Daniel Rosenwasser
Daniel Rosenwasser

Reputation: 23443

How can I install @types compatible with an older version of TypeScript?

My project uses package like @types/express and @types/body-parser. Recently these .d.ts files were updated to use generic defaults, but that means these declaration files now require TypeScript 2.3 or above.

However, my project still uses an older version of TypeScript - TypeScript 2.2. How do I use npm to make sure my project can still understand these definition files without upgrading?

Upvotes: 4

Views: 1314

Answers (1)

Daniel Rosenwasser
Daniel Rosenwasser

Reputation: 23443

The @types publisher tool actually tags releases based on compatibility.

To be able to install declaration files that are compatible with TypeScript 2.2, you can write

npm install @types/[email protected]

It's not always perfect, but it'll usually get the job done.

Upvotes: 6

Related Questions