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

Type error in v-for on Object with key and value #12318

Open
Snack-X opened this issue Nov 4, 2024 · 0 comments · May be fixed by vuejs/language-tools#4981
Open

Type error in v-for on Object with key and value #12318

Snack-X opened this issue Nov 4, 2024 · 0 comments · May be fixed by vuejs/language-tools#4981
Labels
has workaround A workaround has been found to avoid the problem language-tools related to vue language-tools scope: types

Comments

@Snack-X
Copy link

Snack-X commented Nov 4, 2024

Vue version

3.5.12

Link to minimal reproduction

https://play.vuejs.org/#eNp9UctOwzAQ/JWVL1CppILCpUorAeoBDoCAG0YoTTdpWse2/AhFUf6dtaOUHlBvnt3Z2dlxy261ThqPbMZSh7UWmcMFlwCphuaiUGbOWZMJj2PY4Q9UEtRqy1mkALQtFEqdU2cEXTcLOJIJRI2JJmI6ORImaHNTaQcikyWJO8sZWHQ+UHMlrQsbSAo+SHYG1plKlp/DAzqYQxvEsxmcZUJvsrNxgCuCK3QR0XIuCy9zVykZHTbD/KgfNrTQSGgiN530lhZsTHbIQ1GVydYqSaFENme5qnUl0DzrIEmWyWAfAWeZEOr7MdacoaCGer7BfPdPfWv3ocbZi0GLpkHODj2XmRJd316+PeGe3odmrdZeEPtE8xWtEj547Gl3Xq7J9hEvun2otTKO4ni3y71DaYejgtHA7CKfvt7j/YnT/+xOk+s4R4FSil8NmqBJAU6Tm+TyinW/1cjLDA==

Steps to reproduce

Using v-for="value, key in someObject" on someObject: { [key: string]: string } produces type on key

What is expected?

Type of key should be string

What is actually happening?

Type of key is string | number

System Info

No response

Any additional comments?

According to the changelog, this should've been fixed in 3.4.28.

It feels like a regression of #8819, but changing the version of playground to 3.4.28 still has the same issue.

image

If I change the type of an object to Record<string, string>, the issue goes away.

image

@edison1105 edison1105 added scope: types has workaround A workaround has been found to avoid the problem language-tools related to vue language-tools labels Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has workaround A workaround has been found to avoid the problem language-tools related to vue language-tools scope: types
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants