fix: Documentation in index.d.ts deprecated functions deserialize, serialize
Description
deserialize and serialize functions have an error in documentation requesting to change the function to instanceToClass function which is not defined in the index.d.ts file.
export declare function serialize<T>(object: T, options?: ClassTransformOptions): string;
export declare function serialize<T>(object: T[], options?: ClassTransformOptions): string;
/**
* Deserializes given JSON string to a object of the given class.
*
* @deprecated This function is being removed. Please use the following instead:
* ```
* **instanceToClass**(cls, JSON.parse(json), options)
* ```
*/
export declare function deserialize<T>(cls: ClassConstructor<T>, json: string, options?: ClassTransformOptions): T;
/**
* Deserializes given JSON string to an array of objects of the given class.
*
* @deprecated This function is being removed. Please use the following instead:
* ```
* JSON.parse(json).map(value => **instanceToClass**(cls, value, options))
* ```
*
*/
not sure what the correct wording is.
I'm also seeing this.
I have the same problem:
Steps to reproduce:
-
Install
class-transformer -
Try to use it
import { deserializeArray, deserialize } from 'class-transformer'; class AClass { foo: number = 1; bar: string = "baz"; } const jsonArrayString: string = '[{"foo": 1, "bar": "baz"}, {"foo": 2, "bar": "qux"}]'; const deserializedArray: AClass[] = deserializeArray(AClass, jsonArrayString); const jsonObjectString: string = '{"foo": 3, "bar": "bax"}'; const deserialized = deserialize(AClass, jsonObjectString);
Both functions will be reported as deprecated:


In fact when searching for 'instanceToClass' inside the codebase, only two occurrences can be found, in the JSdoc comments of deserialize() and deserializeArray() in src/index.ts:

Also, since the two functions are deprecated, consider removing them from the readme.
Duplicate of https://github.com/typestack/class-transformer/issues/1019