Harold Smith
Harold Smith

Reputation: 932

Should I write TypeScript definitions for my TypeScript module?

I am the process of writing my first TypeScript-based NPM module. When I am done, it will be exported through "main" in package.json, and this field will point at the compiled, plain javascript.

So when I require this module in another TypeScript module, IntelliSense and type checking will not work for my module, right?

So one solution would be to add a definition file. But definition files are for JS libs, right? It shouldn't be necessary to write a definition file for a TS project, right?

So... how am I going to export my definitions along with my project?

Upvotes: 0

Views: 39

Answers (1)

Harold Smith
Harold Smith

Reputation: 932

It seems I just need to add "declaration": true to my tsconfig.json. Pretty simple.

Upvotes: 2

Related Questions