Skip to content

Instantly share code, notes, and snippets.

@hadeshe93
Created December 8, 2020 03:27
Show Gist options
  • Save hadeshe93/67ba302cbe052aec0d634c5ac06b30dc to your computer and use it in GitHub Desktop.
Save hadeshe93/67ba302cbe052aec0d634c5ac06b30dc to your computer and use it in GitHub Desktop.
Type files for typescript, including recognizing file with '.vue' extension.
// 声明全局变量,防止编辑器报错
declare const wx: any;
declare const __wxConfig: any;
declare const App: any;
declare const getCurrentPages: any;
// 声明全局接口
interface IAnyObject {
[key: string]: any;
}
declare global {
// 扩展 window 对象
interface Window {
// 自定义将要挂载的方法
selfDefinedMethod(params: any): any;
// 自定义将要挂载的属性
selfDefinedAttr: any;
}
}
// 必须要加这行
export {}
declare module "*.vue" {
import Vue from "vue";
export default Vue;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment