I'm using TypeScript and I want to use a scoped package (e.g. @foo/bar
, @babel/core
, etc.) that doesn't ship its own type declarations.
I've tried to run something like
npm install @types/@foo/bar
but it doesn't seem to be available.
Is there any way to get these .d.ts
for these packages into the @types
scope? Is there a way to write my own scoped packages on DefinitelyTyped if I need to?
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 runYes! From the Definitely Typed README.md: