Closed
Description
Bug Report
π Search Terms
recursive conditional types
π Version & Regression Information
- This changed between versions 4.5.5 and 4.6.2
β― Playground Link
π» Code
type Query<T> = {
[P in DeepKeys<T>]?: string;
};
type Primitive =
| null
| undefined
| string
| number
| boolean
| symbol
| bigint;
type DeepKeys<T> = T extends Primitive
? never
:
| (keyof T & string)
| {
[P in keyof T & string]: T[P] extends (infer Inner)[]
? `${P}.${DeepKeys<Inner>}`
: T[P] extends object
? `${P}.${DeepKeys<T[P]>}`
: P;
}[keyof T & string];
π Actual behavior
Type instantiation is excessively deep and possibly infinite.
at the ${P}.${DeepKeys<T[P]>}
snippet.
π Expected behavior
No error. Type properly resolves to dot-notation keys of input object.