Subscribe on changes!

Possibly wrong argument type for `createElementBlock`

avatar
Aug 19th 2021

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...

avatar
Aug 19th 2021

Hello, thank you for taking time filling this issue!

However, we kindly ask you to use our Issue Helper when creating new issues, in order to ensure every issue provides the necessary information for us to investigate. This explains why your issue has been automatically closed by me (your robot friend!).

I hope to see your helper-created issue very soon!

avatar
Aug 19th 2021

I'm having the same issue and could provide a minimal example if needed.

avatar
Aug 19th 2021