test-utils icon indicating copy to clipboard operation
test-utils copied to clipboard

Bug: Unable to pass props of a unioned type to `mount` since 2.4.2

Open ascott18 opened this issue 1 year ago • 1 comments

Describe the bug

Starting in 2.4.2 (works in 2.4.1), when passing props to mount whose type is a union, a type error is raised.

Type '{ foo: string; } | { foo: { bar: string; }; }' is not assignable to type 'VNodeProps & { __v_isVNode?: never; [Symbol.iterator]?: never; } & Record<string, any> & { foo: string; }'.
  Type '{ foo: { bar: string; }; }' is not assignable to type 'VNodeProps & { __v_isVNode?: never; [Symbol.iterator]?: never; } & Record<string, any> & { foo: string; }'.
    Type '{ foo: { bar: string; }; }' is not assignable to type '{ foo: string; }'.
      Types of property 'foo' are incompatible.
        Type '{ bar: string; }' is not assignable to type 'string'.(2322)

To Reproduce https://stackblitz.com/edit/github-wh8w7t?file=src%2Fcomponents%2F__tests__%2FHelloWorld.spec.ts

Expected behavior A type error is not raised, as is the case in 2.4.1 and below.

Same repro with 2.4.1: https://stackblitz.com/edit/github-wh8w7t-gbvna2?file=src%2Fcomponents%2F__tests__%2FHelloWorld.spec.ts

Related information:

  System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  npmPackages:
    @vue/test-utils: ^2.4.3 => 2.4.3 
    vitest: ^1.0.4 => 1.1.1 
    vue: ^3.3.11 => 3.4.4 

Additional context

ascott18 avatar Jan 03 '24 16:01 ascott18

Hi @ascott18 , thanks for the repro

We have a WIP PR from @pikax that will probably help with this issue. Watch #2242 if you're interested

cexbrayat avatar Jan 03 '24 19:01 cexbrayat