Skip to content

Commit 877308e

Browse files
committed
Updates used for testing preactjs/preact-iso#130
1 parent edd9b3d commit 877308e

File tree

4 files changed

+77
-4
lines changed

4 files changed

+77
-4
lines changed

src/test.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/test.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/test.tsx

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import { h, FunctionalComponent } from "preact";
2+
import { Router, Route } from "preact-iso";
3+
4+
const A: FunctionalComponent = () => <div>A</div>;
5+
const B: FunctionalComponent = () => <div>B</div>;
6+
const C: FunctionalComponent = () => <div>C</div>;
7+
8+
export function RoutingTestCases() {
9+
return (
10+
<>
11+
{/* =========================================
12+
CASE GROUP 1: <Route /> (official API)
13+
========================================= */}
14+
15+
{/* Case 1 */}
16+
{/* (1) SHOULD work: yes */}
17+
{/* (2) DOES work with official d.ts: yes */}
18+
<Route path="/a" component={A} />
19+
20+
{/* Case 2 */}
21+
{/* (1) SHOULD work: yes */}
22+
{/* (2) DOES work with official d.ts: yes */}
23+
<Route default component={B} />
24+
25+
{/* Case 3 */}
26+
{/* (1) SHOULD work: no */}
27+
{/* (2) DOES work with official d.ts: no */}
28+
{/* @ts-expect-error */}
29+
<Route />
30+
31+
{/* Case 4 */}
32+
{/* (1) SHOULD work: no */}
33+
{/* (2) DOES work with official d.ts: no */}
34+
{/* @ts-expect-error */}
35+
<Route path="/bad" default component={A} />
36+
37+
{/* =========================================
38+
CASE GROUP 2: Arbitrary components inside <Router>
39+
========================================= */}
40+
41+
<Router>
42+
{/* Case 5 */}
43+
{/* (1) SHOULD work: yes */}
44+
{/* (2) DOES work with official d.ts: yes */}
45+
<A />
46+
47+
{/* Case 6 */}
48+
{/* (1) SHOULD work: runtime yes, type-safety debatable */}
49+
{/* (2) DOES work with official d.ts: no */}
50+
{/* @ts-expect-error */}
51+
<A path="/a" />
52+
53+
{/* Case 7 */}
54+
{/* (1) SHOULD work: runtime yes, type-safety debatable */}
55+
{/* (2) DOES work with official d.ts: no */}
56+
{/* @ts-expect-error */}
57+
<B default />
58+
59+
{/* Case 8 */}
60+
{/* (1) SHOULD work: no */}
61+
{/* (2) DOES work with official d.ts: no */}
62+
{/* @ts-expect-error */}
63+
<C path="/c" default />
64+
65+
{/* Case 9 */}
66+
{/* (1) SHOULD work: yes */}
67+
{/* (2) DOES work with official d.ts: yes */}
68+
<C />
69+
</Router>
70+
</>
71+
);
72+
}

tsconfig.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
"outDir": "lib",
44
"rootDir": "src",
55

6-
"jsx": "react",
6+
"jsx": "react-jsx",
7+
"jsxImportSource": "preact",
8+
79
"declaration": true,
810
"strict": true,
911
"esModuleInterop": true,
@@ -14,6 +16,8 @@
1416
"moduleResolution": "node",
1517
"target": "es2022",
1618
"lib": ["es2022", "dom"],
19+
20+
"skipLibCheck": false
1721
},
1822
"include": ["src/**/*.ts", "src/**/*.tsx"]
1923
}

0 commit comments

Comments
 (0)