diff --git a/tests/baselines/reference/inferTypes1.errors.txt b/tests/baselines/reference/inferTypes1.errors.txt index d8dea7d9868..d5b91a426e3 100644 --- a/tests/baselines/reference/inferTypes1.errors.txt +++ b/tests/baselines/reference/inferTypes1.errors.txt @@ -124,7 +124,8 @@ tests/cases/conformance/types/conditional/inferTypes1.ts(78,44): error TS2344: T type T75 = T extends T74 ? T70 | T72 | T74 : never; type T76 = { x: T }; - type T77 = T extends T76 ? T76: never; + type T77 = T extends T76 ? T76 : never; + type T78 = T extends T76 ? T76 : never; // Example from #21496 diff --git a/tests/baselines/reference/inferTypes1.js b/tests/baselines/reference/inferTypes1.js index f916464f2fe..56bc71e5a71 100644 --- a/tests/baselines/reference/inferTypes1.js +++ b/tests/baselines/reference/inferTypes1.js @@ -82,7 +82,8 @@ type T74 = { x: T, y: U }; type T75 = T extends T74 ? T70 | T72 | T74 : never; type T76 = { x: T }; -type T77 = T extends T76 ? T76: never; +type T77 = T extends T76 ? T76 : never; +type T78 = T extends T76 ? T76 : never; // Example from #21496 diff --git a/tests/baselines/reference/inferTypes1.symbols b/tests/baselines/reference/inferTypes1.symbols index e3772e89f01..1e5468e2b8e 100644 --- a/tests/baselines/reference/inferTypes1.symbols +++ b/tests/baselines/reference/inferTypes1.symbols @@ -378,7 +378,7 @@ type T76 = { x: T }; >x : Symbol(x, Decl(inferTypes1.ts, 82, 40)) >T : Symbol(T, Decl(inferTypes1.ts, 82, 9)) -type T77 = T extends T76 ? T76: never; +type T77 = T extends T76 ? T76 : never; >T77 : Symbol(T77, Decl(inferTypes1.ts, 82, 48)) >T : Symbol(T, Decl(inferTypes1.ts, 83, 9)) >T : Symbol(T, Decl(inferTypes1.ts, 83, 9)) @@ -389,154 +389,165 @@ type T77 = T extends T76 ? T76: never; >X : Symbol(X, Decl(inferTypes1.ts, 83, 33)) >Y : Symbol(Y, Decl(inferTypes1.ts, 83, 42)) +type T78 = T extends T76 ? T76 : never; +>T78 : Symbol(T78, Decl(inferTypes1.ts, 83, 66)) +>T : Symbol(T, Decl(inferTypes1.ts, 84, 9)) +>T : Symbol(T, Decl(inferTypes1.ts, 84, 9)) +>T76 : Symbol(T76, Decl(inferTypes1.ts, 80, 84)) +>X : Symbol(X, Decl(inferTypes1.ts, 84, 33), Decl(inferTypes1.ts, 84, 42)) +>X : Symbol(X, Decl(inferTypes1.ts, 84, 33), Decl(inferTypes1.ts, 84, 42)) +>T76 : Symbol(T76, Decl(inferTypes1.ts, 80, 84)) +>X : Symbol(X, Decl(inferTypes1.ts, 84, 33), Decl(inferTypes1.ts, 84, 42)) +>X : Symbol(X, Decl(inferTypes1.ts, 84, 33), Decl(inferTypes1.ts, 84, 42)) + // Example from #21496 type JsonifiedObject = { [K in keyof T]: Jsonified }; ->JsonifiedObject : Symbol(JsonifiedObject, Decl(inferTypes1.ts, 83, 65)) ->T : Symbol(T, Decl(inferTypes1.ts, 87, 21)) ->K : Symbol(K, Decl(inferTypes1.ts, 87, 44)) ->T : Symbol(T, Decl(inferTypes1.ts, 87, 21)) ->Jsonified : Symbol(Jsonified, Decl(inferTypes1.ts, 87, 77)) ->T : Symbol(T, Decl(inferTypes1.ts, 87, 21)) ->K : Symbol(K, Decl(inferTypes1.ts, 87, 44)) +>JsonifiedObject : Symbol(JsonifiedObject, Decl(inferTypes1.ts, 84, 66)) +>T : Symbol(T, Decl(inferTypes1.ts, 88, 21)) +>K : Symbol(K, Decl(inferTypes1.ts, 88, 44)) +>T : Symbol(T, Decl(inferTypes1.ts, 88, 21)) +>Jsonified : Symbol(Jsonified, Decl(inferTypes1.ts, 88, 77)) +>T : Symbol(T, Decl(inferTypes1.ts, 88, 21)) +>K : Symbol(K, Decl(inferTypes1.ts, 88, 44)) type Jsonified = ->Jsonified : Symbol(Jsonified, Decl(inferTypes1.ts, 87, 77)) ->T : Symbol(T, Decl(inferTypes1.ts, 89, 15)) +>Jsonified : Symbol(Jsonified, Decl(inferTypes1.ts, 88, 77)) +>T : Symbol(T, Decl(inferTypes1.ts, 90, 15)) T extends string | number | boolean | null ? T ->T : Symbol(T, Decl(inferTypes1.ts, 89, 15)) ->T : Symbol(T, Decl(inferTypes1.ts, 89, 15)) +>T : Symbol(T, Decl(inferTypes1.ts, 90, 15)) +>T : Symbol(T, Decl(inferTypes1.ts, 90, 15)) : T extends undefined | Function ? never // undefined and functions are removed ->T : Symbol(T, Decl(inferTypes1.ts, 89, 15)) +>T : Symbol(T, Decl(inferTypes1.ts, 90, 15)) >Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) : T extends { toJSON(): infer R } ? R // toJSON is called if it exists (e.g. Date) ->T : Symbol(T, Decl(inferTypes1.ts, 89, 15)) ->toJSON : Symbol(toJSON, Decl(inferTypes1.ts, 92, 17)) ->R : Symbol(R, Decl(inferTypes1.ts, 92, 33)) ->R : Symbol(R, Decl(inferTypes1.ts, 92, 33)) +>T : Symbol(T, Decl(inferTypes1.ts, 90, 15)) +>toJSON : Symbol(toJSON, Decl(inferTypes1.ts, 93, 17)) +>R : Symbol(R, Decl(inferTypes1.ts, 93, 33)) +>R : Symbol(R, Decl(inferTypes1.ts, 93, 33)) : T extends object ? JsonifiedObject ->T : Symbol(T, Decl(inferTypes1.ts, 89, 15)) ->JsonifiedObject : Symbol(JsonifiedObject, Decl(inferTypes1.ts, 83, 65)) ->T : Symbol(T, Decl(inferTypes1.ts, 89, 15)) +>T : Symbol(T, Decl(inferTypes1.ts, 90, 15)) +>JsonifiedObject : Symbol(JsonifiedObject, Decl(inferTypes1.ts, 84, 66)) +>T : Symbol(T, Decl(inferTypes1.ts, 90, 15)) : "what is this"; type Example = { ->Example : Symbol(Example, Decl(inferTypes1.ts, 94, 21)) +>Example : Symbol(Example, Decl(inferTypes1.ts, 95, 21)) str: "literalstring", ->str : Symbol(str, Decl(inferTypes1.ts, 96, 16)) +>str : Symbol(str, Decl(inferTypes1.ts, 97, 16)) fn: () => void, ->fn : Symbol(fn, Decl(inferTypes1.ts, 97, 25)) +>fn : Symbol(fn, Decl(inferTypes1.ts, 98, 25)) date: Date, ->date : Symbol(date, Decl(inferTypes1.ts, 98, 19)) +>date : Symbol(date, Decl(inferTypes1.ts, 99, 19)) >Date : Symbol(Date, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) customClass: MyClass, ->customClass : Symbol(customClass, Decl(inferTypes1.ts, 99, 15)) ->MyClass : Symbol(MyClass, Decl(inferTypes1.ts, 106, 1)) +>customClass : Symbol(customClass, Decl(inferTypes1.ts, 100, 15)) +>MyClass : Symbol(MyClass, Decl(inferTypes1.ts, 107, 1)) obj: { ->obj : Symbol(obj, Decl(inferTypes1.ts, 100, 25)) +>obj : Symbol(obj, Decl(inferTypes1.ts, 101, 25)) prop: "property", ->prop : Symbol(prop, Decl(inferTypes1.ts, 101, 10)) +>prop : Symbol(prop, Decl(inferTypes1.ts, 102, 10)) clz: MyClass, ->clz : Symbol(clz, Decl(inferTypes1.ts, 102, 25)) ->MyClass : Symbol(MyClass, Decl(inferTypes1.ts, 106, 1)) +>clz : Symbol(clz, Decl(inferTypes1.ts, 103, 25)) +>MyClass : Symbol(MyClass, Decl(inferTypes1.ts, 107, 1)) nested: { attr: Date } ->nested : Symbol(nested, Decl(inferTypes1.ts, 103, 21)) ->attr : Symbol(attr, Decl(inferTypes1.ts, 104, 17)) +>nested : Symbol(nested, Decl(inferTypes1.ts, 104, 21)) +>attr : Symbol(attr, Decl(inferTypes1.ts, 105, 17)) >Date : Symbol(Date, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) }, } declare class MyClass { ->MyClass : Symbol(MyClass, Decl(inferTypes1.ts, 106, 1)) +>MyClass : Symbol(MyClass, Decl(inferTypes1.ts, 107, 1)) toJSON(): "correct"; ->toJSON : Symbol(MyClass.toJSON, Decl(inferTypes1.ts, 108, 23)) +>toJSON : Symbol(MyClass.toJSON, Decl(inferTypes1.ts, 109, 23)) } type JsonifiedExample = Jsonified; ->JsonifiedExample : Symbol(JsonifiedExample, Decl(inferTypes1.ts, 110, 1)) ->Jsonified : Symbol(Jsonified, Decl(inferTypes1.ts, 87, 77)) ->Example : Symbol(Example, Decl(inferTypes1.ts, 94, 21)) +>JsonifiedExample : Symbol(JsonifiedExample, Decl(inferTypes1.ts, 111, 1)) +>Jsonified : Symbol(Jsonified, Decl(inferTypes1.ts, 88, 77)) +>Example : Symbol(Example, Decl(inferTypes1.ts, 95, 21)) declare let ex: JsonifiedExample; ->ex : Symbol(ex, Decl(inferTypes1.ts, 113, 11)) ->JsonifiedExample : Symbol(JsonifiedExample, Decl(inferTypes1.ts, 110, 1)) +>ex : Symbol(ex, Decl(inferTypes1.ts, 114, 11)) +>JsonifiedExample : Symbol(JsonifiedExample, Decl(inferTypes1.ts, 111, 1)) const z1: "correct" = ex.customClass; ->z1 : Symbol(z1, Decl(inferTypes1.ts, 114, 5)) ->ex.customClass : Symbol(customClass, Decl(inferTypes1.ts, 99, 15)) ->ex : Symbol(ex, Decl(inferTypes1.ts, 113, 11)) ->customClass : Symbol(customClass, Decl(inferTypes1.ts, 99, 15)) +>z1 : Symbol(z1, Decl(inferTypes1.ts, 115, 5)) +>ex.customClass : Symbol(customClass, Decl(inferTypes1.ts, 100, 15)) +>ex : Symbol(ex, Decl(inferTypes1.ts, 114, 11)) +>customClass : Symbol(customClass, Decl(inferTypes1.ts, 100, 15)) const z2: string = ex.obj.nested.attr; ->z2 : Symbol(z2, Decl(inferTypes1.ts, 115, 5)) ->ex.obj.nested.attr : Symbol(attr, Decl(inferTypes1.ts, 104, 17)) ->ex.obj.nested : Symbol(nested, Decl(inferTypes1.ts, 103, 21)) ->ex.obj : Symbol(obj, Decl(inferTypes1.ts, 100, 25)) ->ex : Symbol(ex, Decl(inferTypes1.ts, 113, 11)) ->obj : Symbol(obj, Decl(inferTypes1.ts, 100, 25)) ->nested : Symbol(nested, Decl(inferTypes1.ts, 103, 21)) ->attr : Symbol(attr, Decl(inferTypes1.ts, 104, 17)) +>z2 : Symbol(z2, Decl(inferTypes1.ts, 116, 5)) +>ex.obj.nested.attr : Symbol(attr, Decl(inferTypes1.ts, 105, 17)) +>ex.obj.nested : Symbol(nested, Decl(inferTypes1.ts, 104, 21)) +>ex.obj : Symbol(obj, Decl(inferTypes1.ts, 101, 25)) +>ex : Symbol(ex, Decl(inferTypes1.ts, 114, 11)) +>obj : Symbol(obj, Decl(inferTypes1.ts, 101, 25)) +>nested : Symbol(nested, Decl(inferTypes1.ts, 104, 21)) +>attr : Symbol(attr, Decl(inferTypes1.ts, 105, 17)) // Repros from #21631 type A1> = [T, U]; ->A1 : Symbol(A1, Decl(inferTypes1.ts, 115, 38)) ->T : Symbol(T, Decl(inferTypes1.ts, 119, 8)) ->U : Symbol(U, Decl(inferTypes1.ts, 119, 10)) ->A1 : Symbol(A1, Decl(inferTypes1.ts, 115, 38)) ->T : Symbol(T, Decl(inferTypes1.ts, 119, 8)) ->U : Symbol(U, Decl(inferTypes1.ts, 119, 10)) +>A1 : Symbol(A1, Decl(inferTypes1.ts, 116, 38)) +>T : Symbol(T, Decl(inferTypes1.ts, 120, 8)) +>U : Symbol(U, Decl(inferTypes1.ts, 120, 10)) +>A1 : Symbol(A1, Decl(inferTypes1.ts, 116, 38)) +>T : Symbol(T, Decl(inferTypes1.ts, 120, 8)) +>U : Symbol(U, Decl(inferTypes1.ts, 120, 10)) type B1 = S extends A1 ? [T, U] : never; ->B1 : Symbol(B1, Decl(inferTypes1.ts, 119, 44)) ->S : Symbol(S, Decl(inferTypes1.ts, 120, 8)) ->S : Symbol(S, Decl(inferTypes1.ts, 120, 8)) ->A1 : Symbol(A1, Decl(inferTypes1.ts, 115, 38)) ->T : Symbol(T, Decl(inferTypes1.ts, 120, 31)) ->U : Symbol(U, Decl(inferTypes1.ts, 120, 40)) ->T : Symbol(T, Decl(inferTypes1.ts, 120, 31)) ->U : Symbol(U, Decl(inferTypes1.ts, 120, 40)) +>B1 : Symbol(B1, Decl(inferTypes1.ts, 120, 44)) +>S : Symbol(S, Decl(inferTypes1.ts, 121, 8)) +>S : Symbol(S, Decl(inferTypes1.ts, 121, 8)) +>A1 : Symbol(A1, Decl(inferTypes1.ts, 116, 38)) +>T : Symbol(T, Decl(inferTypes1.ts, 121, 31)) +>U : Symbol(U, Decl(inferTypes1.ts, 121, 40)) +>T : Symbol(T, Decl(inferTypes1.ts, 121, 31)) +>U : Symbol(U, Decl(inferTypes1.ts, 121, 40)) type A2 = [T, U]; ->A2 : Symbol(A2, Decl(inferTypes1.ts, 120, 61)) ->T : Symbol(T, Decl(inferTypes1.ts, 122, 8)) ->U : Symbol(U, Decl(inferTypes1.ts, 122, 10)) ->T : Symbol(T, Decl(inferTypes1.ts, 122, 8)) ->U : Symbol(U, Decl(inferTypes1.ts, 122, 10)) +>A2 : Symbol(A2, Decl(inferTypes1.ts, 121, 61)) +>T : Symbol(T, Decl(inferTypes1.ts, 123, 8)) +>U : Symbol(U, Decl(inferTypes1.ts, 123, 10)) +>T : Symbol(T, Decl(inferTypes1.ts, 123, 8)) +>U : Symbol(U, Decl(inferTypes1.ts, 123, 10)) type B2 = S extends A2 ? [T, U] : never; ->B2 : Symbol(B2, Decl(inferTypes1.ts, 122, 36)) ->S : Symbol(S, Decl(inferTypes1.ts, 123, 8)) ->S : Symbol(S, Decl(inferTypes1.ts, 123, 8)) ->A2 : Symbol(A2, Decl(inferTypes1.ts, 120, 61)) ->T : Symbol(T, Decl(inferTypes1.ts, 123, 31)) ->U : Symbol(U, Decl(inferTypes1.ts, 123, 40)) ->T : Symbol(T, Decl(inferTypes1.ts, 123, 31)) ->U : Symbol(U, Decl(inferTypes1.ts, 123, 40)) +>B2 : Symbol(B2, Decl(inferTypes1.ts, 123, 36)) +>S : Symbol(S, Decl(inferTypes1.ts, 124, 8)) +>S : Symbol(S, Decl(inferTypes1.ts, 124, 8)) +>A2 : Symbol(A2, Decl(inferTypes1.ts, 121, 61)) +>T : Symbol(T, Decl(inferTypes1.ts, 124, 31)) +>U : Symbol(U, Decl(inferTypes1.ts, 124, 40)) +>T : Symbol(T, Decl(inferTypes1.ts, 124, 31)) +>U : Symbol(U, Decl(inferTypes1.ts, 124, 40)) type C2 = S extends A2 ? [T, U] : never; ->C2 : Symbol(C2, Decl(inferTypes1.ts, 123, 61)) ->S : Symbol(S, Decl(inferTypes1.ts, 124, 8)) ->U : Symbol(U, Decl(inferTypes1.ts, 124, 10)) ->S : Symbol(S, Decl(inferTypes1.ts, 124, 8)) ->A2 : Symbol(A2, Decl(inferTypes1.ts, 120, 61)) ->T : Symbol(T, Decl(inferTypes1.ts, 124, 47)) ->U : Symbol(U, Decl(inferTypes1.ts, 124, 10)) ->T : Symbol(T, Decl(inferTypes1.ts, 124, 47)) ->U : Symbol(U, Decl(inferTypes1.ts, 124, 10)) +>C2 : Symbol(C2, Decl(inferTypes1.ts, 124, 61)) +>S : Symbol(S, Decl(inferTypes1.ts, 125, 8)) +>U : Symbol(U, Decl(inferTypes1.ts, 125, 10)) +>S : Symbol(S, Decl(inferTypes1.ts, 125, 8)) +>A2 : Symbol(A2, Decl(inferTypes1.ts, 121, 61)) +>T : Symbol(T, Decl(inferTypes1.ts, 125, 47)) +>U : Symbol(U, Decl(inferTypes1.ts, 125, 10)) +>T : Symbol(T, Decl(inferTypes1.ts, 125, 47)) +>U : Symbol(U, Decl(inferTypes1.ts, 125, 10)) diff --git a/tests/baselines/reference/inferTypes1.types b/tests/baselines/reference/inferTypes1.types index 4f050958773..ca60ea57d0e 100644 --- a/tests/baselines/reference/inferTypes1.types +++ b/tests/baselines/reference/inferTypes1.types @@ -384,7 +384,7 @@ type T76 = { x: T }; >x : T >T : T -type T77 = T extends T76 ? T76: never; +type T77 = T extends T76 ? T76 : never; >T77 : T77 >T : T >T : T @@ -395,6 +395,17 @@ type T77 = T extends T76 ? T76: never; >X : X >Y : Y +type T78 = T extends T76 ? T76 : never; +>T78 : T78 +>T : T +>T : T +>T76 : T76 +>X : X +>X : X +>T76 : T76 +>X : X +>X : X + // Example from #21496 type JsonifiedObject = { [K in keyof T]: Jsonified };