Typescript optional chaining error: Expression expected.ts(1109)

TypeScript 3.7 has been released, but the stable VS Code uses an older version.

Try + Shift + p and choosing Select TypeScript Version. If it’s not 3.7+, that’s the issue. The easiest fix is to install the ms-vscode.vscode-typescript-next extension. It’ll provide a nightly TypeScript version for VS Code to use (May require restarting VS Code FYI).

You’ll want to remember to remove the extension when VS Code gets TypeScript 3.7+ by default.

See https://code.visualstudio.com/docs/typescript/typescript-compiling#_using-newer-typescript-versions for more details.

Leave a Comment