augmentation-test.ts 592 B

1234567891011121314151617181920212223242526272829303132333435
  1. import Vue = require("../index");
  2. declare module "../vue" {
  3. // add instance property and method
  4. interface Vue {
  5. $instanceProperty: string;
  6. $instanceMethod(): void;
  7. }
  8. // add static property and method
  9. namespace Vue {
  10. const staticProperty: string;
  11. function staticMethod(): void;
  12. }
  13. }
  14. // augment ComponentOptions
  15. declare module "../options" {
  16. interface ComponentOptions<V extends Vue> {
  17. foo?: string;
  18. }
  19. }
  20. const vm = new Vue({
  21. data: {
  22. a: true
  23. },
  24. foo: "foo"
  25. });
  26. vm.$instanceProperty;
  27. vm.$instanceMethod();
  28. Vue.staticProperty;
  29. Vue.staticMethod();