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

v0.40.0 template type problems #1694

Closed
zigomir opened this issue Aug 10, 2022 · 6 comments
Closed

v0.40.0 template type problems #1694

zigomir opened this issue Aug 10, 2022 · 6 comments
Labels
bug Something isn't working

Comments

@zigomir
Copy link
Contributor

zigomir commented Aug 10, 2022

Hi,

Since upgrading to v0.40.0 some of my Vue component templates stopped detecting types, e.g. on hover where I see a type in v0.39.5 I don't see it anymore in v0.40.0.

I also see some of variables, for example computed property defined in script setup marked as not used, even though I'm using them in the template.

Sorry for being sparse with the details, I just am not sure what else than version number and behavior I could provide 😊

[edit] I also found out that when I run Volar: Verify All Scripts in v0.40.0 I got about 5 errors, but I get none in v0.39.5 and I'm almost certain that errors are false positives.

@zigomir zigomir changed the title v0.40.0 template breaks v0.40.0 template type problems Aug 10, 2022
@johnsoncodehk
Copy link
Member

johnsoncodehk commented Aug 10, 2022

I can't reproduce this problem in project in my hand, if you can add a test case to https://github.com/johnsoncodehk/volar/tree/master/packages/vue-test-workspace or provide minimal reproduction it will be helpful.

@jfrs
Copy link

jfrs commented Aug 10, 2022

I have the same issue, and every time the variable/function is used in a v-else block.

<script setup lang="ts">
  const thing = 42; // 'thing' is declared but its value is never read. ts(6133)
</script>

<template>
  <div v-if="true"></div>
  <div v-else>{{ thing }}</div>
</template>

@johnsoncodehk johnsoncodehk added bug Something isn't working and removed need info labels Aug 10, 2022
@danielwaltz
Copy link

Unfortunately I am still experiencing template type issues in a project using vue@2.7. I'm not sure if it's specific to 2.7 but both v0.40.1 and v0.40.0 lead to every component in my templates being of type any. Downgrading to v0.39.5 allows template types to work again.

Having to explicitly downgrade the version in vscode when these updates land with regressions is a little difficult to manage, especially when having to communicate the problem with multiple team members who all need to not only manually downgrade themselves to keep working effectively, but need to remember to upgrade again when it's fixed.

Shameless plug, but it would be really nice if volar used the version of vue-tsc found in your local repo/node_modules folder as described here. That way projects can opt in to newer versions when they are stable.

@danielwaltz
Copy link

Another clue - it appears this is only the case in components that are not yet using <script setup>. Template type checking is working with <script setup>, but is not working without it.

@johnsoncodehk
Copy link
Member

@danielwaltz just guessing it might be related to 412e985.

For vue 2.7 project, please make sure you have config target 2.7 not target 2 in tsconfig.

{
  "vueCompilerOptions": {
    "target": 2.7
  }
}

If still not working, you can also try setup experimentalImplicitWrapComponentOptionsWithVue2Extend to discharge 412e985.

{
  "vueCompilerOptions": {
    "target": 2.7,
    "experimentalImplicitWrapComponentOptionsWithVue2Extend": true
  }
}

Shameless plug, but it would be really nice if volar used the version of vue-tsc found in your local repo/node_modules folder as described here. That way projects can opt in to newer versions when they are stable.

Unfortunately it probably won't happen soon, @volar/vue-language-core API must be stable for it, but current is still moving fast.

This request may be more worth looking forward to: microsoft/vscode#138048

@danielwaltz
Copy link

The target in my tsconfig is indeed set to 2.7 already, but that is a really good thought!

I also just tested out enabling the experimentalImplicitWrapComponentOptionsWithVue2Extend option and unfortunately it still does not fix template type checking in components not using <script setup>.

Really appreciate the additional information on a version locking feature too, it's true that Microsoft supporting extension version locking in their workspace recommendations would also be an excellent solution. Understandable with the speed of iteration that now maybe wouldn't be the best time for that feature. Still hoping for it one day!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants