Home > types-kit > ReadonlyKeys
Get readonly property keys of T.
Signature:
export type ReadonlyKeys<T> = {
// remove undefined key
[K in keyof T]-?: If<
IsEquals<{ [P in K]: T[P] }, { -readonly [P in K]: T[P] }>,
never,
K
>
}[Keys<T>]References: If, IsEquals, Keys
interface Props {
readonly a?: number
b: number
readonly c: number
}
// Expect: 'a' | 'c'
type Keys = ReadonlyKeys<Props>