-
-
Notifications
You must be signed in to change notification settings - Fork 408
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
TS2536 thrown when using a conditional type with keyof
for a generic type parameter
#4469
Comments
{{ item[itemLabel as keyof typeof item] }} |
@Shyam-Chen While this resolves the issue for |
To string. :key="`${item[itemKey as keyof typeof item]}`" |
@Shyam-Chen That does not preserve the type |
probably typescript 5.4 causing this |
maybe this is a workaround: playground, hope this helps :) |
Looks like a language tool issue? (transferred to language-tools, @johnsoncodehk let me know this should be fixed in core) |
I think this is a TypeScript limitation, which can be reproduced without Vue. See TS playground link. |
Vue version
3.4.21
Link to minimal reproduction
https://play.vuejs.org/#eNqVU02P0zAQ/SuDL12kfohlT1G7K0ArAV3BaqnEoalQm0yKdx07sp3SKuS/8+w0pQdUiZM9329m3jTiXVWNdzWLRExdZmXlybGvK1JrvZ2lwrtU3KZalpWxnh6k81RYU1IqxpMghdhUpHo66aLhC8FzWam1Z0hEUxWiEgmlQ8ZlI/OEbq6HKLFhldDgIytlhvTdWJW/GrSrVFBwHr3wAf4y7+XoD018oZwg/XRyVksMgTczupDb8bMzGk01AUEqMlNWUrH9WnlpNHpKKFqCbY3qvz5Hnbc1D3t99pOzl3/on90+6FLxaNmx3aH/k82v7ZZ9Z77/9oX3+J+MpclrBe8Lxid2RtUBY+f2vtY5YJ/5RbSf4jqk3i7c/d6zdn1TAWjwbKN/KrCdDxda/wv37fgmxqW6xRT7zV5iBW1Zs5UZxMU5Rxry5okLR23HlAHyDAIrsBjwoLKmcjSjnAup+TFI04gn8iOhxXLVS3M+nLAu5yQ1gRGmoMVqdBcc5yvCDFnnjpy3mAb9Jl2XG7b4uEO5MQofTDCWyumO5pSQ5h0GGnpd9un6gg8dIf+r5IWk7e3V677tputv2DfWfWJBDGp2nNlVnA6CLpwTDqpWx188LtqNCmPDpcAvQI6VsKDkeEAQl8eyuK1TKFHToYrGCGVFLRhwzDxRsi84iRXPbg0c+YGOA+/AEZBnfP1GtH8Ah39r4g==
Steps to reproduce
Create a component with a generic type parameter
T
and propx
for which the type is a conditional type used with thekeyof
operator to select some of the keys ofT
. Try to access keyx
for a value of typeT
in the template for the component.What is expected?
No type error is thrown and when the component is used in another component, only the keys of properties of the right type are allowed to be passed in for
x
.What is actually happening?
Type error
TS2536
is thrown.System Info
No response
Any additional comments?
No response
The text was updated successfully, but these errors were encountered: