简体   繁体   English

为单个文件禁用 TypeScript Inline

[英]Disable TypeScript Inline for an individual file

I have TS running with errors that I would like to ignore, compile, but when using我有 TS 运行时出现错误,我想忽略、编译,但在使用时

/* tslint:disable */

it still runs when running my build.运行我的构建时它仍然运行。

hutber@hutber:/var/www/bp/frontend$ git commit -m"feat: add basic foundations for theme & breadcrums"
husky > pre-commit (node v14.14.0)
$ tsc
components/Layouts/Breadcrums/index.tsx:17:13 - error TS2322: Type 'string' is not assignable to type 'HTMLCollection'.

17             {a}
               ~~~

In your tslint.json , you could try excluding the file:在您的tslint.json ,您可以尝试排除该文件:

{
  "extends": "tslint:latest",
  "linterOptions": {
      "exclude": [
          "bin",
          "<path to your excluded file here>"
      ]
  }
}

or adding your file to .eslintignore , if you have that instead.或者将您的文件添加到.eslintignore ,如果您有的话。

I think TSLint is deprecated and one needs to use eg // eslint-disable-next-line @typescript-eslint/<type of error> .我认为 TSLint 已被弃用,需要使用例如// eslint-disable-next-line @typescript-eslint/<type of error> However, I'm not fully aware of your configuration, so this might need to fine tuning.但是,我并不完全了解您的配置,因此这可能需要进行微调。

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

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