简体   繁体   English

vue-cli 服务忽略目录上的打字稿类型错误

[英]vue-cli service ignore typescript type errors on directory

How can I configure the vue-cli tool to not run type checks on a specific folder?如何配置 vue-cli 工具不对特定文件夹运行类型检查?

  • I spun up a new app with https://cli.vuejs.org我使用https://cli.vuejs.org启动了一个新应用程序
  • I generated a jQuery/TypeScript API directory via codegen: src/api/我通过 codegen 生成了一个 jQuery/TypeScript API 目录: src/api/
  • I ignored in the tslint file the "src/api/**/*.ts",我在 tslint 文件中忽略了"src/api/**/*.ts",

Try to build, but the cli tool is also checking for type errors.尝试构建,但 cli 工具也在检查类型错误。

The output of serve is:服务的输出是:

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) {

But I cannot change this code without modifying the codegen templates.但是我不能在不修改代码生成模板的情况下更改此代码。 :/ :/

You should either modify the generated code or disable the strictNullChecks of typescript compiler option.您应该修改生成的代码或禁用strictNullChecks编译器选项的 strictNullChecks。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM