export declare type JsonType = null | string | number | boolean | JsonObject | JsonArray; export declare type Serializer = (target: T) => JsonType; export declare type Deserializer = (data: JsonType, target?: T, instantiationMethod?: InstantiationMethod) => T; export declare type IConstructable = { constructor: Function; }; export declare type SerializeFn = (data: T) => JsonType; export declare type SerializablePrimitiveType = DateConstructor | NumberConstructor | BooleanConstructor | RegExpConstructor | StringConstructor; /** * #### InstantiationMethod.New: * The constructor will be invoked when a new instance needs to be created. * * #### InstantiationMethod.ObjectCreate: * The object will be created without invoking its constructor, which is useful for systems where constructed objects immediately freeze themselves * * #### InstantiationMethode.None: * *deserializeXXX* functions will return a plain object instead, which can be useful for systems like Redux that expect / require plain objects and not class instances. */ export declare enum InstantiationMethod { None = 0, New = 1, ObjectCreate = 2 } export interface JsonObject extends Indexable { } export interface JsonArray extends Array { } export interface ISerializer { Serialize: Serializer; Deserialize: Deserializer; } export interface Indexable { [idx: string]: T; } export interface SerializableType { new (...args: any[]): T; onSerialized?: (data: JsonObject, instance: T) => JsonObject | void; onDeserialized?: (data: JsonObject, instance: T, instantiationMethod?: InstantiationMethod) => T | void; } export interface CerializrAsJsonOptions { keyName: string; transformKey: boolean; }