mirror of https://github.com/vuejs/vue.git
add module augmentation test (#3713)
This commit is contained in:
parent
4785afd154
commit
019d90040d
|
|
@ -0,0 +1,35 @@
|
|||
import Vue = require("../index");
|
||||
|
||||
declare module "../vue" {
|
||||
// add instance property and method
|
||||
interface Vue {
|
||||
$instanceProperty: string;
|
||||
$instanceMethod(): void;
|
||||
}
|
||||
|
||||
// add static property and method
|
||||
namespace Vue {
|
||||
const staticProperty: string;
|
||||
function staticMethod(): void;
|
||||
}
|
||||
}
|
||||
|
||||
// augment ComponentOptions
|
||||
declare module "../options" {
|
||||
interface ComponentOptions<V extends Vue> {
|
||||
foo?: string;
|
||||
}
|
||||
}
|
||||
|
||||
const vm = new Vue({
|
||||
data: {
|
||||
a: true
|
||||
},
|
||||
foo: "foo"
|
||||
});
|
||||
|
||||
vm.$instanceProperty;
|
||||
vm.$instanceMethod();
|
||||
|
||||
Vue.staticProperty;
|
||||
Vue.staticMethod();
|
||||
|
|
@ -14,7 +14,8 @@
|
|||
"../vue.d.ts",
|
||||
"options-test.ts",
|
||||
"plugin-test.ts",
|
||||
"vue-test.ts"
|
||||
"vue-test.ts",
|
||||
"augmentation-test.ts"
|
||||
],
|
||||
"compileOnSave": false
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue