Skip to content

Commit 2150a64

Browse files
committed
Add tests
1 parent 44116b5 commit 2150a64

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,19 @@ function test1<T extends Record<string, any>, K extends keyof T>(t: T, k: K) {
141141
t[k] = "hello"; // Error
142142
t[k] = [10, 20]; // Error
143143
}
144+
145+
// Repro from #28839
146+
147+
function f30<T, K extends keyof T>() {
148+
let x: Partial<Record<keyof T, string>>[K] = "hello";
149+
}
150+
151+
// We simplify indexed accesses applied to mapped types up to five levels deep
152+
153+
function f31<T, K extends keyof T>() {
154+
let x: Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>[K] = "hello";
155+
}
156+
157+
function f32<T, K extends keyof T>() {
158+
let x: Partial<Partial<Partial<Partial<Partial<Record<keyof T, string>>>>>>[K] = "hello";
159+
}

0 commit comments

Comments
 (0)