React Native 0.56 now supports the Optional Chaining Operator with ?.
Unfortunately, the latest stable version of VS Code does not recognize this syntax and displays a TypeScript validation error:
[ts] Expression expected.
No compile-time or eslint errors are shown.
How can I resolve this issue?
Updated on 2019/12/11:
Optional chaining is officially supported by TypeScript version 3.7!
If you still encounter this error, it might be because the TypeScript library in your VSCode is below version 3.7.
You can easily fix this by installing a newer version of TypeScript (>= 3.7) as a dev dependency in your workspace (via npm or yarn).
Then, go to the command palette, type tstv
, and switch the TypeScript version used for JS and TS features from VS Code's Version to Workspace's Version (ensure it's >= 3.7) and you're all set!
This feature is truly amazing - thank you all and happy coding!