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

fix(compiler-sfc): support keyof for intersection types #11132

Merged
merged 3 commits into from
Jun 14, 2024

Conversation

lzl0304
Copy link
Contributor

@lzl0304 lzl0304 commented Jun 14, 2024

fixes #11129

@@ -1688,7 +1688,7 @@ export function inferRuntimeType(
case 'TSUnionType':
return flattenTypes(ctx, node.types, scope)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this also apply to UnionTypes?

Copy link
Contributor Author

@lzl0304 lzl0304 Jun 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I've also encountered an issue with union types during testing(keyof A):

  • When type A = 'a' | 'b', resolveType correctly returns ['String'].
  • When type A = number | string, resolveType returns ['Number', 'String'], but in TypeScript, the type of A should be "toString" | "valueOf".

Given this, I believe this might be another issue, and simply adding a parameter might not fix it. Do you think fixing this issue is necessary? If necessary, I'll try to address it.

@yyx990803 yyx990803 merged commit 495263a into vuejs:main Jun 14, 2024
11 checks passed
@lzl0304 lzl0304 deleted the fix-11129 branch June 14, 2024 09:19
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

Successfully merging this pull request may close these issues.

Invalid prop: type check failed, Expected Object when using keyof on type intersection
2 participants