mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-16 15:45:27 -05:00
Test getConstraintOfIndexedAccess fixes and update baselines
This commit is contained in:
@@ -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];
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user