Skip to content

Possibly wrong argument type for createElementBlock #4390

Closed
@pfumagalli

Description

@pfumagalli

https://github.com/vuejs/vue-next/blob/6db15a27cf0040f95b21ccfff86799c021231efc/packages/runtime-core/src/vnode.ts#L289

The definition for createElementBlock reads:

export function createElementBlock(
  type: string,
  props?: Record<string, any> | null,
  children?: any,
  patchFlag?: number,
  dynamicProps?: string[],
  shapeFlag?: number
) { /* ... */ }

However while playing around with compiler-sfc I noticed that when a component has more than one root element (within the <template/> definition the function is passed the Fragment as a type.

Then (obviously) when running TSC over the generated render function, I get a TS2345 error Argument of type '{ new (): { $props: VNodeProps; }; __isFragment: true; }' is not assignable to parameter of type 'string'.

This seems to be also reflected in the tests (e.g. see https://github.com/vuejs/vue-next/blob/ceff89905b05381d3d73c480e08c7aff9271b074/packages/compiler-core/__tests__/__snapshots__/compile.spec.ts.snap#L17) so I don't know why it doesn't seem to be caught.

I assume the correct type for the type parameter should be VNodeTypes ???

@HcySunYang this was in your #3334...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions