Tencent / tdesign-vue-starter

A starter-kit for TDesign Vue UI components.
https://tdesign.tencent.com/starter/vue/
MIT License
373 stars 92 forks source link

[组件名称] 执行 npm run build报错 #259

Open miller806 opened 1 year ago

miller806 commented 1 year ago

tdesign-vue-starter 版本

执行 npm run build报错

重现链接

No response

重现步骤

  1. 使用TDesign Starter创建项目,选项为vue3非简化版
  2. npm install
  3. npm run build,出现以下结果

期望结果

打包完成,生成disk文件夹

实际结果

执行 npm run build报以下错:

second@0.6.1 build vue-tsc --noEmit && vite build --mode release

src/utils/request/Axios.ts:66:44 - error TS2345: Argument of type '(config: AxiosRequestConfig) => AxiosRequestConfig' is not assignable to parameter of type '(value: InternalAxiosRequestConfig) => InternalAxiosRequestConfig | Promise<InternalAxiosRequestConfig>'. Type 'AxiosRequestConfig' is not assignable to type 'InternalAxiosRequestConfig | Promise<InternalAxiosRequestConfig>'. Type 'AxiosRequestConfig' is not assignable to type 'InternalAxiosRequestConfig'. Types of property 'headers' are incompatible. Type 'AxiosHeaders | (Partial<RawAxiosHeaders & { Accept: AxiosHeaderValue; "Content-Length": AxiosHeaderValue; "User-Agent": AxiosHeaderValue; "Content-Encoding": AxiosHeaderValue; Authorization: AxiosHeaderValue; } & { ...; }> & Partial<...>)' is not assignable to type 'AxiosRequestHeaders'. Type 'Partial<RawAxiosHeaders & { Accept: AxiosHeaderValue; "Content-Length": AxiosHeaderValue; "User-Agent": AxiosHeaderValue; "Content-Encoding": AxiosHeaderValue; Authorization: AxiosHeaderValue; } & { ...; }> & Partial<...>' is not assignable to type 'AxiosRequestHeaders'. Type 'Partial<RawAxiosHeaders & { Accept: AxiosHeaderValue; "Content-Length": AxiosHeaderValue; "User-Agent": AxiosHeaderValue; "Content-Encoding": AxiosHeaderValue; Authorization: AxiosHeaderValue; } & { ...; }> & Partial<...>' is missing the following properties from type 'AxiosHeaders': set, has, clear, normalize, and 21 more.

66 this.instance.interceptors.request.use((config: AxiosRequestConfig) => {



Found 1 error in src/utils/request/Axios.ts:66

### 框架版本

_No response_

### 浏览器版本

_No response_

### 系统版本

win11

### Node版本

v16.18.0

### 补充说明

`npm run dev`没有问题,我问了下`chatGpt`,它给我的回答是
```
这个错误信息是 TypeScript 编译器在编译代码时给出的,它的意思是您在给一个类型为 AxiosRequestConfig 的变量赋值时,使用了一个类型为 AxiosHeaders | (Partial<RawAxiosHeaders> & Partial<...>) 的值,而 TypeScript 认为这是不允许的,因为 AxiosHeaders | (Partial<RawAxiosHeaders> & Partial<...>) 不是 AxiosRequestHeaders。解决这个问题的方法有两种:

1. 将变量的类型改为 AxiosRequestConfig,并将变量赋值为一个完整的 AxiosRequestConfig 对象。
2. 将变量的类型改为 InternalAxiosRequestConfig,并将变量赋值为一个完整的 InternalAxiosRequestConfig 对象。
```
但我是前端新手,还不知道怎么解决。
github-actions[bot] commented 1 year ago

👋 @miller806,感谢给 TDesign 提出了 issue。 请根据 issue 模版确保背景信息的完善,我们将调查并尽快回复你。

github-actions[bot] commented 1 year ago

♥️ 有劳 @uyarn 尽快确认问题。 确认有效后将下一步计划和可能需要的时间回复给 @miller806 。