Skip to content

Commit 56b8547

Browse files
committed
docs: add types check and hint in markdown (#508)
* docs: add types check in markdown * fix: lint * feat: use paths instead of nodenext moduleresolution * fix: ts error in mdx
1 parent 1381f1a commit 56b8547

File tree

20 files changed

+297
-226
lines changed

20 files changed

+297
-226
lines changed

examples/plugin/tsconfig.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
{
2-
"extends": "../../tsconfig.json",
32
"compilerOptions": {
4-
"baseUrl": "./",
5-
"rootDir": "src",
6-
"outDir": "lib"
3+
"module": "ESNext",
4+
"target": "ESNext",
5+
"jsx": "react",
6+
"moduleResolution": "node",
7+
"lib": ["ESNext"],
8+
"skipLibCheck": true
79
},
8-
"include": ["src"]
10+
"include": ["src"],
911
}

examples/rax-component/docs/usage.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ sidebar_label: 用法
44

55
本 Demo 演示一行文字的用法。
66

7-
```jsx preview
7+
```tsx preview
8+
import { createElement } from 'rax';
89
import ExampleRaxComponent from 'example-rax-component';
910
import styles from './usage.module.css';
1011

1112
export default function App () {
1213
return (
1314
<div className={styles.usageContainer}>
14-
<ExampleRaxComponent />
15+
<ExampleRaxComponent title="XYZ" />
1516
</div>
1617
)
1718
}

examples/rax-component/tsconfig.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55
"jsx": "preserve",
66
"jsxFactory": "createElement",
77
"moduleResolution": "node",
8-
"lib": ["ES2017", "DOM"],
9-
"sourceMap": true,
10-
"allowJs": true,
11-
"noUnusedLocals": true,
12-
"noImplicitReturns": true,
13-
"noImplicitThis": true,
14-
"noImplicitAny": true,
8+
"lib": ["ES2017", "DOM", "DOM.Iterable"],
9+
"strict": true,
1510
"skipLibCheck": true,
11+
"paths": {
12+
"example-rax-component": ["./src"],
13+
"example-rax-component/*": ["./src/*"]
14+
},
1615
"types": ["vitest/globals"]
1716
},
1817
"include": ["src", "tests"],

examples/react-component/docs/usage.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ sidebar_label: 用法
44

55
本 Demo 演示一行文字的用法。
66

7-
```jsx preview
7+
```tsx preview
8+
import * as React from 'react';
89
import Component from 'example-pkg-react-component';
910

1011
export default function App () {
1112
return (
1213
<Component />
1314
)
1415
}
15-
```
16+
```

examples/react-component/package.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@
99
"dist",
1010
"build"
1111
],
12-
"module": "esm/index.js",
1312
"exports": {
1413
".": {
15-
"import": "./esm/index.js",
16-
"es2017": "./es2017/index.js"
14+
"es2017": {
15+
"types": "./es2017/index.d.ts",
16+
"default": "./es2017/index.js"
17+
},
18+
"default": {
19+
"types": "./esm/index.d.ts",
20+
"default": "./esm/index.js"
21+
}
1722
},
1823
"./*": "./*"
1924
},
Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
{
22
"compilerOptions": {
3-
"outDir": "build",
4-
"module": "esnext",
5-
"target": "esnext",
3+
"module": "ESNext",
4+
"target": "ESNext",
65
"jsx": "react",
76
"moduleResolution": "node",
8-
"lib": ["es6", "dom"],
9-
"sourceMap": true,
10-
"allowJs": true,
11-
"noUnusedLocals": true,
12-
"noImplicitReturns": true,
13-
"noImplicitThis": true,
14-
"noImplicitAny": true,
7+
"lib": ["ESNext", "DOM", "DOM.Iterable"],
8+
"strict": true,
159
"skipLibCheck": true,
1610
"paths": {
1711
"@/*": ["./src/*"],
12+
"example-pkg-react-component": ["./src"],
13+
"example-pkg-react-component/*": ["./src/*"]
1814
}
1915
},
20-
"include": ["src/*.ts", "src/*.tsx"],
21-
"exclude": ["node_modules", "build", "public"]
16+
"include": ["src"],
2217
}

examples/react-multi-components/docs/Avatar.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
sidebar_label: Avatar
33
---
44

5-
```jsx preview
6-
import Avatar from 'pkg-react-multi-components-example/Avatar';
5+
```tsx preview
6+
import * as React from 'react';
7+
import Avatar from 'example-pkg-react-multi-components/Avatar';
78

89
export default function App () {
910
return (

examples/react-multi-components/docs/Button.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
sidebar_label: Button
33
---
44

5-
```jsx preview
6-
import Button from 'pkg-react-multi-components-example/Button';
5+
```tsx preview
6+
import * as React from 'react';
7+
import Button from 'example-pkg-react-multi-components/Button';
78

89
export default function App () {
910
return (

examples/react-multi-components/package.json

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,27 @@
99
"dist",
1010
"build"
1111
],
12-
"module": "esm/Button/index.js",
1312
"exports": {
1413
"./Button": {
15-
"import": "./esm/Button/index.js",
16-
"es2017": "./es2017/Button/index.js"
14+
"es2017": {
15+
"types": "./es2017/Button/index.d.ts",
16+
"default": "./es2017/Button/index.js"
17+
},
18+
"import": {
19+
"types": "./esm/Button/index.d.ts",
20+
"default": "./esm/Button/index.js"
21+
}
1722
},
1823
"./Avatar": {
19-
"import": "./esm/Avatar/index.js",
20-
"es2017": "./es2017/Avatar/index.js"
21-
},
22-
"./*": "./*"
24+
"es2017": {
25+
"types": "./es2017/Avatar/index.d.ts",
26+
"default": "./es2017/Avatar/index.js"
27+
},
28+
"import": {
29+
"types": "./esm/Avatar/index.d.ts",
30+
"default": "./esm/Avatar/index.js"
31+
}
32+
}
2333
},
2434
"sideEffects": [
2535
"dist/*",
Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,16 @@
11
{
2-
"compileOnSave": false,
3-
"buildOnSave": false,
42
"compilerOptions": {
5-
"outDir": "build",
6-
"module": "esnext",
7-
"target": "esnext",
3+
"module": "ESNext",
4+
"target": "ESNext",
85
"jsx": "react",
9-
"moduleResolution": "node",
10-
"lib": ["es6", "dom"],
11-
"sourceMap": true,
12-
"allowJs": true,
13-
"noUnusedLocals": true,
14-
"noImplicitReturns": true,
15-
"noImplicitThis": true,
16-
"noImplicitAny": true,
6+
"moduleResolution": "nodenext",
7+
"lib": ["ESNext", "DOM", "DOM.Iterable"],
8+
"strict": true,
179
"skipLibCheck": true,
1810
"paths": {
19-
"@/*": ["./src/*"],
11+
"example-pkg-react-multi-components": ["./src"],
12+
"example-pkg-react-multi-components/*": ["./src/*"]
2013
}
2114
},
22-
"include": ["src/*.ts", "src/*.tsx"],
23-
"exclude": ["node_modules", "build", "public"]
15+
"include": ["src"],
2416
}

0 commit comments

Comments
 (0)