michaelolof / vuex-class-component

A Type Safe Vuex Module or Store Using ES6 Classes and ES7 Decorators written in TypeScript.
217 stars 21 forks source link

Missing extends on generic type in proxy and submodule declarations #35

Closed aymasse closed 5 years ago

aymasse commented 5 years ago

Hello,

First of all, thank you very much for your work. I tried migrating to v2 on a project using vue-cli, and unfortunately got an error during compilation, specifically:

ERROR in node_modules/vuex-class-component/dist/proxy.d.ts
5:101 Type 'T' does not satisfy the constraint 'new (...args: any) => any'.
    3 | export declare function createProxy<T extends typeof VuexModule>($store: any, cls: T): ProxyWatchers & InstanceType<T>;
    4 | export declare function createLocalProxy<T extends typeof VuexModule>(cls: T, $store: any): InstanceType<T>;
  > 5 | export declare function _createProxy<T>(cls: T, $store: any, namespacedPath?: string): InstanceType<T>;
      |                                                                                                     ^
    6 |

and:

ERROR in node_modules/vuex-class-component/dist/proxy.d.ts
5:101 Type 'T' does not satisfy the constraint 'new (...args: any) => any'.
    3 | export declare function createProxy<T extends typeof VuexModule>($store: any, cls: T): ProxyWatchers & InstanceType<T>;
    4 | export declare function createLocalProxy<T extends typeof VuexModule>(cls: T, $store: any): InstanceType<T>;
  > 5 | export declare function _createProxy<T>(cls: T, $store: any, namespacedPath?: string): InstanceType<T>;
      |                                                                                                     ^
    6 | 

I tracked those errors to a missing extends in the declaration files of proxy and submodule classes.

Changing:

export declare function createSubModule<T>(Cls: T): InstanceType<T>;

to:

export declare function createSubModule<T extends typeof VuexModule>(Cls: T): InstanceType<T>;

and doing the same for proxy seems to fix my problem.

NicoAiko commented 5 years ago

I got that same error.

Please fix :)