Skip to content
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

Class string color scopes incorrect when v-model contains TS "as" cast #520

Closed
qgates opened this issue Sep 23, 2021 · 9 comments
Closed
Labels

Comments

@qgates
Copy link

qgates commented Sep 23, 2021

Example:

<textarea
  v-model="var as string"
  class="fld-module h-full resize-none">
...

Class string is assigned incorrect scopes meta.namespace.declaration.ts and source.ts.embedded.html.vue etc..

The order of attributes seems to make no difference. Workarounds:

  • bracket the entire v-model expression eg. v-model="(var as string)"
  • use angle bracket casting instead, eg. v-model="<string>var"

How it appears (using tomorrow night theme):

image

How it should appear:

image

@johnsoncodehk
Copy link
Member

This problem similar to #112, it's embed language syntax issue, we can't fix, you need to use () to catch it.

@qgates
Copy link
Author

qgates commented Sep 24, 2021

@johnsoncodehk which upstream package is responsible for this issue?

@johnsoncodehk
Copy link
Member

@mesqueeb
Copy link
Contributor

mesqueeb commented Jan 9, 2022

@johnsoncodehk adding round parentheses fixes it. It might be interesting for volar to auto-add those inside templates.

Should I open a FR for this?

@johnsoncodehk
Copy link
Member

@mesqueeb you can open a FR, but there is not necessarily a way to do it.

@douira
Copy link

douira commented Aug 27, 2023

What issue in https://github.com/microsoft/TypeScript-TmLanguage is the upstream issue for this? It doesn't make sense to have this closed without notifying the upstream repo to fix it.

@Mettbrot
Copy link

Marking any issue as duplicate of this one yet closing it without a proper path to get it fixed is kind of frustrating. How can we further track this issue, maybe over at microsoft/TypeScript-TmLanguage ?

@matthew-dean
Copy link

What issue in https://github.com/microsoft/TypeScript-TmLanguage is the upstream issue for this? It doesn't make sense to have this closed without notifying the upstream repo to fix it.

I think saying this is an upstream issue without pointing to the issue is a little dismissive / frustrating. I don't see, for example, how this can be purely an upstream issue when HTML languages don't have expressions like Vue has. It seems more likely (or at least possible?) that Vue is possibly identifying bound values as the wrong type of expression?

That is, if we assume:

  • VSCode colors TypeScript correctly, and
  • VSCode colors TSX correctly, and
  • VSCode colors HTML correctly, then:
  • How Vue's language tools are plugging into those services is probably incorrect. Even if Vue's coloring works 99% of the time doesn't mean that it's done correctly

If you aren't tracking an issue with Microsoft that has asked them for feedback, can you really prove otherwise? This feels like kicking the can down the road.

@johnsoncodehk
Copy link
Member

@matthew-dean Even in .ts files, problems can occur when writing syntax equivalent to the original topic.

image

This is the code where we embed the ts syntax, you can try investigating:

I don't think upstream has a chance to fix it, it's more like a design limitation of the embedded language syntax highlight.

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

No branches or pull requests

6 participants