Skip to content

fix: wrong docstring that instanceToClass should be changed to plainToInstance #1413

Closed as not planned
@tmac12

Description

@tmac12

Description

The instanceToClass function doesn't exist. It should be changed to the plainToInstance function.

Minimal code-snippet showcasing the problem
Wrong deprecated suggestion, instanceToClass doesn't exists.

/**
 * 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))
 * ```
 *
 */
export declare function deserializeArray<T>(cls: ClassConstructor<T>, json: string, options?: ClassTransformOptions): T[];

Expected behavior

It suggest to use instanceToClass instead of plainToInstance.

/**
 * Deserializes given JSON string to a object of the given class.
 *
 * @deprecated This function is being removed. Please use the following instead:
 * ```
 * plainToInstance(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 => plainToInstance(cls, value, options))
 * ```
 *
 */
export declare function deserializeArray<T>(cls: ClassConstructor<T>, json: string, options?: ClassTransformOptions): T[];

Actual behavior

It suggest to use instanceToClass that doesn't exists.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: duplicateIssue is being tracked already in another issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions