wheatjs / vite-plugin-vue-type-imports

Import types in Vue SFC for defineProps
223 stars 17 forks source link

type argument passed to defineProps() must be a literal type, or a reference to an interface or literal type. #30

Closed misogihagi closed 2 years ago

misogihagi commented 2 years ago

Related #25

Hello, thank you for your help before.

By the way, I found another problem.

I used export type props=Partial<{ msg: string }> instead of export type props={ msg: string } and the example problem occurred again.

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

/vitest-test/src/components/HelloWorld.vue 5 |
6 |
7 | defineProps() | ^^^^^ 8 |
9 |

Here is my repp.

Zolyn commented 2 years ago

image

These types are not supported.

See Known limitations

The plugin just simply extracts types from files, it does not do static analysis.

It's hard to do static analysis which behaves as same as TS due to my poor knowledge of TS's type system.

We will mark this issue as an enhancement. And we hope that we can find an efficient way to achieve this.

Zolyn commented 2 years ago

I added the duplicate label because there was already an identical problem. (#28 )

Zolyn commented 2 years ago

We temporarily close this issue as duplicate, you can keep an eye on #28