Test getConstraintOfIndexedAccess fixes and update baselines

This commit is contained in:
Nathan Shively-Sanders
2017-08-17 12:45:20 -07:00
parent b8e0dedac0
commit 1b4f90705f
7 changed files with 322 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
// test for #17069
function sum<T extends Record<K, number>, K extends string>(n: number, v: T, k: K) {
n = n + v[k];
n += v[k]; // += should work the same way
}
function realSum<T extends Record<K, number>, K extends string>(n: number, vs: T[], k: K) {
for (const v of vs) {
n = n + v[k];
n += v[k];
}
}

View File

@@ -0,0 +1,32 @@
// @strict: true
// test for #15371
function f<T extends object, P extends keyof T>(s: string, tp: T[P]): void {
tp = s;
}
function g<T extends null, P extends keyof T>(s: string, tp: T[P]): void {
tp = s;
}
function h<T extends undefined, P extends keyof T>(s: string, tp: T[P]): void {
tp = s;
}
function i<T extends void, P extends keyof T>(s: string, tp: T[P]): void {
tp = s;
}
function j<T extends never, P extends keyof T>(s: string, tp: T[P]): void {
tp = s;
}
function k<T extends number, P extends keyof T>(s: string, tp: T[P]): void {
tp = s;
}
function o<T extends string, P extends keyof T>(s: string, tp: T[P]): void {
tp = s;
}
function l<T extends {}, P extends keyof T>(s: string, tp: T[P]): void {
tp = s;
}
function m<T extends { a: number }, P extends keyof T>(s: string, tp: T[P]): void {
tp = s;
}
function n<T extends { [s: string]: number }, P extends keyof T>(s: string, tp: T[P]): void {
tp = s;
}