Open
Description
Description
#238 feature allows us to add custom options to @Transform
functions, but ClassTransformOptions
interface itself does not allow to add custom options. See its current source here:
This also will be useful for #89.
Proposed solution
I think custom keys should be alowed in the interface like this:
export interface ClassTransformOptions {
...
/** Additional custom options for Transform functions */
[key: PropertyKey]: any;
}
or like this:
export interface ClassTransformOptions {
...
/** Additional custom options for Transform functions */
custom: Record<PropertyKey, any>;
}
or even like this:
export interface ClassTransformOptions<T = Record<PropertyKey, any>> {
...
/** Additional custom options for Transform functions */
custom: T;
}
Workaround
import {ClassTransformOptions as _ClassTransformOptions} from 'class-transformer/types/interfaces/class-transformer-options.interface';
export interface ClassTransformOptions extends _ClassTransformOptions {
custom: {
/**
* Time zone, as specified by the IANA Time Zone Database.
* Used for handling UTC timestamps in `toJSON()`.
* Example: Europe/Moscow
*/
timezone: string;
}
}