5

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
  • 344
  • 3
  • 15
Yaniv Peretz
  • 734
  • 7
  • 21

2 Answers2

3

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
  • 352
  • 1
  • 4
  • 14
  • 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
0

it's not exactly clear what you're asking, but if prettier is throwing an error that you wish to avoid, you can add //prettier-ignore before the code.

more in the docs, here: https://prettier.io/docs/en/ignore.html

ultraGentle
  • 2,562
  • 1
  • 9
  • 23