How can I install TypeScript declarations for scoped/namespaced packages via @types? How can I install TypeScript declarations for scoped/namespaced packages via @types? typescript typescript

How can I install TypeScript declarations for scoped/namespaced packages via @types?


Is there any way to get these .d.ts for these packages into the @types scope?

Yes there is a way! It's just a little unintuitive.

npm doesn't permit scoped packages to contain @ in their name, so these names are mangled to use two underscores in place of the @.

So as an example, if you want to install type declarations for the package @foo/bar, you'll need to run

npm install @types/foo__bar

Is there a way to write my own scoped packages on DefinitelyTyped if I need to?

Yes! From the Definitely Typed README.md:

Types for a scoped package @foo/bar should go in types/foo__bar. Note the double underscore.