Skip to content

Commit c4c7c2b

Browse files
Ship TypeScript definitions
Generate .d.ts files in the /lib directory and include in npm package.
1 parent c2f6153 commit c4c7c2b

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
"author": "Drew Keller <drew@wimpyprogrammer.com>",
1010
"license": "MIT",
1111
"main": "lib/index.js",
12-
"directories": {
13-
"lib": "lib"
14-
},
12+
"types": "./lib/index.d.ts",
13+
"files": ["lib/"],
1514
"engines": {
1615
"node": ">=8"
1716
},
1817
"scripts": {
19-
"build": "npm run clean && babel src -d lib --extensions '.js,.ts' --ignore '**/*.spec.js','**/*.spec.ts'",
18+
"build": "npm run clean && babel src -d lib --extensions '.js,.ts' --ignore '**/*.spec.js','**/*.spec.ts' && npm run build-types",
2019
"build-demo": "webpack --config demo/webpack.config.js",
20+
"build-types": "tsc -p ./tsconfig.types.json",
2121
"clean": "rimraf lib/*",
2222
"format": "prettier --write 'src/**'",
2323
"lint": "tsc -p ./tsconfig.json; eslint ./src --report-unused-disable-directives --ext .js,.ts --parser-options=project:./tsconfig.json",

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"downlevelIteration": true,
77
"esModuleInterop": true,
88
"forceConsistentCasingInFileNames": true,
9-
"rootDir": "./",
109
"lib": [
1110
"es5",
1211
"es2015.collection",
@@ -20,6 +19,7 @@
2019
"noImplicitReturns": true,
2120
"noUnusedLocals": true,
2221
"noUnusedParameters": true,
22+
"outDir": "./lib",
2323
"pretty": true,
2424
"sourceMap": true,
2525
"strict": true

tsconfig.types.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"compilerOptions": {
3+
// Necessary due to https://github.com/microsoft/TypeScript/issues/7546
4+
"allowJs": false,
5+
"checkJs": false,
6+
7+
"declaration": true,
8+
"emitDeclarationOnly": true,
9+
"noEmit": false
10+
},
11+
"exclude": ["**/*.spec.ts"],
12+
"extends": "./tsconfig.json"
13+
}

0 commit comments

Comments
 (0)