【问题标题】:Visual Studio Code TS Intellisense for JS Event, File types用于 JS 事件、文件类型的 Visual Studio Code TS Intellisense
【发布时间】:2017-07-23 20:42:58
【问题描述】:

当尝试做类似的事情时,

onDragOver(event: Event): void

在 VS Code 中,intellisense 会抛出以下错误:

[ts] 找不到名称“事件”。

当我尝试做类似的事情时也会发生同样的情况,

let file: File = new File()

[ts] 找不到名称“文件”。

我将如何消除 VS Code 中的这些错误?我对 TS 和 VS Code 还很陌生,所以我缺少一些类型声明吗?

【问题讨论】:

  • 在您的 tsconfig.json 中缺少 lib:["dom"]

标签: typescript visual-studio-code javascript-intellisense


【解决方案1】:

在为浏览器编写代码时,将"dom" 添加到lib 数组中的tsconfig.json

例如:

// tsconfig.json
{
  "compilerOptions": {
    ...
    "lib": [
      "dom",
      ...
    ]
  }
}

【讨论】:

    猜你喜欢
    • 2017-05-10
    • 2017-03-31
    • 2018-07-29
    • 2019-07-17
    • 1970-01-01
    • 2017-10-28
    • 2016-07-14
    • 1970-01-01
    • 2018-02-03
    相关资源
    最近更新 更多