본문으로 건너뛰기

ReadonlyKeysOf

객체의 readonly 한 속성의 키를 추출합니다.

Signature​

type ReadonlyKeysOf<T extends object> = { [P in keyof T]-?: IfEquals<{ [Q in P]: T[P] }, { -readonly [Q in P]: T[P] }, never, P> }[keyof T];

References​

IfEquals

Example​

type Example = ReadonlyKeysOf<{
readonly a: number;
b: string;
readonly c: string;
}>;

// type Example = "a" | "c"