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

definitelytyped, typescript, umd, webpack

Solution

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

In your case it would 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"
  ]
}

Problem

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?

Original source