kentor
kentor

Reputation: 18504

Reexporting external types in a npm package

I created a npm package which uses types from the definetely typed repo. I installed these types as devDependency on the npm package and I was able to use them just fine like this:

export class Example {
  constructor (options: ExternalTypes.Options) {}
}

However when I install the npm package trying to instantiate the Example class the ExternalTypes.Options types are not known.

My question:

How do I use external typescript types in a NPM package so, that users of that npm package get the types as well? Do I need to install types which are supposed to be public as dependency instead of as devDepedency?

Upvotes: 2

Views: 322

Answers (1)

Paleo
Paleo

Reputation: 23672

Do I need to install types which are supposed to be public as dependency instead of as devDepedency?

This is what I do.

When npm installs a package, it also installs dependencies but not devDependencies. Your package user needs ExternalTypes.Options, so it's required to declare it as a dependency.

Upvotes: 2

Related Questions