Skip to content

Commit

Permalink
Merge branch 'main' into eslint_peer_0130
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan authored Feb 20, 2024
2 parents 74ff587 + e1199b8 commit b22806d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,20 @@ export const Button = (props?: ButtonProps) => {};
```

The above is a standard writeup where `ButtonProps` will be extracted into the table and `Button` will be the title of the table.
If you use the default export, the filename will be used as the form title. The generated content is as follows:
If you use the default export, the filename will be used as the form title.

Notice that export features declared elsewhere are not available.

```tsx
const A = () => {};

export { A }; // wrong
export default A; // wrong
export const B = () => {}; // right
export default () => {}; // right
```

The generated content is as follows:

```mdx
### ButtonTest
Expand All @@ -267,6 +280,12 @@ If React types are used in Props, you need to add the types in tsconfig.json, ot
}
```

The best way is that you import the type directly:

```tsx
import { FC } from 'react';
```

:::

- `documentation` is used in tool library scenarios to parse JSDoc annotations.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,20 @@ export type ButtonProps = {
export const Button = (props?: ButtonProps) => {};
```

上面是一个标准写法,其中 `ButtonProps` 将被提取至表格中, `Button` 作为表格的标题。
如果使用默认导出,文件名将作为表格标题。生成的内容如下:
上面是一个标准写法,其中 `ButtonProps` 将被提取至表格中, `Button` 作为表格的标题。如果使用默认导出,文件名将作为表格标题。

需要注意的是,export 导出事先定义的特性将不会被解析。

```tsx
const A = () => {};

export { A }; // wrong
export default A; // wrong
export const B = () => {}; // right
export default () => {}; // right
```

生成的内容如下:

```mdx
### ButtonTest
Expand All @@ -262,6 +274,12 @@ export const Button = (props?: ButtonProps) => {};
}
```

更好的方式是直接引用类型,例如

```tsx
import { FC } from 'react';
```

:::

- `documentation`适用于工具库场景,用来解析 JSDoc 注释。
Expand Down

0 comments on commit b22806d

Please sign in to comment.