From 2f85af83a7b689468fc8a0fc4ac66d6a7df4323a Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 21 Aug 2018 16:17:21 -0700 Subject: [PATCH] Accept new baselines --- .../reference/infiniteConstraints.errors.txt | 10 +++++++++- .../baselines/reference/infiniteConstraints.js | 5 +++++ .../reference/infiniteConstraints.symbols | 18 ++++++++++++++++++ .../reference/infiniteConstraints.types | 8 ++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/tests/baselines/reference/infiniteConstraints.errors.txt b/tests/baselines/reference/infiniteConstraints.errors.txt index 108c3693783..387b0daac68 100644 --- a/tests/baselines/reference/infiniteConstraints.errors.txt +++ b/tests/baselines/reference/infiniteConstraints.errors.txt @@ -2,9 +2,10 @@ tests/cases/compiler/infiniteConstraints.ts(4,37): error TS2536: Type '"val"' ca tests/cases/compiler/infiniteConstraints.ts(31,42): error TS2345: Argument of type '{ main: Record<"val", "dup">; alternate: Record<"val", "dup">; }' is not assignable to parameter of type '{ main: never; alternate: never; }'. Types of property 'main' are incompatible. Type 'Record<"val", "dup">' is not assignable to type 'never'. +tests/cases/compiler/infiniteConstraints.ts(36,71): error TS2536: Type '"foo"' cannot be used to index type 'T[keyof T]'. -==== tests/cases/compiler/infiniteConstraints.ts (2 errors) ==== +==== tests/cases/compiler/infiniteConstraints.ts (3 errors) ==== // Both of the following types trigger the recursion limiter in getImmediateBaseConstraint type T1], { val: string }>["val"] }> = B; @@ -42,4 +43,11 @@ tests/cases/compiler/infiniteConstraints.ts(31,42): error TS2345: Argument of ty !!! error TS2345: Argument of type '{ main: Record<"val", "dup">; alternate: Record<"val", "dup">; }' is not assignable to parameter of type '{ main: never; alternate: never; }'. !!! error TS2345: Types of property 'main' are incompatible. !!! error TS2345: Type 'Record<"val", "dup">' is not assignable to type 'never'. + + // Repro from #26448 + + type Cond = T extends number ? number : never; + declare function function1}>(): T[keyof T]["foo"]; + ~~~~~~~~~~~~~~~~~ +!!! error TS2536: Type '"foo"' cannot be used to index type 'T[keyof T]'. \ No newline at end of file diff --git a/tests/baselines/reference/infiniteConstraints.js b/tests/baselines/reference/infiniteConstraints.js index 0ad3b676f14..03a4d70e00c 100644 --- a/tests/baselines/reference/infiniteConstraints.js +++ b/tests/baselines/reference/infiniteConstraints.js @@ -30,6 +30,11 @@ const noError = ensureNoDuplicates({main: value("test"), alternate: value("test2 const shouldBeNoError = ensureNoDuplicates({main: value("test")}); const shouldBeError = ensureNoDuplicates({main: value("dup"), alternate: value("dup")}); + +// Repro from #26448 + +type Cond = T extends number ? number : never; +declare function function1}>(): T[keyof T]["foo"]; //// [infiniteConstraints.js] diff --git a/tests/baselines/reference/infiniteConstraints.symbols b/tests/baselines/reference/infiniteConstraints.symbols index 0f0d44c9f53..6306203a7e0 100644 --- a/tests/baselines/reference/infiniteConstraints.symbols +++ b/tests/baselines/reference/infiniteConstraints.symbols @@ -120,3 +120,21 @@ const shouldBeError = ensureNoDuplicates({main: value("dup"), alternate: value(" >alternate : Symbol(alternate, Decl(infiniteConstraints.ts, 30, 61)) >value : Symbol(value, Decl(infiniteConstraints.ts, 15, 57)) +// Repro from #26448 + +type Cond = T extends number ? number : never; +>Cond : Symbol(Cond, Decl(infiniteConstraints.ts, 30, 88)) +>T : Symbol(T, Decl(infiniteConstraints.ts, 34, 10)) +>T : Symbol(T, Decl(infiniteConstraints.ts, 34, 10)) + +declare function function1}>(): T[keyof T]["foo"]; +>function1 : Symbol(function1, Decl(infiniteConstraints.ts, 34, 49)) +>T : Symbol(T, Decl(infiniteConstraints.ts, 35, 27)) +>K : Symbol(K, Decl(infiniteConstraints.ts, 35, 39)) +>T : Symbol(T, Decl(infiniteConstraints.ts, 35, 27)) +>Cond : Symbol(Cond, Decl(infiniteConstraints.ts, 30, 88)) +>T : Symbol(T, Decl(infiniteConstraints.ts, 35, 27)) +>K : Symbol(K, Decl(infiniteConstraints.ts, 35, 39)) +>T : Symbol(T, Decl(infiniteConstraints.ts, 35, 27)) +>T : Symbol(T, Decl(infiniteConstraints.ts, 35, 27)) + diff --git a/tests/baselines/reference/infiniteConstraints.types b/tests/baselines/reference/infiniteConstraints.types index 78fbc9becaa..e23e138c820 100644 --- a/tests/baselines/reference/infiniteConstraints.types +++ b/tests/baselines/reference/infiniteConstraints.types @@ -87,3 +87,11 @@ const shouldBeError = ensureNoDuplicates({main: value("dup"), alternate: value(" >value : (val: V) => Record<"val", V> >"dup" : "dup" +// Repro from #26448 + +type Cond = T extends number ? number : never; +>Cond : Cond + +declare function function1}>(): T[keyof T]["foo"]; +>function1 : ; }>() => T[keyof T]["foo"] +