Skip to content

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

Closed

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.

Activity

  1. edison1105 commented on Apr 16, 2026

    @edison1105
    Member

    This issue should have existed all along — the compiler did not parse MayRef<T>, but skipCheck was added in the DEV.

    options: { type: [Promise, Function], required: false, skipCheck: true, default: () => [] }

    However, when the third-party library is bundled (in PROD), skipCheck is stripped out, which is why the warning appears when using it in the project.

  2. added
    🔨 p3-minor-bug
    on Apr 16, 2026
  3. aschoube commented on Apr 26, 2026

    @aschoube
    Contributor

    Hi! I've put up a fix in #14758 with it, your repro emits type: [Object, Array, Promise, Function] and the warning goes away.
    To understand the underlying cause, could you share your packages/app/tsconfig.json both package.json files, and the output of node -e "console.log(require.resolve('vue'))" run from packages/app/? I suspect vue's .d.ts isn't reachable from ui-lib's emitted types in your monorepo layout, and that'd be useful to confirm.

  4. wuchunxu commented on Apr 27, 2026

    @wuchunxu
    Author

    Hi! I've put up a fix in #14758 with it, your repro emits type: [Object, Array, Promise, Function] and the warning goes away. To understand the underlying cause, could you share your packages/app/tsconfig.json both package.json files, and the output of node -e "console.log(require.resolve('vue'))" run from packages/app/? I suspect vue's .d.ts isn't reachable from ui-lib's emitted types in your monorepo layout, and that'd be useful to confirm.

    Thanks! Here are the requested files from my repro monorepo.

    packages/app/tsconfig.json:

    {
      "extends": "../../tsconfig.base.json",
      "include": ["src/**/*.ts", "src/**/*.vue"]
    }

    packages/app/package.json

    {
      "name": "app",
      "private": true,
      "type": "module",
      "scripts": {
        "dev": "vite"
      },
      "dependencies": {
        "ui-lib": "workspace:*",
        "vue": "^3.5.31"
      },
      "devDependencies": {
        "@vitejs/plugin-vue": "^6.0.5",
        "typescript": "^5.6.3",
        "vite": "^8.0.8"
      }
    }

    packages/ui-lib/package.json:

    {
      "name": "ui-lib",
      "version": "0.0.0",
      "type": "module",
      "main": "dist/ui-lib.umd.cjs",
      "module": "dist/ui-lib.js",
      "exports": {
        ".": {
          "import": "./dist/ui-lib.js",
          "require": "./dist/ui-lib.umd.cjs"
        }
      },
      "scripts": {
        "build": "vite build"
      },
      "dependencies": {
        "vue": "^3.5.31"
      },
      "devDependencies": {
        "@vitejs/plugin-vue": "^6.0.5",
        "typescript": "^5.6.3",
        "vite": "^8.0.8"
      }
    }

    Output of running from packages/app/:

    node -e "console.log(require.resolve('vue'))"
    E:\repro\vite-prop-runtime-repro\node_modules\.pnpm\vue@3.5.32_typescript@5.9.3\node_modules\vue\index.js
    
  5. added a commit that references this issue on May 6, 2026
    7f46fd4
  6. locked and limited conversation to collaborators on May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    🔨 p3-minor-bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions