File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change 6
6
"types" : " ./index.d.ts" ,
7
7
"scripts" : {
8
8
"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"
10
12
},
11
13
"repository" : " github:gr2m/javascript-plugin-architecture-with-typescript-definitions" ,
12
14
"keywords" : [
Original file line number Diff line number Diff line change
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 ;
You can’t perform that action at this time.
0 commit comments