Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

class-transformer default value

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
}
Comment

PREVIOUS NEXT
Code Example
Typescript :: check if name is unique among non-deleted items laravel 
Typescript :: check if email exists firebase 
Typescript :: where do you get your test data 
Typescript :: roots of grass 
Typescript :: pros and cons? 
Typescript :: subplots in subplots 
Typescript :: laravel validation check if email exists forget password 
Typescript :: typescript hashmap 
Typescript :: get random dark color 
Typescript :: primeng dropdown formControlName setValue 
Typescript :: npm run serve https 
Typescript :: tailwind base components utilities 
Typescript :: get random light color 
Typescript :: plot multiple plots in r 
Typescript :: Create Hash Node TypeScript 
Typescript :: html form display results same page 
Typescript :: define typescript types 
Typescript :: typescript type from array 
Typescript :: computed vue typescript 
Typescript :: c# compare two objects for changes 
Typescript :: angular initail valeur in fromgroup 
Typescript :: data binding lwc multiple 
Typescript :: react native paper 
Typescript :: angular validator email 
Typescript :: how to add alias to my hosts in ansible hosts 
Typescript :: useCallback hook to fix useEffect re-render warning on function dependency 
Typescript :: Start Angular App In Localhost 
Typescript :: typescript add object to object 
Typescript :: ts object field from variable 
Typescript :: how to add command line arguments in vscode 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =