Search code examples
typescriptvisual-studio-codecreate-react-app

Invalid typescript environment using vscode


I am writing React app (started from create react app) with vscode, I am also using eslint. Recently I started to integrate Typescript.
For some reason I have problems to write some Typescript expressions. For example:

interface Lengthwise {
    length: number;
}

function loggingIdentity<T extends Lengthwise>(arg: T): T {
    console.log(arg.length);  // Now we know it has a .length property, so no more error
    return arg;
}

This example is taken from typescriptlang.org page.
I got the following error: vscode error

Any idea what is wrong in my environment?


Solution

  • Eventually the issue was invalid parser in eslintrc.
    Changed parser from 'babel-eslint' to @typescript-eslint/parser and it's worked.