Pasho
Pasho

Reputation: 488

How to generate typings for a library written in typescript?

I have a library written in TypeScript and distributed as a JavaScript bundle. It is used in several apps (JavaScript, CoffeeScript, TypeScript), some of which are pretty old. I want to reference the same piece of code in all of them. That means I need typings for the TypeScript users. Is there a tool to generate typings from TypeScript codebase? Compiler (tsc) doesn't seem to support that.

Upvotes: 1

Views: 879

Answers (1)

Balázs Édes
Balázs Édes

Reputation: 13816

Have a look at the --declaration compiler option. It will generate the d.ts file(s) for you. It's also available if you are using a tsconfig.json file for storing your compiler options.

https://www.typescriptlang.org/docs/handbook/compiler-options.html

Upvotes: 4

Related Questions