wopolow
wopolow

Reputation: 401

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?

Upvotes: 4

Views: 1637

Answers (1)

wopolow
wopolow

Reputation: 401

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]

Upvotes: 3

Related Questions