mobxjs / serializr

Serialize and deserialize complex object graphs to and from JSON and Javascript classes
MIT License
766 stars 52 forks source link

Typing of deserialize #40

Closed ghost closed 7 years ago

ghost commented 7 years ago

I think the type parameter T of deserialize

function deserialize<T>(modelschema: ClazzOrModelSchema<T>, jsonArray: any[], ...): T[];

would be more straightforward if it takes the type of the array itself, instead of its element, i.e.

function deserialize<T extends any[]>(modelschema: ClazzOrModelSchema<T[0]>, jsonArray: any[], ...): T;

and call it like:

deserialize<Model[]>(Model, array, ...);