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

Vue 2 errors accessing scoped properties in slots #1355

Closed
jaredmcateer opened this issue May 26, 2022 · 2 comments
Closed

Vue 2 errors accessing scoped properties in slots #1355

jaredmcateer opened this issue May 26, 2022 · 2 comments

Comments

@jaredmcateer
Copy link

Minimal Test Case

https://github.com/jaredmcateer/vue2-volar-type-error

Explanation

  <SlotComponent>
    <template v-slot="props"><span>{{ props.value }}</span> </template>
    <template #oneThing="props"><span>{{ props.value }}</span> </template>
  </SlotComponent>

Trying to access scope properties of a slot in Vue 2 results in an error Property 'value' does not exist on type 'VNode[]'... ts(2551)

in #439 the workaround appears to be to assert the scoped property to a type (#oneThing="props as MyProp") but in Vue 2 trying to do that will result in an Unexpected token error at compile time.

@jaredmcateer jaredmcateer changed the title Vue 2 errors accessing scoped properties Vue 2 errors accessing scoped properties in slots May 26, 2022
@hexf00
Copy link

hexf00 commented May 27, 2022

see #1354 (comment)

and you need read document chapter "Setup for Vue 2", add package and config

https://github.com/johnsoncodehk/volar/tree/master/extensions/vscode-vue-language-features

@jaredmcateer
Copy link
Author

jaredmcateer commented May 27, 2022

I've read the documentation and followed it as best I can, I noticed I missed the vueCompilerOptions section (in my test repo) and I added it but it made no difference, do you think I've missed something in my test repo?

Edit: after reloading vscode it appears the missing vueCompilerOptions in tsconfig was the actual problem.

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

No branches or pull requests

2 participants