gpt4 book ai didi

typescript - vue-cli 服务忽略目录上的 typescript 类型错误

转载 作者:行者123 更新时间:2023-12-04 17:38:05 69 4
gpt4 key购买 nike

如何配置 vue-cli 工具不对特定文件夹运行类型检查?

  • 我用 https://cli.vuejs.org 启动了一个新应用程序
  • 我通过 codegen 生成了一个 jQuery/TypeScript API 目录:src/api/
  • 我在 tslint 文件中忽略了 "src/api/**/*.ts",

尝试构建,但 cli 工具也在检查类型错误。

服务的输出是:

vue-cli-service serve

INFO Starting development server...
Starting type checking and linting service...
Using 1 worker with 2048MB memory limit
98% after emitting CopyPlugin

DONE Compiled successfully in 2701ms 3:50:28 PM

Type checking and linting in progress...

App running at:
- Local: http://localhost:8080/
- Network: http://192.168.1.32:8080/

Note that the development build is not optimized.
To create a production build, run npm run build.

ERROR in /home/me/code/g2/frontend/fe_main/src/api/ms-authentication/api/AuthenticationApi.ts
25:12 Type 'null' is not assignable to type 'JQueryAjaxSettings | undefined'.
23 | protected basePath = 'http://localhost';
24 | public defaultHeaders: Array<string> = [];
> 25 | public defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings = null;
| ^
26 | public configuration: Configuration = new Configuration();
27 |
28 | constructor(basePath?: string, configuration?: Configuration, defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings) {
ERROR in /home/me/code/g2/frontend/fe_main/src/api/ms-authentication/api/PasswordApi.ts
25:12 Type 'null' is not assignable to type 'JQueryAjaxSettings | undefined'.
23 | protected basePath = 'http://localhost';
24 | public defaultHeaders: Array<string> = [];
> 25 | public defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings = null;
| ^
26 | public configuration: Configuration = new Configuration();
27 |
28 | constructor(basePath?: string, configuration?: Configuration, defaultExtraJQueryAjaxSettings?: JQueryAjaxSettings) {

但我无法在不修改代码生成模板的情况下更改此代码。 :/

最佳答案

您应该修改生成的代码或禁用 typescript 编译器选项的 strictNullChecks

关于typescript - vue-cli 服务忽略目录上的 typescript 类型错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55769984/

69 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com