rambda
Version:
Lightweight faster alternative to Ramda
19 lines (16 loc) • 408 B
text/typescript
import {Keys} from './Keys'
import {Equals} from '../Any/Equals'
// Credit https://stackoverflow.com/a/52473108/3570903
/** Get the keys of **`O`** that are readonly
* @param O
* @returns **`keyof`**
* @example
* ```ts
* ```
*/
export type ReadonlyKeys<O extends object> = {
[K in keyof O]-?: {
1: never
0: K
}[Equals<{-readonly [Q in K]: O[K]}, {[Q in K]: O[K]}>]
}[Keys<O>]