Vetur: how can i use optionalChaining?

Created on 22 Sep 2019  路  18Comments  路  Source: vuejs/vetur

let b = a?.b?.c?.s

question

Most helpful comment

Not using TypeScript but Intellisense is broken to me as well.
Code_affuFhouZ7

All 18 comments

For JavaScript: the Babel plugin

For TypeScript: Soon! November 5th!

The issue
TS 3.7, target release of 11/5/19

Also, this can probably be closed as an issue not particularly specific to Vetur

I've used the Babel plugin, but the vscode shows the Expression expected.Vetur(1109). How to configure vetur ?

TS 3.7, target release of 11/5/19

Vetur is based on vue-language-server. the vue-language-server is current loading bundled [email protected].

so you have to wait for the vue-language-server to upgrade this version to 3.7

As answered by others, you'll need to wait TS 3.7. After which you can install locally to your workspace and use vetur.useWorkspaceDependencies to use it.

It's time.

@octref Please reopen this issue ,

As answered by others, you'll need to wait TS 3.7. After which you can install locally to your workspace and use vetur.useWorkspaceDependencies to use it.

This answer not working !

TS 3.7 might break other functionalities of Vetur, so I can't just upgrade.
You can now use vetur.useWorkspaceDependencies with locally installed TS. The point of that setting is you don't have to wait for Vetur to update its TS dependencies for using a newer version.

Yup, can confirm that useWorkspaceDependencies is working great for us for optional chaining, having TS 3.7 installed for the repo :+1: Love it!

Is it intended not to work within template tags? Or does typescript only work within script tags?

Using TypeScript 3.7 breaks intellisense for me.

Should we reopen? Seems like vetur is not compatible with TS 3.7 fully

Using TypeScript 3.7 breaks intellisense for me.

What exactly is broken for you?

Not using TypeScript but Intellisense is broken to me as well.
Code_affuFhouZ7

Well, if you're not using TypeScript, then it's a separate issue, I think. useWorkspaceDependencies just allows you to use the TS that is in your package.json rather than the bundled one

Is there any reason why vetur.useWorkspaceDependencies cannot be set in the workspace but only in the user settings?

For those that have multiple projects in their VS workspace.

This seems to be the problem for me, I hope that points some of you in the right direction.

I have found two solutions for now:

  1. init a package.json in the root workspace folder, install typescript there and reopen the workspace. Creating a node_modules folder here just to workaround this Vetur warning makes me feel a little sick so I have to resort to...
  2. Open the the project folder as a visual studio workspace. This works fine, although not exactly how I want to work.

I'm hoping someone knows how to fix this and can help me?

Ideally I want a way to get Vetur to detect the deepest dependencies and then work from there. I assume this is how Visual Studio itself works, maybe there is a way I can get Vetur to do the same?

What is required to get this working within template tags? Is that an issue with eslint-plugin-vue which is used to validate templates?

Was this page helpful?
0 / 5 - 0 ratings