Skip to content

Regression in prop type checking of imported type literal unions #13847

@dbohn

Description

@dbohn

Vue version

min. 3.5.19

Link to minimal reproduction

https://github.com/dbohn/vue-type-union-regression

Steps to reproduce

After checking out the reproduction repository, run

npm install
npm run build

Please note, that this issue persists up to the latest patch version. This can be checked by increasing the patch version in the package.json file and run the above steps again.

What is expected?

Up to Vue 3.5.18, the build succeeded without any issues, as right-end is a valid value of the imported Placement type.

What is actually happening?

Build fails with the following error:

error during build:
[vite:vue] [@vue/compiler-sfc] Default value of prop "placement" does not match declared type.

/.../vue-floating-default/src/components/HelloWorld.vue
3  |  import { ref } from 'vue'
4  |
5  |  const {placement = 'right-end'} = defineProps<{ msg: string, placement?: Placement }>()
   |                     ^^^^^^^^^^^
6  |
7  |  const validPlacement: Placement = 'right-end';

System Info

System:
    OS: Linux 6.6 Ubuntu 24.04.3 LTS 24.04.3 LTS (Noble Numbat)
    CPU: (22) x64 Intel(R) Core(TM) Ultra 7 155H
    Memory: 4.56 GB / 15.37 GB
    Container: Yes
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.14.0 - ~/.nvm/versions/node/v22.14.0/bin/node
    npm: 10.9.2 - ~/.nvm/versions/node/v22.14.0/bin/npm
  npmPackages:
    vue: 3.5.19 => 3.5.19

Any additional comments?

We have a set of components, that use floating-ui for positioning. We are using a similar placement parameter in these components to set the initial positioning of our floating component.
After updating to the latest patch version of Vue, we ran into these issues.
Interestingly, the vue-tsc invocation within the build command does not produce an error here.

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.regressionscope: sfc

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions