Home > Back-end >  flatMap still doesn't work in typescript even after target and lib set in tsconfig
flatMap still doesn't work in typescript even after target and lib set in tsconfig

Time:11-06

I've tried some bable settings, different target/lib settings in tsconfig, nothing. Not sure what else I can do...

The errors look like this where:

  let test:object[] = [{}];
  test.flatMap();

Property 'flatMap' does not exist on type 'object[]'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2019' or later.ts(2550)

& my tsconfig

{
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "es2020"
    ],
    "esModuleInterop": true,
    "jsx": "react",
    "module": "commonjs",
    "moduleResolution": "node",
    "noEmit": true,
    "noUnusedLocals": true,
    "outDir": "public",
    "resolveJsonModule": true,
    "rootDir": "src",
    "sourceMap": false,
    "strict": true,
    "strictNullChecks": true,
    "allowJs": true,
    "allowSyntheticDefaultImports": true,
    "skipLibCheck": true,
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules", "public"]
}

CodePudding user response:

Changes to tsconfig don't reflect in IDEs sometimes. Depending on your IDE, you should be able to find a way to restart the TypeScript server. If you can't find it, then you could just restart your IDE itself.

How to do it on VSCode: link

  • Related