VSCode and Vue 2 plugin TypeScript definitions
我正在使用VSCode和TypeScript类进行Vue 2组件开发。请参阅:vuejs / vue-class-component。
在我当前的项目中,我使用诸如
我如何才能了解到这些扩展功能存在且intellisense开始工作的VSCode?我可以创建自己的* .d.ts文件吗?如果是这样,我如何将它们连接起来,以便VSCode可以找到它们以进行智能检测?任何例子都欢迎。或链接到一些示例Github存储库中已完成的操作?
此问题现在已解决,并记录在Vue TypeScript文档中。它称为\\\\"与插件一起使用的扩展类型"。
以下摘录自该页面,供快速参考:
1 2 3 4 5 6 7 8 9 10 11 12 13 | // For example, to declare an instance property $myProperty with type string: // 1. Make sure to import 'vue' before declaring augmented types import Vue from 'vue' // 2. Specify a file with the types you want to augment // Vue has the constructor type in types/vue.d.ts declare module 'vue/types/vue' { // 3. Declare augmentation for Vue interface Vue { $myProperty: string } } |