Skip to content

Commit 0c0240f

Browse files
committed
test: typescript
1 parent 3e64163 commit 0c0240f

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
"types": "./index.d.ts",
77
"scripts": {
88
"build": "tsc src/index.ts --declaration --outDir .",
9-
"test": "jest --coverage"
9+
"test": "npm run -s test:code && npm run -s test:typescript",
10+
"test:code": "jest --coverage",
11+
"test:typescript": "npx tsc --noEmit --declaration --noUnusedLocals test-typescript.ts"
1012
},
1113
"repository": "github:gr2m/javascript-plugin-architecture-with-typescript-definitions",
1214
"keywords": [

test-typescript.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// ************************************************************
2+
// THIS CODE IS NOT EXECUTED. IT IS JUST FOR TYPECHECKING
3+
// ************************************************************
4+
5+
import { Base } from "./src";
6+
7+
function isString(what: string) {}
8+
9+
// sets .options types from constructor options
10+
const base = new Base({ option: "value" });
11+
isString(base.options.option);
12+
13+
// sets .options types from Base.defaults({})
14+
const BaseWithDefaults = Base.defaults({ parentOption: "value" });
15+
const baseWithDefaults = new BaseWithDefaults({ childOption: "value" });
16+
17+
isString(baseWithDefaults.options.childOption);
18+
// see #32
19+
isString(baseWithDefaults.options.parentOption);
20+
21+
// @ts-expect-error see #31
22+
baseWithDefaults.unknown;

0 commit comments

Comments
 (0)