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

时间:2019-04-20 03:27:28

标签: typescript vue.js vue-cli

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

  • 我用https://cli.vuejs.org推出了一个新应用
  • 我通过代码生成src/api/
  • 生成了jQuery / typescript 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) {

但是我不能在不修改codegen模板的情况下更改此代码:/

1 个答案:

答案 0 :(得分:0)

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

相关问题