wheatjs / vite-plugin-vue-type-imports

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

Cannot use namespace 'xxx' as a type.ts(2709) #18

Closed wangrongding closed 2 years ago

wangrongding commented 2 years ago

Hi, I'm having this problem, it doesn't seem to be caused by your plugin, but I don't know how to fix it, can you take a look?

Thanks~

Cannot use namespace 'xxx' as a type.ts(2709)

image

https://github.dev/wangrongding/vue-super-admin/blob/main/src/page/testing/test.vue#L6

Zolyn commented 2 years ago

It may be related to your typescript version, check if it is the latest version by runnning npm list.

wangrongding commented 2 years ago

I feel that it should not be a problem of version, see other people's version of typescript is much lower than my version did not appear this error

image

Documents with the error message: https://github.dev/wangrongding/vue-super-admin/blob/main/src/page/testing/test.vue#L6

My version of typescript: https://github.dev/wangrongding/vue-super-admin/blob/main/package.json#L69

Zolyn commented 2 years ago

I think you can try removing .ts

import type { Test } from './type'
Zolyn commented 2 years ago

Alternatively, you can do this if you want to preserve extensions:

// shims-vue.d.ts
declare module '*.ts' {
  export { Test } from '@/page/testing/type'
}

Also, I've noticed that you declare it in multiple files. (@/env.d.ts, @/types/shims-vue.d.ts) I think you should remove the redundant declaration.

wangrongding commented 2 years ago

Thanks, good brother. Have a great life.🥰