Skip to content

Update TypeScript 3.7 #1510

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
3 tasks done
goldengecko opened this issue Nov 20, 2019 · 5 comments
Closed
3 tasks done

Update TypeScript 3.7 #1510

goldengecko opened this issue Nov 20, 2019 · 5 comments

Comments

@goldengecko
Copy link

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

@LinusBorg
Copy link
Member

LinusBorg commented Nov 20, 2019

As far as im aware (and I'm not a VS Code extensions expert), Vetur does not bring its own version of typescript - it uses the one that comes with VSCode.

And since that's the version that all your normal .ts files will be run through by VSCode as well (unless you tell VSCode otherwise), this seems like a sensible default.

@goldengecko
Copy link
Author

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

@ktsn ktsn changed the title Please support optional chaining in Vetur Update TypeScript 3.7 Nov 21, 2019
@ktsn
Copy link
Member

ktsn commented 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.

@Niekvdm
Copy link

Niekvdm commented Nov 22, 2019

@ktsn That would be nice, as of now using useWorkspaceDependencies with TS 3.7.2 results in intellisense failures.

@kbirger
Copy link

kbirger commented Dec 11, 2019

@Niekvdm
Sorry, I made this comment on the other issue where you posted that. I didn't see that you posted here too.

So, to track things in one place: Can you clarify what is broken for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants