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

v-for does not infer actual key/value types of generic prop #11076

Open
pimlie opened this issue Jun 5, 2024 · 2 comments
Open

v-for does not infer actual key/value types of generic prop #11076

pimlie opened this issue Jun 5, 2024 · 2 comments

Comments

@pimlie
Copy link

pimlie commented Jun 5, 2024

Vue version

3.5.0-alpha.2

Link to minimal reproduction

https://play.vuejs.org/#eNp9U11v2jAU/St3eQlIEKp1e2EUba06aXtYq5W3ppoC3FCXxI5sh9Gy/Pcd24Gmny+JfT/PPT53F32rqmRTczSOJmahRWWpyOTqJI2sSSMybOtqmkoiUVZKW9qR5pwayrUqKUZi3HGeqbIaIMTeV4xLUZfyTMlcrPYJaZSMXJDrmEZfUumSiRZKGotvJ+GEdsGXKzVGySKbczGm+LtSMTWD4Jtnuus7zXTX9/DU97D3NWQyK0wu2DwBGdB0sAPEmu9V7m34dQG60C5sxIKYSUic9vqpnIwCn2APF8tlVWSWPZeTaopAwNvts5tmMgo8o0RZuVp4ggWOeIQxGqGlN3QQRPQVd1h7+PXpZEruELA4CwJGKDkZdXpHA7xrKJfcGSXx7J7n0EsUrC8qKzBXGgFeYDKNsqJQf396m9U1twwj55YX61fsd2brbGl0qdmw3uCtDz6b6RXb4D6/+sVbnA/OUi3rAtHvOH+zwZAOYwg7reUSsDtxHu0Pr0ghVzNzvrUszX4oB9SrwMenEZToGH9r9Ee4x8knn5fKBizuVfz63oBp3vqVeLkKUDZdr0lIMlYD4E1HpsEChaLLU/28tZu0YslaLGCcEfhiuXymageGaMm5kHypVWUm7XBBBmOa+bGg2XYfg6y5FBZYQ945Loe8HmOfILB44GQ2bndk1h/TRonlvphH/c4KfBgOaXZFrLXSpKQr5ThxbQHJsRa3bPwjWZdz1jiY+3KOxiQMSWUpM0asZDYvmKwKVMctmjih4TB0mtfWosFmmCsdtkXmHnrfNQws+GUqxGKNAAeh9zgg9mjqyfDbKvPEv5Xf2FC57aLdsrWDSfU42zMYr7a5mN/xwibAbjw8sepfH90cOudCG9tp93yl/2xYO4FDjMfJ5+RomBXVbZZ8jJr/rDbySw==

Steps to reproduce

See the html comments in the template of the Comp.vue component

What is expected?

That v-for="(value, key) in obj" infers the actual type of key and value

What is actually happening?

It infers the generic key type string | number | symbol for objects. Also note that when calling Object.keys(config)[0] the correct type is inferred

image

System Info

No response

Any additional comments?

This issue doesn't seem to be related to #9059

Workaround is to assert the type of the object in the v-for explicitly (this messes up syntax highlighting though):
image

@Hiws
Copy link

Hiws commented Jun 6, 2024

Probably related to #8144

Workaround can be to use const props = defineProps({ ... }) and then use props.config in the template to get the correct type.

There's also vuejs/language-tools#3820 and #10801 but based on that it should've been fixed in 3.5.0-alpha.1

@davidmatter
Copy link
Contributor

Might be related to

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

3 participants