readonly, as const


readonly, as const

class Layer { id!: string; name!: string; x: number = 0; y: number = 0; width: number = 0; height: number = 0; } const LAYER_DATA_INITIALIZE_INCLUDE_KEYS: ReadonlyArray<keyof Layer> = [ 'x', 'y', 'width', 'height' ]; const x = LAYER_DATA_INITIALIZE_INCLUDE_KEYS[0]; // "id" | "name" | "x" | "y" | "width" | "height"; const LAYER_DATA_INITIALIZE_EXCLUDE_KEYS = ["id", "name"] as const; const id = LAYER_DATA_INITIALIZE_EXCLUDE_KEYS[0]; // "id" ReadonlyArray<T> const weekdays: ReadonlyArray<string> = ...


#as #asconst #const #MappedTypes #ReadonlyArray #TypeScript #타입스크립트

원문링크 : readonly, as const