Skip to content

Commit e3a44ba

Browse files
authored
refactor: split types/check.ts into smaller files (#79)
* chore(tsc): move `assert` util to shared file * chore(tsc): remove `skipLibCheck` config; - prevents intellisense "*.d.ts" checks? * chore(tsc): split `types/check.ts` into smaller files
1 parent 7b998a4 commit e3a44ba

File tree

15 files changed

+825
-771
lines changed

15 files changed

+825
-771
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
"scripts": {
7878
"build": "node bin",
7979
"test": "uvu src \".test.ts$\" -r ./bin/register",
80-
"types": "tsc"
80+
"types": "tsc --noEmit --skipLibCheck"
8181
},
8282
"dependencies": {
8383
"regexparam": "^2.0.0"

tsconfig.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
{
22
"compilerOptions": {
33
"strict": true,
4-
"noEmit": true,
54
"allowJs": true,
6-
"checkJs": true,
75
"target": "esnext",
86
"module": "esnext",
9-
"skipLibCheck": true,
10-
"moduleResolution": "node",
117
"strictBindCallApply": true,
128
"forceConsistentCasingInFileNames": true,
139
"lib": ["esnext", "dom.iterable", "webworker"],
1410
"strictFunctionTypes": true,
11+
"moduleResolution": "node",
1512
"strictNullChecks": true,
1613
"noImplicitThis": true,
1714
"noImplicitAny": true,
1815
"alwaysStrict": true,
1916
"baseUrl": "./src",
17+
"checkJs": true,
2018
"paths": {
2119
"worktop": ["./router.d.ts", "./router.ts"],
2220
"worktop/cache": ["./cache.d.ts", "./cache.ts"],

types/base64.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import * as Base64 from 'worktop/base64';
2+
3+
assert<string>(Base64.encode('asd'));
4+
assert<string>(Base64.base64url('asd'));
5+
assert<string>(Base64.decode('asd'));
6+
7+
// @ts-expect-error
8+
Base64.encode(12345);
9+
10+
// @ts-expect-error
11+
Base64.encode(new Uint8Array);

types/cache.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import * as Cache from 'worktop/cache';
2+
3+
declare const event: FetchEvent;
4+
5+
// @ts-expect-error
6+
Cache.save(event, 123);
7+
// @ts-expect-error
8+
Cache.save(123, event);
9+
// @ts-expect-error
10+
Cache.save(123);
11+
12+
assert<Response>(
13+
Cache.save(event, new Response)
14+
);
15+
16+
assert<Response>(
17+
Cache.save(event, new Response, '/custom')
18+
);
19+
20+
assert<Response>(
21+
Cache.save(event, new Response, new Request('/custom'))
22+
);
23+
24+
// @ts-expect-error
25+
Cache.lookup(event, new Response);
26+
27+
Cache.lookup(event, '/custom');
28+
Cache.lookup(event, new Request('/custom'));

0 commit comments

Comments
 (0)