Skip to content

Commit 019d900

Browse files
ktsnyyx990803
authored andcommitted
add module augmentation test (#3713)
1 parent 4785afd commit 019d900

2 files changed

Lines changed: 37 additions & 1 deletion

File tree

types/test/augmentation-test.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import Vue = require("../index");
2+
3+
declare module "../vue" {
4+
// add instance property and method
5+
interface Vue {
6+
$instanceProperty: string;
7+
$instanceMethod(): void;
8+
}
9+
10+
// add static property and method
11+
namespace Vue {
12+
const staticProperty: string;
13+
function staticMethod(): void;
14+
}
15+
}
16+
17+
// augment ComponentOptions
18+
declare module "../options" {
19+
interface ComponentOptions<V extends Vue> {
20+
foo?: string;
21+
}
22+
}
23+
24+
const vm = new Vue({
25+
data: {
26+
a: true
27+
},
28+
foo: "foo"
29+
});
30+
31+
vm.$instanceProperty;
32+
vm.$instanceMethod();
33+
34+
Vue.staticProperty;
35+
Vue.staticMethod();

types/test/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"../vue.d.ts",
1515
"options-test.ts",
1616
"plugin-test.ts",
17-
"vue-test.ts"
17+
"vue-test.ts",
18+
"augmentation-test.ts"
1819
],
1920
"compileOnSave": false
2021
}

0 commit comments

Comments
 (0)