Explorar o código

fix(types): avoid `this` in VueConstructor signature (#9173)

https://github.com/vuejs/vue-class-component/issues/294#issuecomment-445526936
Herrington Darkholme %!s(int64=7) %!d(string=hai) anos
pai
achega
e06d2af276
Modificáronse 3 ficheiros con 13 adicións e 5 borrados
  1. 1 0
      types/test/tsconfig.json
  2. 9 2
      types/test/vue-test.ts
  3. 3 3
      types/vue.d.ts

+ 1 - 0
types/test/tsconfig.json

@@ -1,6 +1,7 @@
 {
   "compilerOptions": {
     "target": "es5",
+    "experimentalDecorators": true,
     "lib": [
       "dom",
       "es2015"

+ 9 - 2
types/test/vue-test.ts

@@ -102,10 +102,10 @@ class Test extends Vue {
     this.compile("<div>{{ message }}</div>");
     this
       .use(() => {
-        
+
       })
       .use(() => {
-        
+
       })
       .mixin({})
       .mixin({});
@@ -193,3 +193,10 @@ Vue.extend({
     return h('canvas', {}, [a])
   }
 })
+
+declare function decorate<VC extends typeof Vue>(v: VC): VC;
+
+@decorate
+class Decorated extends Vue {
+  a = 123;
+}

+ 3 - 3
types/vue.d.ts

@@ -111,9 +111,9 @@ export interface VueConstructor<V extends Vue = Vue> {
   component<Props>(id: string, definition: FunctionalComponentOptions<Props, RecordPropsDefinition<Props>>): ExtendedVue<V, {}, {}, {}, Props>;
   component(id: string, definition?: ComponentOptions<V>): ExtendedVue<V, {}, {}, {}, {}>;
 
-  use<T>(plugin: PluginObject<T> | PluginFunction<T>, options?: T): this;
-  use(plugin: PluginObject<any> | PluginFunction<any>, ...options: any[]): this;
-  mixin(mixin: VueConstructor | ComponentOptions<Vue>): this;
+  use<T>(plugin: PluginObject<T> | PluginFunction<T>, options?: T): VueConstructor<V>;
+  use(plugin: PluginObject<any> | PluginFunction<any>, ...options: any[]): VueConstructor<V>;
+  mixin(mixin: VueConstructor | ComponentOptions<Vue>): VueConstructor<V>;
   compile(template: string): {
     render(createElement: typeof Vue.prototype.$createElement): VNode;
     staticRenderFns: (() => VNode)[];