vite-plugin-dts 0.9.3 → 0.9.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -2
- package/README.zh-CN.md +23 -4
- package/dist/index.js +10871 -8346
- package/dist/index.mjs +10869 -8343
- package/package.json +29 -21
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ A vite plugin that generate `.d.ts` files from `.ts` or `.vue` source files for
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
9
|
```sh
|
|
10
|
-
|
|
10
|
+
pnpm add vite-plugin-dts -D
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
## Usage
|
|
@@ -122,10 +122,13 @@ export interface PluginOptions {
|
|
|
122
122
|
noEmitOnError?: boolean
|
|
123
123
|
|
|
124
124
|
// Whether skip typescript diagnostics
|
|
125
|
+
// Skip type diagnostics means that type errors will not interrupt the build process
|
|
126
|
+
// But for the source files with type errors will not be emitted
|
|
125
127
|
// Default: true
|
|
126
128
|
skipDiagnostics?: boolean
|
|
127
129
|
|
|
128
130
|
// Whether log diagnostic informations
|
|
131
|
+
// Not effective when `skipDiagnostics` is true
|
|
129
132
|
// Default: false
|
|
130
133
|
logDiagnostics?: boolean
|
|
131
134
|
|
|
@@ -151,11 +154,27 @@ export interface PluginOptions {
|
|
|
151
154
|
Clone and run the following script:
|
|
152
155
|
|
|
153
156
|
```sh
|
|
154
|
-
|
|
157
|
+
pnpm run test:e2e
|
|
155
158
|
```
|
|
156
159
|
|
|
157
160
|
Then check `example/types`.
|
|
158
161
|
|
|
162
|
+
## FAQ
|
|
163
|
+
|
|
164
|
+
Here will include some FAQ's and provide some solutions.
|
|
165
|
+
|
|
166
|
+
### Missing some declaration files after build
|
|
167
|
+
|
|
168
|
+
By default `skipDiagnostics` option is `true`, which means that type diagnostic will be skipped during the build process (some projects may have diagnostic tool such as `vue-tsc`). If there are some files with type errors which will interrupt the build process, these files will not be emitted (not generate declaration files).
|
|
169
|
+
|
|
170
|
+
If your project has not type diagnostic tools, you can set `skipDiagnostics: false` and `logDiagnostics: true` to turn on the diagnostic and log features of this plugin. It will help you to check the type errors during build and log error information to the terminal.
|
|
171
|
+
|
|
172
|
+
### Take type error when using both `script` and `setup-script` in vue component
|
|
173
|
+
|
|
174
|
+
This is usually caused by using `defineComponent` function in both `script` and `setup-script`. When `vue/compiler-sfc` compiles these files, the default export result in `script` will be merged into the parameter object of `defineComponent` that in `setup-script`, but there is incompatible of `defineComponent` returned types and parameter types, then a type error is caused.
|
|
175
|
+
|
|
176
|
+
Here is a simple [example](https://github.com/qmhc/vite-plugin-dts/blob/main/example/components/BothScripts.vue), you should remove the `defineComponent` which in `script` and export a native object directly.
|
|
177
|
+
|
|
159
178
|
## License
|
|
160
179
|
|
|
161
180
|
MIT License.
|
package/README.zh-CN.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
## 安装
|
|
8
8
|
|
|
9
9
|
```sh
|
|
10
|
-
|
|
10
|
+
pnpm add vite-plugin-dts -D
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
## 使用
|
|
@@ -121,10 +121,13 @@ export interface PluginOptions {
|
|
|
121
121
|
noEmitOnError?: boolean
|
|
122
122
|
|
|
123
123
|
// 是否跳过类型诊断
|
|
124
|
+
// 跳过类型诊断意味着出现错误时不会中断打包进程的执行
|
|
125
|
+
// 但对于出现错误的源文件,将无法生成相应的类型文件
|
|
124
126
|
// 默认值: true
|
|
125
127
|
skipDiagnostics?: boolean
|
|
126
128
|
|
|
127
129
|
// 是否打印类型诊断信息
|
|
130
|
+
// 当跳过类型诊断时该属性将不会生效
|
|
128
131
|
// 默认值: false
|
|
129
132
|
logDiagnostics?: boolean
|
|
130
133
|
|
|
@@ -145,16 +148,32 @@ export interface PluginOptions {
|
|
|
145
148
|
}
|
|
146
149
|
```
|
|
147
150
|
|
|
148
|
-
##
|
|
151
|
+
## 示例
|
|
149
152
|
|
|
150
153
|
克隆项目然后执行下列命令:
|
|
151
154
|
|
|
152
155
|
```sh
|
|
153
|
-
|
|
156
|
+
pnpm run test:e2e
|
|
154
157
|
```
|
|
155
158
|
|
|
156
159
|
然后检查 `example/types` 目录。
|
|
157
160
|
|
|
161
|
+
## 常见问题
|
|
162
|
+
|
|
163
|
+
此处将收录一些常见的问题并提供一些解决方案。
|
|
164
|
+
|
|
165
|
+
### 打包后出现类型文件缺失
|
|
166
|
+
|
|
167
|
+
默认情况下 `skipDiagnostics` 选项的值为 `true`,这意味着打包过程中将跳过类型检查(一些项目通常有 `vue-tsc` 等的类型检查工具),这时如果出现存在类型错误的文件,并且这是错误会中断打包过程,那么这些文件对应的类型文件将不会被生成。
|
|
168
|
+
|
|
169
|
+
如果您的项目没有依赖外部的类型检查工具,这时候可以您可以设置 `skipDiagnostics: false` 和 `logDiagnostics: true` 来打开插件的诊断与输出功能,这将帮助您检查打包过程中出现的类型错误并将错误信息输出至终端。
|
|
170
|
+
|
|
171
|
+
### Vue 组件中同时使用了 `script` 和 `setup-script` 后出现类型错误
|
|
172
|
+
|
|
173
|
+
这通常是由于分别在 `script` 和 `setup-script` 中同时使用了 `defineComponent` 方法导致的。 `vue/compiler-sfc` 为这类文件编译时会将 `script` 中的默认导出结果合并到 `setup-script` 的 `defineComponent` 的参数定义中,而 `defineComponent` 的参数类型与结果类型并不兼容,这一行为将会导致类型错误。
|
|
174
|
+
|
|
175
|
+
这是一个简单的[示例](https://github.com/qmhc/vite-plugin-dts/blob/main/example/components/BothScripts.vue),您应该将位于 `script` 中的 `defineComponent` 方法移除,直接导出一个原始的对象。
|
|
176
|
+
|
|
158
177
|
## 授权
|
|
159
178
|
|
|
160
|
-
MIT
|
|
179
|
+
MIT 授权。
|