diff --git a/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts b/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts index 23e5cd6a66e..83687e8c872 100644 --- a/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts +++ b/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts @@ -321,6 +321,20 @@ function f90(x1: S2[keyof S2], x2: T[keyof S2] x4.length; } +function f91(x: T, y: T[keyof T], z: T[K]) { + let a: {}; + a = x; + a = y; + a = z; +} + +function f92(x: T, y: T[keyof T], z: T[K]) { + let a: {} | null | undefined; + a = x; + a = y; + a = z; +} + // Repros from #12011 class Base { @@ -594,3 +608,24 @@ type DynamicDBRecord = ({ dynamicField: number } | { dynami function getFlagsFromDynamicRecord(record: DynamicDBRecord, flags: Flag[]) { return record[flags[0]]; } + +// Repro from #21368 + +interface I { + foo: string; +} + +declare function take(p: T): void; + +function fn(o: T, k: K) { + take<{} | null | undefined>(o[k]); + take(o[k]); +} + +// Repro from #23133 + +class Unbounded { + foo(x: T[keyof T]) { + let y: {} | undefined | null = x; + } +}