Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Expression expected.ts(1109) after TypeScript upgrade to 3.7.2

I upgraded TypeScript to 3.7.2 from 3.6.x. And write code using optional chaining. But get strange error

Expression expected.ts(1109)

in (vim, VSCode) IDE, even when build was successful.

enter image description here

like image 333
Edgaras Karka Avatar asked Nov 12 '19 14:11

Edgaras Karka


3 Answers

Click the version in the bottom right of VS Code.

TS Version

A dropdown will appear at the top with a few options such as "Use VS Code's Version" and "Use Workspace Version".

Select "Use Workspace Version" which will select the version of typescript that tsc is using, typically installed in your devDependencies.

This will automatically add a line to your Workspace Configuration File that looks something like the following:

{
   "typescript.tsdk": "node_modules/typescript/lib"
}
like image 193
styfle Avatar answered Oct 12 '22 00:10

styfle


It could be that your editor isn't using TypeScript 3.7 yet - see if there are options for using the TypeScript version in the TSServer from from your node_modules.

like image 24
orta Avatar answered Oct 12 '22 02:10

orta


You can start using TypeScript 3.7 features in VS Code today by installing the JavaScript and TypeScript Nightly extension.

like image 30
laogui Avatar answered Oct 12 '22 02:10

laogui