Prettier-vscode: Throwing Error on Optional Chaining (TS 3.7.2)

Created on 11 Nov 2019  路  5Comments  路  Source: prettier/prettier-vscode

Summary

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:

  1. Add optional chaining syntax x?.y to a TS file
  2. Attempt to auto-format the TS file
  3. Check the Output window of VSCode, and there will be an error of Expression expected pointing to the ?.
  4. 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

locked

Most helpful comment

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

All 5 comments

https://github.com/prettier/prettier-vscode/pull/1025 related. Just saw this automated PR is out but failing

As a note, v3.1.0 of the plugin (which is in preview) does successfully work with TS v3.7.2

Version 3.0 is now released to the normal extension location.

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

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings