question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Update TypeScript 3.7

See original GitHub issue
  • I have searched through existing issues
  • I have read through docs
  • I have read FAQ

Info

  • 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:

  1. 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.
  2. It requires every individual project to have typescript installed to be able to use this language feature
  3. 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:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

10reactions
ktsncommented, Nov 21, 2019

We’ll activate Dependabot for this repo so that we can release it with the latest TypeScript as soon as we can.

1reaction
goldengeckocommented, Nov 21, 2019

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found