katyusha
katyusha

Reputation: 161

Visual Studio Code TS Intellisense for JS Event, File types

When trying to do something like,

onDragOver(event: Event): void

in VS Code, intellisense throws the following error:

[ts] Cannot find name 'Event'.

the same happens when I try to do something like,

let file: File = new File()

[ts] Cannot find name 'File'.

How would I go about removing these errors in VS Code? I'm fairly new to TS and VS Code, so is there some typings declaration that I'm missing?

Upvotes: 1

Views: 540

Answers (1)

unional
unional

Reputation: 15589

When you are writing code for browser, add "dom" to your lib array in your tsconfig.json.

For example:

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

Upvotes: 2

Related Questions