Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type augmentation test #3713

Merged
merged 1 commit into from
Sep 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 35 additions & 0 deletions types/test/augmentation-test.ts
Original file line number Diff line number Diff line change
@@ -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();
3 changes: 2 additions & 1 deletion types/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"../vue.d.ts",
"options-test.ts",
"plugin-test.ts",
"vue-test.ts"
"vue-test.ts",
"augmentation-test.ts"
],
"compileOnSave": false
}