Reputation: 4725
Suppose I want to use a package named some-other-package
for its typing.
I want to use TypeScript typeof
to extract it's typing like this
import someOtherPackage from "some-other-package";
export const myFunction = (param: typeof someOtherPackage) =>
JSON.stringify(param);
And my package has an exported function called myFunction
for people who npm install
my package.
Now, should I list some-other-package
as my package's dependencies
?
If so, when people npm install
my package, I think they will be misleading that my package is actually using those js
code as well.
Is there any other better way to do this?
Upvotes: 1
Views: 123
Reputation: 527
you can do import type
now, which I believe will only download the dependecy types while compiling. This will always erase when is not needed and therefore won't be downloaded on runtime
More about that on typescript 3.8 release notes
Upvotes: 1