Accept new baselines

This commit is contained in:
Anders Hejlsberg 2018-08-21 16:17:21 -07:00
parent db9c202b64
commit 2f85af83a7
4 changed files with 40 additions and 1 deletions

View file

@ -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<B extends { [K in keyof B]: Extract<B[Exclude<keyof B, K>], { 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> = T extends number ? number : never;
declare function function1<T extends {[K in keyof T]: Cond<T[K]>}>(): T[keyof T]["foo"];
~~~~~~~~~~~~~~~~~
!!! error TS2536: Type '"foo"' cannot be used to index type 'T[keyof T]'.

View file

@ -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> = T extends number ? number : never;
declare function function1<T extends {[K in keyof T]: Cond<T[K]>}>(): T[keyof T]["foo"];
//// [infiniteConstraints.js]

View file

@ -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> = 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 extends {[K in keyof T]: Cond<T[K]>}>(): 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))

View file

@ -87,3 +87,11 @@ const shouldBeError = ensureNoDuplicates({main: value("dup"), alternate: value("
>value : <V extends string>(val: V) => Record<"val", V>
>"dup" : "dup"
// Repro from #26448
type Cond<T> = T extends number ? number : never;
>Cond : Cond<T>
declare function function1<T extends {[K in keyof T]: Cond<T[K]>}>(): T[keyof T]["foo"];
>function1 : <T extends { [K in keyof T]: Cond<T[K]>; }>() => T[keyof T]["foo"]