Skip to content

Commit 864e2e6

Browse files
committed
Add a build script which generates .d.ts files for developers using the package with TypeScript
1 parent 957e651 commit 864e2e6

4 files changed

Lines changed: 23 additions & 3 deletions

File tree

‎package.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
"version": "0.1.0",
44
"description": "Node.js implementation of a W3C WoT Web Thing",
55
"type": "module",
6+
"types": "dist/index.d.ts",
67
"scripts": {
78
"test": "node --test test/*.test.js",
89
"lint": "eslint .",
910
"format": "prettier --write .",
1011
"format:check": "prettier --check .",
11-
"typecheck": "tsc",
12+
"build": "tsc",
13+
"typecheck": "tsc -p tsconfig.typecheck.json",
1214
"example": "node ./examples/lamp.js"
1315
},
1416
"repository": {

‎src/index.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export { default as Thing } from './thing.js';
2+
export { default as ThingServer } from './thing-server.js';
3+
export { default as InteractionAffordance } from './interaction-affordance.js';
4+
export { default as PropertyAffordance } from './property-affordance.js';
5+
export { default as ValidationError } from './validation-error.js';

‎tsconfig.json‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
"compilerOptions": {
33
"allowJs": true,
44
"checkJs": true,
5-
"noEmit": true,
5+
"declaration": true,
6+
"emitDeclarationOnly": true,
7+
"outDir": "dist",
8+
"rootDir": "src",
69
"strict": true,
710
"module": "nodenext",
811
"moduleResolution": "nodenext",
912
"target": "es2022"
1013
},
11-
"include": ["src/**/*.js", "examples/**/*.js"]
14+
"include": ["src/**/*.js"]
1215
}

‎tsconfig.typecheck.json‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"declaration": false,
5+
"emitDeclarationOnly": false,
6+
"noEmit": true,
7+
"rootDir": "."
8+
},
9+
"include": ["src/**/*.js", "examples/**/*.js"]
10+
}

0 commit comments

Comments
 (0)