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

types(runtime-core): fix types of createElementBlock and createBlock #4411

Closed
wants to merge 1 commit into from

Conversation

SebastianSpeitel
Copy link

@SebastianSpeitel SebastianSpeitel commented Aug 21, 2021

fix: #4391
supersedes: #4406

This aligns the arguments of createElementBlock and createBlock closer to the ones of the underlying createBaseVNode and createVNode.

packages/runtime-core/src/helpers/renderSlot.ts had to be changed since the type of props.key had to be string | number | symbol | undefined instead of unknown.

I already tested it with my fail case (#4391) and it fixes the issue.

type: string,
props?: Record<string, any> | null,
children?: any,
type: VNodeTypes | ClassComponent | typeof NULL_DYNAMIC_COMPONENT,
Copy link
Member

Choose a reason for hiding this comment

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

Strictly speaking, the type cannot be a component type.

Copy link
Author

Choose a reason for hiding this comment

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

Why is that and why isn't that reflected in createBaseVNode?

Copy link
Member

Choose a reason for hiding this comment

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

createElementBlock will only be generated in callsites where the argument is either a plain element or a fragment. This is defined by how it is generated by the compiler.

@yyx990803 yyx990803 closed this Aug 23, 2021
@yyx990803
Copy link
Member

These functions are only used in compiler-generated code so their type checking should be lax.

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.

Type misdeclaration when using <script setup>
3 participants