Throwing Error on Optional Chaining (TS 3.7.2)
See original GitHub issueSummary
Prettier VSCode plugin is failing on new TypeScript in version 3.7.2 syntax (specifically optional chaining). Prettier 1.19.1 was release on 11/8/2019 adding support https://github.com/prettier/prettier/issues/6469
Steps To Reproduce:
- Add optional chaining syntax
x?.y
to a TS file - Attempt to auto-format the TS file
- Check the
Output
window of VSCode, and there will be an error ofExpression expected
pointing to the?.
- Auto-format fails
Expected result
No error should be thrown, and auto-format should succeed
Actual result
See steps to reproduce
VS Code Version: 1.40.0
Prettier & Prettier Plugin Version: 1.19.1 and 2.3.0 respectively
OS and version: macOS 10.14.6
Issue Analytics
- State:
- Created 4 years ago
- Reactions:15
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Documentation - TypeScript 3.7
At its core, optional chaining lets us write code where TypeScript can immediately ... There's a specific set of functions that throw an...
Read more >Typescript optional chaining error: Expression expected.ts(1109)
Try ⌘ + Shift + p and choosing Select TypeScript Version . If it's not 3.7+, that's the issue. The easiest fix is...
Read more >Optional chaining (?.) - JavaScript - MDN Web Docs - Mozilla
If the object accessed or function called is undefined or null , it returns undefined instead of throwing an error. Try it.
Read more >What is wrong with optional chaining and how to fix it - DEV ...
Optional chaining simplifies above and removes a lot of errors by saying that values considered as no value are only two - null...
Read more >Optional chaining '?.' - The Modern JavaScript Tutorial
innerHTML property of null . And in some cases, when the absence of the element is normal, we'd like to avoid the error...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
VSCode is still on 3.6.x, you need to force it to use the locally installed typescript in node_modules (to 3.7.2), see https://code.visualstudio.com/docs/typescript/typescript-compiling#_using-newer-typescript-versions
Version 3.0 is now released to the normal extension location.