Reference: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html
Example
{
"compilerOptions": {
"strict": true,
"outDir": "build",
// "allowJs": true, // cannot use together with 'declaration'
"target": "es5",
"module": "commonjs",
"lib": [
"es5",
"es2015.promise"
],
"sourceMap": true,
"declaration": true,
},
"include": [
"**/*.ts"
],
"exclude": [
"node_modules",
"**/*.spec.ts",
"build" // exclude out dir when declaration is put
]
}
$ npm install — save-dev @types/node
To package a module for both Javascript & typescript use, enable "declaration" in compiling (tsconfig.json). Then use "main" and "types" in package.json to point to Javascript entry and Typescript declaration
...
"description": "A nice greeter",
"main": "lib/index.js",
"types": "lib/index.d.ts",
...
Packaging To package a module for both Javascript & typescript use, enable "declaration" in compiling (tsconfig.json). Then use "main" and "types" in package.json to point to Javascript entry and Typescript declaration ... "description": "A nice greeter", "main": "lib/index.js", "types": "lib/index.d.ts", ...