📅  最后修改于: 2022-03-11 14:48:25.654000             🧑  作者: Mango
import { Transform, Expose } from 'class-transformer'
import { cloneDeep } from 'lodash'
export function Default(defaultValue: unknown): PropertyDecorator {
return Transform((value: unknown) => value ?? cloneDeep(defaultValue))
}
class A {
@Expose()
@Default('123')
a: string
}