I am working on the library surveyjs
It uses gulp+webpack to build umd bundle.
I want to create the type definition bundle (or may be just multiple d.ts files) for using in typescript projects. I would like to have something like that:
import * as Survey from 'surveyjs';
All contens for Survey.* is described here: https://github.com/dmitrykurmanov/surveyjs/blob/master/src/entries/ko.ts
I have tried to use: github.com/SitePen/dts-generator and github.com/TypeStrong/dts-bundle but whithout success, could somebody please show me the right direction?
d. ts files are declaration files that contain only type information. These files don't produce . js outputs; they are only used for typechecking. We'll learn more about how to write our own declaration files later.
As toskv mentioned you can use tsc to generate the .d.ts files. Problem there is that the compiler creates multiple declaration files, one for each of your .ts file. I had the same problem with another projected I worked on. I soved it by creating a small plugin for webpack which merges the .d.ts files generated by tsc.
You can check it out on here: https://www.npmjs.com/package/typescript-declaration-webpack-plugin
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With