Skip to content

Commit 6b9d94c

Browse files
committed
chore: collapse legacy FAQs
1 parent f70e5fc commit 6b9d94c

File tree

2 files changed

+34
-24
lines changed

2 files changed

+34
-24
lines changed

README.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,6 @@ Starting with `3.0.0`, you can use this plugin with Rollup.
5959

6060
Here are some FAQ's and solutions.
6161

62-
### Missing some declaration files after build (before `1.7.0`)
63-
64-
By default, the `skipDiagnostics` option is set to `true` which means type diagnostics will be skipped during the build process (some projects may have diagnostic tools such as `vue-tsc`). Files with type errors which interrupt the build process will not be emitted (declaration files won't be generated).
65-
66-
If your project doesn't use type diagnostic tools, you can set `skipDiagnostics: false` and `logDiagnostics: true` to turn on diagnostic and logging features of this plugin. Type errors during build will be logged to the terminal.
67-
68-
### Type error when using both `script` and `setup-script` in Vue component (before `3.0.0`)
69-
70-
This is usually caused by using the `defineComponent` function in both `script` and `setup-script`. When `vue/compiler-sfc` compiles these files, the default export result from `script` gets merged with the parameter object of `defineComponent` from `setup-script`. This is incompatible with parameters and types returned from `defineComponent`. This results in a type error.
71-
72-
Here is a simple [example](https://github.com/qmhc/vite-plugin-dts/blob/main/examples/vue/components/BothScripts.vue). You should remove the `defineComponent` in `script` and export a native object directly.
73-
7462
### Type errors that are unable to infer types from packages in `node_modules`
7563

7664
This is an existing [TypeScript issue](https://github.com/microsoft/TypeScript/issues/42873) where TypeScript infers types from packages located in `node_modules` through soft links (pnpm). A workaround is to add `baseUrl` to your `tsconfig.json` and specify the `paths` for these packages:
@@ -96,6 +84,23 @@ For example: `baseUrl: 'src'` is specified and importing from `<root>/src/compon
9684

9785
Currently, you need to avoid the above situation, or use aliases instead (with the `paths` option).
9886

87+
<details>
88+
<summary>Legacy</summary>
89+
90+
### Missing some declaration files after build (before `1.7.0`)
91+
92+
By default, the `skipDiagnostics` option is set to `true` which means type diagnostics will be skipped during the build process (some projects may have diagnostic tools such as `vue-tsc`). Files with type errors which interrupt the build process will not be emitted (declaration files won't be generated).
93+
94+
If your project doesn't use type diagnostic tools, you can set `skipDiagnostics: false` and `logDiagnostics: true` to turn on diagnostic and logging features of this plugin. Type errors during build will be logged to the terminal.
95+
96+
### Type error when using both `script` and `setup-script` in Vue component (before `3.0.0`)
97+
98+
This is usually caused by using the `defineComponent` function in both `script` and `setup-script`. When `vue/compiler-sfc` compiles these files, the default export result from `script` gets merged with the parameter object of `defineComponent` from `setup-script`. This is incompatible with parameters and types returned from `defineComponent`. This results in a type error.
99+
100+
Here is a simple [example](https://github.com/qmhc/vite-plugin-dts/blob/main/examples/vue/components/BothScripts.vue). You should remove the `defineComponent` in `script` and export a native object directly.
101+
102+
</details>
103+
99104
## Options
100105

101106
```ts

README.zh-CN.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,6 @@ export default defineConfig({
5959

6060
此处将收录一些常见的问题并提供一些解决方案。
6161

62-
### 打包后出现类型文件缺失 (`1.7.0` 之前)
63-
64-
默认情况下 `skipDiagnostics` 选项的值为 `true`,这意味着打包过程中将跳过类型检查(一些项目通常有 `vue-tsc` 等的类型检查工具),这时如果出现存在类型错误的文件,并且这是错误会中断打包过程,那么这些文件对应的类型文件将不会被生成。
65-
66-
如果您的项目没有依赖外部的类型检查工具,这时候可以您可以设置 `skipDiagnostics: false``logDiagnostics: true` 来打开插件的诊断与输出功能,这将帮助您检查打包过程中出现的类型错误并将错误信息输出至终端。
67-
68-
### Vue 组件中同时使用了 `script``setup-script` 后出现类型错误(`3.0.0` 之前)
69-
70-
这通常是由于分别在 `script``setup-script` 中同时使用了 `defineComponent` 方法导致的。 `vue/compiler-sfc` 为这类文件编译时会将 `script` 中的默认导出结果合并到 `setup-script``defineComponent` 的参数定义中,而 `defineComponent` 的参数类型与结果类型并不兼容,这一行为将会导致类型错误。
71-
72-
这是一个简单的[示例](https://github.com/qmhc/vite-plugin-dts/blob/main/example/components/BothScripts.vue),您应该将位于 `script` 中的 `defineComponent` 方法移除,直接导出一个原始的对象。
73-
7462
### 打包时出现了无法从 `node_modules` 的包中推断类型的错误
7563

7664
这是 TypeScript 通过软链接 (pnpm) 读取 `node_modules` 中过的类型时会出现的一个已知的问题,可以参考这个 [issue](https://github.com/microsoft/TypeScript/issues/42873),目前已有的一个解决方案,在你的 `tsconfig.json` 中添加 `baseUrl` 以及在 `paths` 添加这些包的路径:
@@ -96,6 +84,23 @@ export default defineConfig({
9684

9785
目前想要正常打包,需要规避上述情况,或使用别名代替(配合 `paths` 属性)。
9886

87+
<details>
88+
<summary>过时的</summary>
89+
90+
### 打包后出现类型文件缺失 (`1.7.0` 之前)
91+
92+
默认情况下 `skipDiagnostics` 选项的值为 `true`,这意味着打包过程中将跳过类型检查(一些项目通常有 `vue-tsc` 等的类型检查工具),这时如果出现存在类型错误的文件,并且这是错误会中断打包过程,那么这些文件对应的类型文件将不会被生成。
93+
94+
如果您的项目没有依赖外部的类型检查工具,这时候可以您可以设置 `skipDiagnostics: false``logDiagnostics: true` 来打开插件的诊断与输出功能,这将帮助您检查打包过程中出现的类型错误并将错误信息输出至终端。
95+
96+
### Vue 组件中同时使用了 `script``setup-script` 后出现类型错误(`3.0.0` 之前)
97+
98+
这通常是由于分别在 `script``setup-script` 中同时使用了 `defineComponent` 方法导致的。 `vue/compiler-sfc` 为这类文件编译时会将 `script` 中的默认导出结果合并到 `setup-script``defineComponent` 的参数定义中,而 `defineComponent` 的参数类型与结果类型并不兼容,这一行为将会导致类型错误。
99+
100+
这是一个简单的[示例](https://github.com/qmhc/vite-plugin-dts/blob/main/example/components/BothScripts.vue),您应该将位于 `script` 中的 `defineComponent` 方法移除,直接导出一个原始的对象。
101+
102+
</details>
103+
99104
## 选项
100105

101106
```ts

0 commit comments

Comments
 (0)