How to create a TypeScript definition file (d.ts) for the umd library

I am working on surveyjs library

It uses gulp + webpack to build the umd package.

I want to create a set of type definitions (or maybe just a few d.ts files) for use in typescript projects. I would like to have something like this:

import * as Survey from 'surveyjs'; 

All content for the survey. * described here: https://github.com/dmitrykurmanov/surveyjs/blob/master/src/entries/ko.ts

I tried using: github.com/SitePen/dts-generator and github.com/TypeStrong/dts-bundle , but without success, can someone please show me in the right direction?

+5
source share
1 answer

You can request tsc to create declaration files for your code by adding the declaration flag in tsconfig.json .

In your case, it will be:

 { "compilerOptions": { "target": "es5", "module": "es2015", "sourceMap": true, "noImplicitAny": false, "jsx": "react", "declaration": true }, // "filesGlob": [ // "typings/index.d.ts" // ], // TODO "include": [ "typings/index.d.ts", "src/**/*" ], "exclude": [ "node_modules", "**/*.spec.ts" ] } 
+2
source

Source: https://habr.com/ru/post/1258542/


All Articles