Skip to content

Commit 85fe882

Browse files
committedOct 9, 2024
expect-type
1 parent 1f3aca5 commit 85fe882

File tree

4 files changed

+85
-2
lines changed

4 files changed

+85
-2
lines changed
 

‎package.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,18 @@
2020
"build": "tsc && vite build",
2121
"dev": "vite",
2222
"prepare": "npm run build",
23-
"lint": "prettier --check .",
23+
"watch:types": "tsc --noEmit --watch",
24+
"lint": "concurrently 'npm:lint:*(!fix)' --names 'lint:' --prefixColors=auto",
25+
"lint:types": "tsc --noEmit",
26+
"lint:prettier": "prettier --check .",
2427
"lint:fix": "prettier --write .",
2528
"test": "vitest"
2629
},
2730
"devDependencies": {
2831
"@types/node": "^20.11.25",
2932
"@vitest/browser": "^1.5.3",
33+
"concurrently": "^9.0.1",
34+
"expect-type": "^1.0.0",
3035
"prettier": "^3.2.5",
3136
"release-plan": "^0.9.0",
3237
"typescript": "latest",

‎pnpm-lock.yaml

+45
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/public-api-types.ts

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* The purpose of these tests is to make sure the types are exposed how we expect,
3+
* and that we double-check what we're exposing as public API
4+
*/
5+
import {expectTypeOf} from 'expect-type';
6+
import {Signal} from './wrapper.ts';
7+
8+
/**
9+
* Top-Level
10+
*/
11+
expectTypeOf<keyof typeof Signal>().toMatchTypeOf<
12+
'State' | 'Computed' | 'subtle' | 'isState' | 'isComputed' | 'isWatcher'
13+
>();
14+
15+
let num = new Signal.State(0);
16+
expectTypeOf(num).toMatchTypeOf<Signal.State<number>>();
17+
expectTypeOf(num.get()).toMatchTypeOf<number>();
18+
expectTypeOf(num.set(1)).toMatchTypeOf<void>();
19+
20+
expectTypeOf<keyof Signal.State<unknown> & string>().toEqualTypeOf<'get' | 'set'>();
21+
expectTypeOf<keyof Signal.Computed<unknown> & string>().toEqualTypeOf<'get'>();
22+
expectTypeOf<keyof typeof Signal.subtle>().toEqualTypeOf<
23+
| 'untrack'
24+
| 'currentComputed'
25+
| 'introspectSources'
26+
| 'introspectSinks'
27+
| 'hasSinks'
28+
| 'hasSources'
29+
| 'Watcher'
30+
| 'watched'
31+
| 'unwatched'
32+
>();

‎tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"lib": ["DOM", "ES2021"],
1414
"strict": true,
1515
"composite": true,
16-
"forceConsistentCasingInFileNames": true
16+
"forceConsistentCasingInFileNames": true,
17+
"allowImportingTsExtensions": true
1718
},
1819
"exclude": ["**/node_modules/**", "**/*.spec.ts", "**/dist/**/*"],
1920
"include": ["src"]

0 commit comments

Comments
 (0)