Closed
Description
#12114 added mapped types, including recursive mapped types. But as pointed out by @ahejlsberg
Note, however, that such types aren't particularly useful without some form of conditional type that makes it possible to limit the recursion to selected kinds of types.
type primitive = string | number | boolean | undefined | null;
type DeepReadonly<T> = T extends primitive ? T : DeepReadonlyObject<T>;
type DeepReadonlyObject<T> = {
readonly [P in keyof T]: DeepReadonly<T[P]>;
};
I couldn't find an existing issue with a feature request.
Conditional mapping would greatly improve the ergonomics of libraries like Immutable.js.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment