Subscribe on changes!

error using type union or intersection in defineProps

avatar
Apr 28th 2023

Vue version

3.2.47

Link to minimal reproduction

https://stackblitz.com/edit/vitejs-vite-1fkknn

Steps to reproduce

  1. Create a type union/intersection
  2. Use the type union/intersection in defineProps

What is expected?

defineProps allows type union/intersection

What is actually happening?

defineProps doesnt allow type union/intersection

[vite] Internal server error: [@vue/compiler-sfc] type argument passed to defineProps() must be a literal type, or a reference to an interface or literal type.

/home/projects/vitejs-vite-1fkknn/src/components/HelloWorld.vue
12 |  type HelloWorldProps = BaseProps & OtherProps;
13 |  
14 |  withDefaults(defineProps<HelloWorldProps>(), {
   |                           ^^^^^^^^^^^^^^^
15 |    msg: 'Hello World',
16 |  });

System Info

No response

Any additional comments?

No response

avatar
Apr 28th 2023

This is known and wont' be supported before 3.3 (currently in beta)