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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/runtime-core/src/helpers/renderSlot.ts
Expand Up @@ -14,7 +14,7 @@ import {
} from '../vnode'
import { PatchFlags, SlotFlags } from '@vue/shared'
import { warn } from '../warning'
import { createVNode } from '@vue/runtime-core'
import { createVNode, VNodeProps } from '@vue/runtime-core'

/**
* Compiler runtime helper for rendering `<slot/>`
Expand All @@ -23,7 +23,7 @@ import { createVNode } from '@vue/runtime-core'
export function renderSlot(
slots: Slots,
name: string,
props: Data = {},
props: Data & VNodeProps = {},
// this is not a user-facing function, so the fallback is always generated by
// the compiler and guaranteed to be a function returning an array
fallback?: () => VNodeArrayChildren,
Expand Down
18 changes: 9 additions & 9 deletions packages/runtime-core/src/vnode.ts
Expand Up @@ -286,12 +286,12 @@ function setupBlock(vnode: VNode) {
* @private
*/
export function createElementBlock(
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.

props?: (Data & VNodeProps) | null,
children?: unknown,
patchFlag?: number,
dynamicProps?: string[],
shapeFlag?: number
dynamicProps?: string[] | null,
shapeFlag?: number | ShapeFlags
) {
return setupBlock(
createBaseVNode(
Expand All @@ -314,11 +314,11 @@ export function createElementBlock(
* @private
*/
export function createBlock(
type: VNodeTypes | ClassComponent,
props?: Record<string, any> | null,
children?: any,
type: VNodeTypes | ClassComponent | typeof NULL_DYNAMIC_COMPONENT,
props?: (Data & VNodeProps) | null,
children?: unknown,
patchFlag?: number,
dynamicProps?: string[]
dynamicProps?: string[] | null
): VNode {
return setupBlock(
createVNode(
Expand Down