Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

vue-cli@next脚手架中生成的shims-vue.d.ts文件,

declare module '*.vue' {
  import type { DefineComponent } from 'vue'
  const component: DefineComponent<{}, {}, any>
  export default component
}

这里的import type是什么意思?是将interface DefineComponent转换为type DefineComponent嘛?假如是这个意思的话,是什么意义呢?

-------------更新

image
使用import type 导致eslint 的 prettier报错请问怎么解决


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
3.2k views
Welcome To Ask or Share your Answers For Others

1 Answer

declare module '*.vue' {
  import type { DefineComponent } from 'vue' //import DefineComponent类型 
  const component: DefineComponent<{}, {}, any> //声明component为DefineComponent类型
  export default component;//默认导出变量
}
Importing Types
Prior to TypeScript 3.8, you can import a type using import. With TypeScript 3.8, you can import a type using the import statement, or using import type.

`// Re-using the same import
import { APIResponseType } from "./api";

// Explicitly use import type
import type { APIResponseType } from "./api";`


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...