Bab*_*age 6 typescript vue.js vue-component typescript-typings vuejs2
有一个模块扩充(types/test.d.ts):
import Vue from 'vue'
declare module 'vue/types/vue' {
interface Vue {
$test: string
}
}
Run Code Online (Sandbox Code Playgroud)
并将其包含为(tsconfig.json):
// ...
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx",
"types/*.d.ts"
],
// ...
Run Code Online (Sandbox Code Playgroud)
然后,它在任何.ts文件中都能正常工作:
有人可以帮助我吗?
尝试将 types/*.d.ts 添加到 yout tsconfig 中的 typeRoots
像这样:
"typeRoots": [
"src/types"
],
Run Code Online (Sandbox Code Playgroud)
(通常我使用@types来存储我的.d.ts文件)
归档时间: |
|
查看次数: |
276 次 |
最近记录: |