farwayer / mst-decorators

Class based MobX-State-Tree definitions
26 stars 1 forks source link

Fixed Typescript definitions for typescript@3.7.2. #3

Closed Venryx closed 5 years ago

Venryx commented 5 years ago

Details: InstanceType<T> is now defined by TypeScript as follows:

/**
 * Obtain the return type of a constructor function type
 */
type InstanceType<T extends new (...args: any) => any> = T extends new (...args: any) => infer R ? R : any;

The extends clause requires that the type-parameter be a constructor.

Since InstanceType was used by Model.create in mst-decorators/src/index.d.ts, I had to replace it with a looser version, that just returns any if the supplied type-parameter for Model<T> is a normal function instead of a constructor. (as is true for this line in the tests)

farwayer commented 5 years ago

Thanks!