Closed
Description
Bug Report
π Search Terms
suggestion pathof
π Version & Regression Information
4.7
β― Playground Link
Playground link with relevant code
π» Code
// get from https://github.com/microsoft/TypeScript/issues/20423#issuecomment-812564842
type PathOf<T, K extends string, P extends string = ""> =
K extends `${infer U}.${infer V}`
? U extends keyof T ? PathOf<T[U], V, `${P}${U}.`> : `${P}${keyof T & (string | number)}`
: K extends keyof T ? `${P}${K}` : `${P}${keyof T & (string | number)}`;
declare function consumer<K extends string>(path: PathOf<{a: string, b: {c: string}}, K>) : number;
// suggestion works well in 4.6, and not work in 4.7
consumer('b.')