Deno: VS Code typescript doesnt know ES6

729 views Asked by At

I am building an app with deno and typescript. As my IDE I'm using VS Code.

When I'm trying to use modern javascript syntax like await and flatMap VS Code underlines these statements in red and shows errors like:

Property 'flatMap' does not exist on type 'any[]'. ts(2339)

or

Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher. ts(1378)

but also when trying to import deno libraries:

Cannot find module 'https://deno.land/std/fs/mod' or its corresponding type declarations.ts(2307)

How do I fix these errors? Where do they come from?

I do not have any typescript extension installed but I have the official Deno extension by denoland.

1

There are 1 answers

0
IceRevenge On

Thanks to Jared Smith and this post I was able to fix the problems.

I added a tsconfig.json to the root directory of my folder and added this to it:

{
  "compilerOptions": {
    "module": "ESNext",
    "target": "ES2020"
  }
}