Skip to content

defineProps runtime props inference misses Array from MaybeRef<T[]> in union type after upgrading to Vue 3.5.31 #14729

@wuchunxu

Description

@wuchunxu

Vue version

3.5.31

Link to minimal reproduction

https://github.com/wuchunxu/vite-prop-runtime-repro

Steps to reproduce

After upgrading Vue from 3.5.21 to 3.5.31, runtime props inference from defineProps<T>() changed for a complex union type.

I have a prop type like this:

export type FormItemOptions<T = any, Context = any> =
  MaybeRef<OptionItem[]>
  | Promise<OptionItem[]>
  | ((row: T, context: Context) => Awaitable<OptionItem[]>)

In built output, Vue generates runtime prop type as:

options: {
  type: [Promise, Function],
  default: () => []
}

Array is missing, so passing an array value triggers runtime warning:

[Vue warn]: Invalid prop: type check failed for prop "options". Expected Promise | Function, got Array

If I explicitly add OptionItem[] in the union (instead of relying only on MaybeRef<OptionItem[]>), the generated runtime type includes Array and warning disappears.

What is expected?

Runtime props inference should include Array branch (or at least not narrow in a way that rejects valid array values from MaybeRef<OptionItem[]>).

For this case, expected generated runtime type should include:

type: [Array, Promise, Function]

What is actually happening?

Generated runtime type is:

type: [Promise, Function]

which rejects array values at runtime.

System Info

Any additional comments?

This looks like a boundary case in SFC type-to-runtime props inference for complex union types involving MaybeRef<T[]>.

If this should be tracked in another Vue package (e.g. compiler-sfc), please let me know and I can move the issue with the same repro.

Metadata

Metadata

Assignees

No one assigned

    Labels

    🔨 p3-minor-bugPriority 3: this fixes a bug, but is an edge case that only affects very specific usage.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions