Accept new baselines
This commit is contained in:
parent
34994627f0
commit
69cd6c0ff5
|
@ -300,23 +300,16 @@ type S2 = {
|
||||||
b: string;
|
b: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
function f90<T extends S2, K extends keyof S2>(x1: S2[keyof S2], x2: T[keyof S2], x3: S2[K], x4: T[K]) {
|
function f90<T extends S2, K extends keyof S2>(x1: S2[keyof S2], x2: T[keyof S2], x3: S2[K]) {
|
||||||
x1 = x2;
|
x1 = x2;
|
||||||
x1 = x3;
|
x1 = x3;
|
||||||
x1 = x4;
|
|
||||||
x2 = x1;
|
x2 = x1;
|
||||||
x2 = x3;
|
x2 = x3;
|
||||||
x2 = x4;
|
|
||||||
x3 = x1;
|
x3 = x1;
|
||||||
x3 = x2;
|
x3 = x2;
|
||||||
x3 = x4;
|
|
||||||
x4 = x1;
|
|
||||||
x4 = x2;
|
|
||||||
x4 = x3;
|
|
||||||
x1.length;
|
x1.length;
|
||||||
x2.length;
|
x2.length;
|
||||||
x3.length;
|
x3.length;
|
||||||
x4.length;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function f91<T, K extends keyof T>(x: T, y: T[keyof T], z: T[K]) {
|
function f91<T, K extends keyof T>(x: T, y: T[keyof T], z: T[K]) {
|
||||||
|
@ -886,23 +879,16 @@ var C1 = /** @class */ (function () {
|
||||||
};
|
};
|
||||||
return C1;
|
return C1;
|
||||||
}());
|
}());
|
||||||
function f90(x1, x2, x3, x4) {
|
function f90(x1, x2, x3) {
|
||||||
x1 = x2;
|
x1 = x2;
|
||||||
x1 = x3;
|
x1 = x3;
|
||||||
x1 = x4;
|
|
||||||
x2 = x1;
|
x2 = x1;
|
||||||
x2 = x3;
|
x2 = x3;
|
||||||
x2 = x4;
|
|
||||||
x3 = x1;
|
x3 = x1;
|
||||||
x3 = x2;
|
x3 = x2;
|
||||||
x3 = x4;
|
|
||||||
x4 = x1;
|
|
||||||
x4 = x2;
|
|
||||||
x4 = x3;
|
|
||||||
x1.length;
|
x1.length;
|
||||||
x2.length;
|
x2.length;
|
||||||
x3.length;
|
x3.length;
|
||||||
x4.length;
|
|
||||||
}
|
}
|
||||||
function f91(x, y, z) {
|
function f91(x, y, z) {
|
||||||
var a;
|
var a;
|
||||||
|
@ -1240,7 +1226,7 @@ declare type S2 = {
|
||||||
a: string;
|
a: string;
|
||||||
b: string;
|
b: string;
|
||||||
};
|
};
|
||||||
declare function f90<T extends S2, K extends keyof S2>(x1: S2[keyof S2], x2: T[keyof S2], x3: S2[K], x4: T[K]): void;
|
declare function f90<T extends S2, K extends keyof S2>(x1: S2[keyof S2], x2: T[keyof S2], x3: S2[K]): void;
|
||||||
declare function f91<T, K extends keyof T>(x: T, y: T[keyof T], z: T[K]): void;
|
declare function f91<T, K extends keyof T>(x: T, y: T[keyof T], z: T[K]): void;
|
||||||
declare function f92<T, K extends keyof T>(x: T, y: T[keyof T], z: T[K]): void;
|
declare function f92<T, K extends keyof T>(x: T, y: T[keyof T], z: T[K]): void;
|
||||||
declare class Base {
|
declare class Base {
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1207,12 +1207,11 @@ type S2 = {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function f90<T extends S2, K extends keyof S2>(x1: S2[keyof S2], x2: T[keyof S2], x3: S2[K], x4: T[K]) {
|
function f90<T extends S2, K extends keyof S2>(x1: S2[keyof S2], x2: T[keyof S2], x3: S2[K]) {
|
||||||
>f90 : <T extends S2, K extends "a" | "b">(x1: string, x2: T["a" | "b"], x3: S2[K], x4: T[K]) => void
|
>f90 : <T extends S2, K extends "a" | "b">(x1: string, x2: T["a" | "b"], x3: S2[K]) => void
|
||||||
>x1 : string
|
>x1 : string
|
||||||
>x2 : T["a" | "b"]
|
>x2 : T["a" | "b"]
|
||||||
>x3 : S2[K]
|
>x3 : S2[K]
|
||||||
>x4 : T[K]
|
|
||||||
|
|
||||||
x1 = x2;
|
x1 = x2;
|
||||||
>x1 = x2 : T["a" | "b"]
|
>x1 = x2 : T["a" | "b"]
|
||||||
|
@ -1224,11 +1223,6 @@ function f90<T extends S2, K extends keyof S2>(x1: S2[keyof S2], x2: T[keyof S2]
|
||||||
>x1 : string
|
>x1 : string
|
||||||
>x3 : S2[K]
|
>x3 : S2[K]
|
||||||
|
|
||||||
x1 = x4;
|
|
||||||
>x1 = x4 : T[K]
|
|
||||||
>x1 : string
|
|
||||||
>x4 : T[K]
|
|
||||||
|
|
||||||
x2 = x1;
|
x2 = x1;
|
||||||
>x2 = x1 : string
|
>x2 = x1 : string
|
||||||
>x2 : T["a" | "b"]
|
>x2 : T["a" | "b"]
|
||||||
|
@ -1239,11 +1233,6 @@ function f90<T extends S2, K extends keyof S2>(x1: S2[keyof S2], x2: T[keyof S2]
|
||||||
>x2 : T["a" | "b"]
|
>x2 : T["a" | "b"]
|
||||||
>x3 : S2[K]
|
>x3 : S2[K]
|
||||||
|
|
||||||
x2 = x4;
|
|
||||||
>x2 = x4 : T[K]
|
|
||||||
>x2 : T["a" | "b"]
|
|
||||||
>x4 : T[K]
|
|
||||||
|
|
||||||
x3 = x1;
|
x3 = x1;
|
||||||
>x3 = x1 : string
|
>x3 = x1 : string
|
||||||
>x3 : S2[K]
|
>x3 : S2[K]
|
||||||
|
@ -1254,26 +1243,6 @@ function f90<T extends S2, K extends keyof S2>(x1: S2[keyof S2], x2: T[keyof S2]
|
||||||
>x3 : S2[K]
|
>x3 : S2[K]
|
||||||
>x2 : T["a" | "b"]
|
>x2 : T["a" | "b"]
|
||||||
|
|
||||||
x3 = x4;
|
|
||||||
>x3 = x4 : T[K]
|
|
||||||
>x3 : S2[K]
|
|
||||||
>x4 : T[K]
|
|
||||||
|
|
||||||
x4 = x1;
|
|
||||||
>x4 = x1 : string
|
|
||||||
>x4 : T[K]
|
|
||||||
>x1 : string
|
|
||||||
|
|
||||||
x4 = x2;
|
|
||||||
>x4 = x2 : T["a" | "b"]
|
|
||||||
>x4 : T[K]
|
|
||||||
>x2 : T["a" | "b"]
|
|
||||||
|
|
||||||
x4 = x3;
|
|
||||||
>x4 = x3 : S2[K]
|
|
||||||
>x4 : T[K]
|
|
||||||
>x3 : S2[K]
|
|
||||||
|
|
||||||
x1.length;
|
x1.length;
|
||||||
>x1.length : number
|
>x1.length : number
|
||||||
>x1 : string
|
>x1 : string
|
||||||
|
@ -1287,11 +1256,6 @@ function f90<T extends S2, K extends keyof S2>(x1: S2[keyof S2], x2: T[keyof S2]
|
||||||
x3.length;
|
x3.length;
|
||||||
>x3.length : number
|
>x3.length : number
|
||||||
>x3 : S2[K]
|
>x3 : S2[K]
|
||||||
>length : number
|
|
||||||
|
|
||||||
x4.length;
|
|
||||||
>x4.length : number
|
|
||||||
>x4 : T[K]
|
|
||||||
>length : number
|
>length : number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,9 +63,12 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(117,5): error
|
||||||
Type 'T' is not assignable to type 'U'.
|
Type 'T' is not assignable to type 'U'.
|
||||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(122,5): error TS2322: Type '42' is not assignable to type 'keyof T'.
|
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(122,5): error TS2322: Type '42' is not assignable to type 'keyof T'.
|
||||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(123,5): error TS2322: Type '"hello"' is not assignable to type 'keyof T'.
|
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(123,5): error TS2322: Type '"hello"' is not assignable to type 'keyof T'.
|
||||||
|
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(140,5): error TS2322: Type '42' is not assignable to type 'T[K]'.
|
||||||
|
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(141,5): error TS2322: Type '"hello"' is not assignable to type 'T[K]'.
|
||||||
|
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(142,5): error TS2322: Type 'number[]' is not assignable to type 'T[K]'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts (38 errors) ====
|
==== tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts (41 errors) ====
|
||||||
class Shape {
|
class Shape {
|
||||||
name: string;
|
name: string;
|
||||||
width: number;
|
width: number;
|
||||||
|
@ -293,4 +296,29 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(123,5): error
|
||||||
~
|
~
|
||||||
!!! error TS2322: Type '"hello"' is not assignable to type 'keyof T'.
|
!!! error TS2322: Type '"hello"' is not assignable to type 'keyof T'.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Repro from #27470
|
||||||
|
|
||||||
|
type UndefinedKeys<T extends Record<string, any>> = {
|
||||||
|
[K in keyof T]: undefined extends T[K] ? K : never
|
||||||
|
};
|
||||||
|
|
||||||
|
type MyType = {a: string, b: string | undefined}
|
||||||
|
|
||||||
|
type Result1 = UndefinedKeys<MyType>;
|
||||||
|
|
||||||
|
const a1: Result1['a'] = 'a'; // Error
|
||||||
|
const b1: Result1['b'] = 'b';
|
||||||
|
|
||||||
|
function test1<T extends Record<string, any>, K extends keyof T>(t: T, k: K) {
|
||||||
|
t[k] = 42; // Error
|
||||||
|
~~~~
|
||||||
|
!!! error TS2322: Type '42' is not assignable to type 'T[K]'.
|
||||||
|
t[k] = "hello"; // Error
|
||||||
|
~~~~
|
||||||
|
!!! error TS2322: Type '"hello"' is not assignable to type 'T[K]'.
|
||||||
|
t[k] = [10, 20]; // Error
|
||||||
|
~~~~
|
||||||
|
!!! error TS2322: Type 'number[]' is not assignable to type 'T[K]'.
|
||||||
|
}
|
||||||
|
|
|
@ -123,6 +123,25 @@ function f4<T extends { [K in keyof T]: string }>(k: keyof T) {
|
||||||
k = 42; // error
|
k = 42; // error
|
||||||
k = "hello"; // error
|
k = "hello"; // error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Repro from #27470
|
||||||
|
|
||||||
|
type UndefinedKeys<T extends Record<string, any>> = {
|
||||||
|
[K in keyof T]: undefined extends T[K] ? K : never
|
||||||
|
};
|
||||||
|
|
||||||
|
type MyType = {a: string, b: string | undefined}
|
||||||
|
|
||||||
|
type Result1 = UndefinedKeys<MyType>;
|
||||||
|
|
||||||
|
const a1: Result1['a'] = 'a'; // Error
|
||||||
|
const b1: Result1['b'] = 'b';
|
||||||
|
|
||||||
|
function test1<T extends Record<string, any>, K extends keyof T>(t: T, k: K) {
|
||||||
|
t[k] = 42; // Error
|
||||||
|
t[k] = "hello"; // Error
|
||||||
|
t[k] = [10, 20]; // Error
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//// [keyofAndIndexedAccessErrors.js]
|
//// [keyofAndIndexedAccessErrors.js]
|
||||||
|
@ -189,3 +208,10 @@ function f4(k) {
|
||||||
k = 42; // error
|
k = 42; // error
|
||||||
k = "hello"; // error
|
k = "hello"; // error
|
||||||
}
|
}
|
||||||
|
var a1 = 'a'; // Error
|
||||||
|
var b1 = 'b';
|
||||||
|
function test1(t, k) {
|
||||||
|
t[k] = 42; // Error
|
||||||
|
t[k] = "hello"; // Error
|
||||||
|
t[k] = [10, 20]; // Error
|
||||||
|
}
|
||||||
|
|
|
@ -428,3 +428,61 @@ function f4<T extends { [K in keyof T]: string }>(k: keyof T) {
|
||||||
>k : Symbol(k, Decl(keyofAndIndexedAccessErrors.ts, 120, 50))
|
>k : Symbol(k, Decl(keyofAndIndexedAccessErrors.ts, 120, 50))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Repro from #27470
|
||||||
|
|
||||||
|
type UndefinedKeys<T extends Record<string, any>> = {
|
||||||
|
>UndefinedKeys : Symbol(UndefinedKeys, Decl(keyofAndIndexedAccessErrors.ts, 123, 1))
|
||||||
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 127, 19))
|
||||||
|
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
|
||||||
|
|
||||||
|
[K in keyof T]: undefined extends T[K] ? K : never
|
||||||
|
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 128, 3))
|
||||||
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 127, 19))
|
||||||
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 127, 19))
|
||||||
|
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 128, 3))
|
||||||
|
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 128, 3))
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
type MyType = {a: string, b: string | undefined}
|
||||||
|
>MyType : Symbol(MyType, Decl(keyofAndIndexedAccessErrors.ts, 129, 2))
|
||||||
|
>a : Symbol(a, Decl(keyofAndIndexedAccessErrors.ts, 131, 15))
|
||||||
|
>b : Symbol(b, Decl(keyofAndIndexedAccessErrors.ts, 131, 25))
|
||||||
|
|
||||||
|
type Result1 = UndefinedKeys<MyType>;
|
||||||
|
>Result1 : Symbol(Result1, Decl(keyofAndIndexedAccessErrors.ts, 131, 48))
|
||||||
|
>UndefinedKeys : Symbol(UndefinedKeys, Decl(keyofAndIndexedAccessErrors.ts, 123, 1))
|
||||||
|
>MyType : Symbol(MyType, Decl(keyofAndIndexedAccessErrors.ts, 129, 2))
|
||||||
|
|
||||||
|
const a1: Result1['a'] = 'a'; // Error
|
||||||
|
>a1 : Symbol(a1, Decl(keyofAndIndexedAccessErrors.ts, 135, 5))
|
||||||
|
>Result1 : Symbol(Result1, Decl(keyofAndIndexedAccessErrors.ts, 131, 48))
|
||||||
|
|
||||||
|
const b1: Result1['b'] = 'b';
|
||||||
|
>b1 : Symbol(b1, Decl(keyofAndIndexedAccessErrors.ts, 136, 5))
|
||||||
|
>Result1 : Symbol(Result1, Decl(keyofAndIndexedAccessErrors.ts, 131, 48))
|
||||||
|
|
||||||
|
function test1<T extends Record<string, any>, K extends keyof T>(t: T, k: K) {
|
||||||
|
>test1 : Symbol(test1, Decl(keyofAndIndexedAccessErrors.ts, 136, 29))
|
||||||
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 138, 15))
|
||||||
|
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
|
||||||
|
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 138, 45))
|
||||||
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 138, 15))
|
||||||
|
>t : Symbol(t, Decl(keyofAndIndexedAccessErrors.ts, 138, 65))
|
||||||
|
>T : Symbol(T, Decl(keyofAndIndexedAccessErrors.ts, 138, 15))
|
||||||
|
>k : Symbol(k, Decl(keyofAndIndexedAccessErrors.ts, 138, 70))
|
||||||
|
>K : Symbol(K, Decl(keyofAndIndexedAccessErrors.ts, 138, 45))
|
||||||
|
|
||||||
|
t[k] = 42; // Error
|
||||||
|
>t : Symbol(t, Decl(keyofAndIndexedAccessErrors.ts, 138, 65))
|
||||||
|
>k : Symbol(k, Decl(keyofAndIndexedAccessErrors.ts, 138, 70))
|
||||||
|
|
||||||
|
t[k] = "hello"; // Error
|
||||||
|
>t : Symbol(t, Decl(keyofAndIndexedAccessErrors.ts, 138, 65))
|
||||||
|
>k : Symbol(k, Decl(keyofAndIndexedAccessErrors.ts, 138, 70))
|
||||||
|
|
||||||
|
t[k] = [10, 20]; // Error
|
||||||
|
>t : Symbol(t, Decl(keyofAndIndexedAccessErrors.ts, 138, 65))
|
||||||
|
>k : Symbol(k, Decl(keyofAndIndexedAccessErrors.ts, 138, 70))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -412,3 +412,56 @@ function f4<T extends { [K in keyof T]: string }>(k: keyof T) {
|
||||||
>"hello" : "hello"
|
>"hello" : "hello"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Repro from #27470
|
||||||
|
|
||||||
|
type UndefinedKeys<T extends Record<string, any>> = {
|
||||||
|
>UndefinedKeys : UndefinedKeys<T>
|
||||||
|
|
||||||
|
[K in keyof T]: undefined extends T[K] ? K : never
|
||||||
|
};
|
||||||
|
|
||||||
|
type MyType = {a: string, b: string | undefined}
|
||||||
|
>MyType : MyType
|
||||||
|
>a : string
|
||||||
|
>b : string
|
||||||
|
|
||||||
|
type Result1 = UndefinedKeys<MyType>;
|
||||||
|
>Result1 : UndefinedKeys<MyType>
|
||||||
|
|
||||||
|
const a1: Result1['a'] = 'a'; // Error
|
||||||
|
>a1 : "a"
|
||||||
|
>'a' : "a"
|
||||||
|
|
||||||
|
const b1: Result1['b'] = 'b';
|
||||||
|
>b1 : "b"
|
||||||
|
>'b' : "b"
|
||||||
|
|
||||||
|
function test1<T extends Record<string, any>, K extends keyof T>(t: T, k: K) {
|
||||||
|
>test1 : <T extends Record<string, any>, K extends keyof T>(t: T, k: K) => void
|
||||||
|
>t : T
|
||||||
|
>k : K
|
||||||
|
|
||||||
|
t[k] = 42; // Error
|
||||||
|
>t[k] = 42 : 42
|
||||||
|
>t[k] : T[K]
|
||||||
|
>t : T
|
||||||
|
>k : K
|
||||||
|
>42 : 42
|
||||||
|
|
||||||
|
t[k] = "hello"; // Error
|
||||||
|
>t[k] = "hello" : "hello"
|
||||||
|
>t[k] : T[K]
|
||||||
|
>t : T
|
||||||
|
>k : K
|
||||||
|
>"hello" : "hello"
|
||||||
|
|
||||||
|
t[k] = [10, 20]; // Error
|
||||||
|
>t[k] = [10, 20] : number[]
|
||||||
|
>t[k] : T[K]
|
||||||
|
>t : T
|
||||||
|
>k : K
|
||||||
|
>[10, 20] : number[]
|
||||||
|
>10 : 10
|
||||||
|
>20 : 20
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue