Update TypeScript 3.7
See original GitHub issueInfo
- Platform: macOS
- Vetur version: 0.22.6
- VS Code version: 1.40.1
Problem
Can’t use optional chaining, e.g. a.b?.c
Messages:
Expression expected. Vetur(1109)
':' expected. Vetur(1005)
Reproducible Case
Type this code:
const a = {}
console.log(a.b?.c)
Cause, Workaround and Fix
The cause of this problem is the version of Typescript included in Vetur.
There is a workaround by including typescript in your own project and then setting the useWorkspaceDependencies
to true in your VSCode settings, as noted in bug report #1503
This workaround is not suitable for general use because:
- The issue is of a severity where it causes the program to not compile and there is no way to tell Vetur to ignore the next line or anything like that.
- It requires every individual project to have typescript installed to be able to use this language feature
- Vetur should work out of the box with the latest language features, so while this is new and not completely ratified, it is already included in the most common browser, Chrome 79+, and there is a readily available polyfill for other browsers. It is also already fully supported in VSCode, so this is the only impediment to using it.
I would therefore ask that rather than just closing the issue because there is a workaround, that you put it on the todo list to implement the fix.
The fix is to upgrade the version of typescript included in Vetur to 3.7+
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:5 (2 by maintainers)
Top Results From Across the Web
How to update TypeScript to latest version with npm?
Open Cmd and do 'where tsc' , which shows the list of typescripts in the path then you can manually delete the typescript...
Read more >Announcing TypeScript 3.7 - Microsoft Developer Blogs
We're thrilled to announce the release of TypeScript 3.7, a release packed with awesome new language, compiler, and tooling features.
Read more >How to set up TypeScript
To do this, run npm install -g typescript . This will install the latest version (currently 4.9). An alternative is to use npx...
Read more >3.7.5 - typescript - npm
TypeScript is a language for application scale JavaScript development. Latest version: 4.9.4, last published: 17 days ago.
Read more >TypeScript 3.7 quick release overview in Angular context
1.Change your package.json by updating/installing 3.7 version: npm update typescript@3.7 — save-dev · 2. Then update tsconfig.json by adding ...
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
We’ll activate Dependabot for this repo so that we can release it with the latest TypeScript as soon as we can.
@LinusBorg It comes with its own language server which includes typescript (https://github.com/vuejs/vetur/blob/master/server/package.json), but you can tell it to use the workspace version using
useWorkspaceDependencies
. Unfortunately, what it thinks of as the workspace version is explicitly loaded from the node_modules in your project (see src/services/dependencyService.ts:70) so it doesn’t matter what version is included in VSCode and also doesn’t pick up a global install of typescript. Therefore the only workaround at the moment is to enable the workspace dependencies setting in VSCode and also to include the typescript library in each project.