12

Vs code > OUTPUT > Prettier

2/23/2020, 12:10:36 PM:
-----------------------
Expression expected. (/Users/yanivper/dev/test/test.ts:2:23)
1 | function test(obj) {
2 |          return obj.a?.b;
                          ^

In a new project:

npm i typescript

VScode use Workstation Version 3.8.2 (shown in the left-bottom bar TypeScript 3.8.2 ) Prettier v 2.2.2

Kevin Friedheim
  • 394
  • 3
  • 15
Yaniv Peretz
  • 1,118
  • 2
  • 13
  • 22

1 Answers1

13

In my case I resolve by update prettier from 1.18.2 to 2.0.5.

If someone here is using JetBrains based IDE, please check your prettier settings in IDE, make sure the "Prettier package" is set to right path but not older version path in your global package.

Jie Wang
  • 620
  • 1
  • 10
  • 17
  • 1
    I started creating an issue myself just to post this answer. Turns out all that was needed was a `npm install -g prettier` to update to latest - which adds optional chaining support (https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#optional-chaining) – Kevin Friedheim Oct 14 '20 at 15:25
  • Additionally, I had to restart VSCode (reload window) after updating prettier. – Joe Sadoski Mar 13 '23 at 22:29