serializr icon indicating copy to clipboard operation
serializr copied to clipboard

add support for generic types

Open cruperman opened this issue 7 years ago • 3 comments

export class A<T> {
   @serializable(alias('foo', object(???))
   public Foo: T;
}

cruperman avatar Feb 27 '18 15:02 cruperman

Does the raw type handle this?

alexggordon avatar Apr 20 '18 18:04 alexggordon

I would say that it doesn't. The raw type, the way I read it, would only work if T were an interface. If T were an object with methods associated with it, then the raw type would be insufficient.

you can perform any logic that is not possible with the standard types using the custom type and applying your own methods for serialization and deserialization, the latter can also be performed asynchronously.

see e.g. this test case: https://github.com/mobxjs/serializr/blob/e46f7980d4a3db201ce7f75c9f3b235acdc7c61f/test/typescript/ts.ts#L494

1R053 avatar Jan 23 '19 22:01 1R053