Reputation: 334
For packages that don't come with it's own types, next step is to look for @types/<package>
for the package typings. However, if there is a package X
, which is forked to a package Y
. How can we use the same @types/<X>
package for the package Y
?
Edit:
Example: node-bunyan doesn't have types. @types/bunyan exists and provides types. Now, I am trying to use a fork of node-bunyan(@scoop/bunyan) while still being able to utilize types from @types/bunyan.
Upvotes: 7
Views: 1117
Reputation: 10069
You could pretend to NPM that the DT types have a different package name which matches your fork.
npm i -D @types/scoop__bunyan@npm:@types/node-bunyan
(This did the job for me just now -- I was suggested this idea by Gerrit0 on the Typescript Discord.)
Upvotes: 2
Reputation: 4352
Probably you can add in your tsconfig.json
"paths":{
"@scoop/bunyan": ["./node_modules/@types/bunyan"]
}
Maybe you can add you to the package Y
in package.json
the path to @types/<X>
.
{
...
"types": "./node_modules/@types/<X>/lib/main.d.ts",
...
}
Upvotes: 6