DEV Community

Discussion on: Generating TypeScript Definition Files from JavaScript

Collapse
 
abinashgommt profile image
Abinash Patra

Just wondering, if instead of jsDoc, we can use only *.d.ts files for the type-checking purposes same as the jsDoc comment

This will allow my code to be lightly coupled with type-system at the same time, allowing me the benefits of type-safety

To summarize: Idea is to have .ts / .js files without any typescript specific language construct, with only .d.ts files accompanying them

Anyone used it like this or any thoughts on this ?

Collapse
 
dakmor profile image
Thomas Allmer

this is actually typescripts main use case it gets compiled to .js + d.ts files which you then publish.
e.g. even full typescript project have "only" js in their node_modules folder.

often these .js files are accompanied by d.ts files or there is a dedicated package @types/packageName.

So in short yes manually writing js and declaration files for it certainly works as well :)