【问题标题】:tslint:disable not working in vscodetslint:禁用在 vscode 中不起作用
【发布时间】:2018-12-01 01:58:38
【问题描述】:

无法导入类型声明文件。考虑导入“googlemaps”而不是“@ types / googlemaps”。

我有默认选项,但这对我不起作用。

【问题讨论】:

  • 您确定这是tslint 错误消息而不是ts 消息吗? (当你将鼠标悬停在它上面时)
  • 文件“@types/googlemaps/index.d.ts”不是模块。错误来自 ts
  • 那么你需要修复这个错误。 tslint:disable 只会禁用与 tslint 相关的错误实际的 ts 错误。

标签: visual-studio-code tslint


【解决方案1】:

除了与 linter 无关外,正如评论的那样,issue 16472 补充说:

在绝大多数情况下,从以 @types 开头的模块说明符导入是一个错误,会导致运行时错误。

例如见tinganho/express-request-language PR 13:

使用较新版本的 TypeScript => 2.4.1 会出现指出的错误。
直接导入类型是错误的,应该导入使用类型的包。

-import * as e from '@types/express';
+import * as e from 'express';

另见“Deprecation Notice: Regarding TypeScript@2.0”。

【讨论】:

    猜你喜欢
    • 2018-11-22
    • 2020-06-15
    • 2019-11-15
    • 2017-10-30
    • 2018-09-21
    • 2019-06-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多