javascript - 禁用单个文件的 TypeScript Inline

标签 javascript typescript

我的 TS 运行时出现错误,我想忽略这些错误,进行编译,但是在使用时

/* tslint:disable */

运行我的构建时它仍然运行。

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}
               ~~~

最佳答案

在您的 tslint.json 中,您可以尝试排除该文件:

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

或者将您的文件添加到 .eslintignore(如果您有的话)。

关于javascript - 禁用单个文件的 TypeScript Inline,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64663635/

相关文章:

javascript - React Navigation - 如何嵌套组件将堆栈导航器包装在选项卡导航器中

javascript - 为什么 Babylon 将 .manifest 扩展名添加到可加载模型中?

javascript - 从Excel中检索数据并显示在页面中

typescript - Typescript 的 Jest 测试显示错误的错误行

angular - 单击按钮打开 url 但来自 ts 函数

javascript - window.onload 未在页面刷新时运行

javascript - 如何在 webstorm 中使用 GIT

typescript - TypeScript 支持 TouchEvent 吗?

typescript - 如何在 Typescript 中切换 boolean 值?

javascript - RxJS 在浏览器中缺少运算符错误,但在 Visual Studio Code 中却没有