wheatjs / vite-plugin-vue-type-imports

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

CAN NOT import types from entry file with multiple exports levels #17

Closed gaokun closed 2 years ago

gaokun commented 2 years ago

The code below is not working:

Vue

import type { MsgProps } from './types' 

defineProps<MsgProps>()

types.ts

export * from './msg'

msg.ts

export interface MsgProps {
  msg: string;
}

I got:

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

If I import type { MsgProps } from './msg', it works ok.

Reproduce Repo

https://github.com/gaokun/vue3-ts-vite-type-imports

Zolyn commented 2 years ago

The following syntaxes are not supported currently:

  • import default
  • import { a as b }
  • export default
  • export * from

See Known limitations

This is a known issue, however, the documentation is currently not updated until #15 is merged.

Unfortunenately, this may take a while to fix because I'm not focusing on this project now.

gaokun commented 2 years ago

@Zolyn Many thanks for your extremely quick response. And thanks to your work anyway.

Zolyn commented 2 years ago

Supported in v0.2.2