Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NPM package aliases and Typescript definition files

I have a package that I need in two separate versions - luckily, as of npm 6.9.0 I can achieve that pretty easily.

The question is: the package has type definitions. But, if I create an alias for that package, i refer to it by the alias created - and the typings are not automatically detected because the name is changed. How can I achieve so it's auto-detected?

like image 367
wopolow Avatar asked Sep 01 '25 10:09

wopolow


1 Answers

One solution I've come up with is copying @types/package-name into @types/package-alias, run after postinstall npm script. Maybe it'll get automated overtime.

EDIT: The better approach would be to just install @types in specified version, aliased as well.

npm install @types/package-alias@npm:@types/[email protected]

like image 181
wopolow Avatar answered Sep 03 '25 02:09

wopolow