From e79e0bd3e79644d09efd7b0f92b94eef479c77da Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 2 Apr 2019 15:22:45 -0700 Subject: [PATCH] Accept new baselines --- .../indexSignatureAndMappedType.errors.txt | 5 +-- .../reference/infiniteConstraints.errors.txt | 5 +-- .../reference/mappedTypeErrors2.errors.txt | 5 ++- .../mappedTypeRelationships.errors.txt | 38 +++++++++++++++---- .../reference/mappedTypes6.errors.txt | 6 +++ ...tiveConstraintOfIndexAccessType.errors.txt | 6 +-- 6 files changed, 44 insertions(+), 21 deletions(-) diff --git a/tests/baselines/reference/indexSignatureAndMappedType.errors.txt b/tests/baselines/reference/indexSignatureAndMappedType.errors.txt index 623fcd11bd0..9fbf139a172 100644 --- a/tests/baselines/reference/indexSignatureAndMappedType.errors.txt +++ b/tests/baselines/reference/indexSignatureAndMappedType.errors.txt @@ -1,18 +1,15 @@ -tests/cases/compiler/indexSignatureAndMappedType.ts(6,5): error TS2322: Type '{ [key: string]: T; }' is not assignable to type 'Record'. tests/cases/compiler/indexSignatureAndMappedType.ts(15,5): error TS2322: Type 'Record' is not assignable to type '{ [key: string]: T; }'. Type 'U' is not assignable to type 'T'. tests/cases/compiler/indexSignatureAndMappedType.ts(16,5): error TS2322: Type '{ [key: string]: T; }' is not assignable to type 'Record'. -==== tests/cases/compiler/indexSignatureAndMappedType.ts (3 errors) ==== +==== tests/cases/compiler/indexSignatureAndMappedType.ts (2 errors) ==== // A mapped type { [P in K]: X }, where K is a generic type, is related to // { [key: string]: Y } if X is related to Y. function f1(x: { [key: string]: T }, y: Record) { x = y; y = x; // Error - ~ -!!! error TS2322: Type '{ [key: string]: T; }' is not assignable to type 'Record'. } function f2(x: { [key: string]: T }, y: Record) { diff --git a/tests/baselines/reference/infiniteConstraints.errors.txt b/tests/baselines/reference/infiniteConstraints.errors.txt index 414fa8f9213..a49aa5e366b 100644 --- a/tests/baselines/reference/infiniteConstraints.errors.txt +++ b/tests/baselines/reference/infiniteConstraints.errors.txt @@ -1,4 +1,3 @@ -tests/cases/compiler/infiniteConstraints.ts(3,37): error TS2589: Type instantiation is excessively deep and possibly infinite. tests/cases/compiler/infiniteConstraints.ts(4,37): error TS2536: Type '"val"' cannot be used to index type 'B[Exclude]'. tests/cases/compiler/infiniteConstraints.ts(21,21): error TS2536: Type '"val"' cannot be used to index type 'Extract>'. tests/cases/compiler/infiniteConstraints.ts(21,57): error TS2536: Type '"val"' cannot be used to index type 'Extract], Record<"val", string>>'. @@ -7,12 +6,10 @@ tests/cases/compiler/infiniteConstraints.ts(31,63): error TS2322: Type 'Record<" 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 (7 errors) ==== +==== tests/cases/compiler/infiniteConstraints.ts (6 errors) ==== // Both of the following types trigger the recursion limiter in getImmediateBaseConstraint type T1], { val: string }>["val"] }> = B; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2589: Type instantiation is excessively deep and possibly infinite. type T2]["val"] }> = B; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2536: Type '"val"' cannot be used to index type 'B[Exclude]'. diff --git a/tests/baselines/reference/mappedTypeErrors2.errors.txt b/tests/baselines/reference/mappedTypeErrors2.errors.txt index 7cf73fbd030..9178731d189 100644 --- a/tests/baselines/reference/mappedTypeErrors2.errors.txt +++ b/tests/baselines/reference/mappedTypeErrors2.errors.txt @@ -1,12 +1,13 @@ tests/cases/conformance/types/mapped/mappedTypeErrors2.ts(9,30): error TS2536: Type 'K' cannot be used to index type 'T1'. tests/cases/conformance/types/mapped/mappedTypeErrors2.ts(13,30): error TS2536: Type 'K' cannot be used to index type 'T3'. +tests/cases/conformance/types/mapped/mappedTypeErrors2.ts(15,38): error TS2536: Type 'S' cannot be used to index type '{ [key in AB[S]]: true; }'. tests/cases/conformance/types/mapped/mappedTypeErrors2.ts(15,47): error TS2322: Type 'AB[S]' is not assignable to type 'string | number | symbol'. Type 'AB[S]' is not assignable to type 'symbol'. tests/cases/conformance/types/mapped/mappedTypeErrors2.ts(15,47): error TS2536: Type 'S' cannot be used to index type 'AB'. tests/cases/conformance/types/mapped/mappedTypeErrors2.ts(17,49): error TS2536: Type 'L' cannot be used to index type '{ [key in AB[S]]: true; }'. -==== tests/cases/conformance/types/mapped/mappedTypeErrors2.ts (5 errors) ==== +==== tests/cases/conformance/types/mapped/mappedTypeErrors2.ts (6 errors) ==== // Repros from #17238 type AB = { @@ -26,6 +27,8 @@ tests/cases/conformance/types/mapped/mappedTypeErrors2.ts(17,49): error TS2536: !!! error TS2536: Type 'K' cannot be used to index type 'T3'. type T5 = {[key in AB[S]]: true}[S]; // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2536: Type 'S' cannot be used to index type '{ [key in AB[S]]: true; }'. ~~~~~ !!! error TS2322: Type 'AB[S]' is not assignable to type 'string | number | symbol'. !!! error TS2322: Type 'AB[S]' is not assignable to type 'symbol'. diff --git a/tests/baselines/reference/mappedTypeRelationships.errors.txt b/tests/baselines/reference/mappedTypeRelationships.errors.txt index 838e11b01d9..d66312c0f17 100644 --- a/tests/baselines/reference/mappedTypeRelationships.errors.txt +++ b/tests/baselines/reference/mappedTypeRelationships.errors.txt @@ -13,13 +13,24 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(35,5): error TS2 tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(40,5): error TS2322: Type 'U[keyof T] | undefined' is not assignable to type 'T[keyof T]'. Type 'undefined' is not assignable to type 'T[keyof T]'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(41,5): error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T] | undefined'. - Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. - Type 'T' is not assignable to type 'U'. + Type 'T[string] | T[number] | T[symbol]' is not assignable to type 'U[keyof T] | undefined'. + Type 'T[string]' is not assignable to type 'U[keyof T] | undefined'. + Type 'T[string]' is not assignable to type 'U[keyof T]'. + Type 'T' is not assignable to type 'U'. + Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. + Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(45,5): error TS2322: Type 'U[K] | undefined' is not assignable to type 'T[K]'. Type 'undefined' is not assignable to type 'T[K]'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(46,5): error TS2322: Type 'T[K]' is not assignable to type 'U[K] | undefined'. - Type 'T[K]' is not assignable to type 'U[K]'. - Type 'T' is not assignable to type 'U'. + Type 'T[keyof T]' is not assignable to type 'U[K] | undefined'. + Type 'T[string] | T[number] | T[symbol]' is not assignable to type 'U[K] | undefined'. + Type 'T[string]' is not assignable to type 'U[K] | undefined'. + Type 'T[string]' is not assignable to type 'U[K]'. + Type 'T' is not assignable to type 'U'. + Type 'T[keyof T]' is not assignable to type 'U[K]'. + Type 'T' is not assignable to type 'U'. + Type 'T[K]' is not assignable to type 'U[K]'. + Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(51,5): error TS2542: Index signature in type 'Readonly' only permits reading. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(56,5): error TS2542: Index signature in type 'Readonly' only permits reading. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(61,5): error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. @@ -123,8 +134,12 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS y[k] = x[k]; // Error ~~~~ !!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T] | undefined'. -!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[string] | T[number] | T[symbol]' is not assignable to type 'U[keyof T] | undefined'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T] | undefined'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. } function f13(x: T, y: Partial, k: K) { @@ -135,8 +150,15 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS y[k] = x[k]; // Error ~~~~ !!! error TS2322: Type 'T[K]' is not assignable to type 'U[K] | undefined'. -!!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[K] | undefined'. +!!! error TS2322: Type 'T[string] | T[number] | T[symbol]' is not assignable to type 'U[K] | undefined'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K] | undefined'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[K]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. } function f20(x: T, y: Readonly, k: keyof T) { diff --git a/tests/baselines/reference/mappedTypes6.errors.txt b/tests/baselines/reference/mappedTypes6.errors.txt index cbe4c58d27e..3c5c8eac2ed 100644 --- a/tests/baselines/reference/mappedTypes6.errors.txt +++ b/tests/baselines/reference/mappedTypes6.errors.txt @@ -3,6 +3,9 @@ tests/cases/conformance/types/mapped/mappedTypes6.ts(24,5): error TS2322: Type ' tests/cases/conformance/types/mapped/mappedTypes6.ts(27,5): error TS2322: Type 'Partial' is not assignable to type 'T'. tests/cases/conformance/types/mapped/mappedTypes6.ts(37,5): error TS2322: Type 'Required' is not assignable to type 'Denullified'. Type 'T[P]' is not assignable to type 'NonNullable'. + Type 'T[keyof T]' is not assignable to type 'NonNullable'. + Type 'T[string] | T[number] | T[symbol]' is not assignable to type 'NonNullable'. + Type 'T[string]' is not assignable to type 'NonNullable'. tests/cases/conformance/types/mapped/mappedTypes6.ts(38,5): error TS2322: Type 'T' is not assignable to type 'Denullified'. tests/cases/conformance/types/mapped/mappedTypes6.ts(39,5): error TS2322: Type 'Partial' is not assignable to type 'Denullified'. tests/cases/conformance/types/mapped/mappedTypes6.ts(42,5): error TS2322: Type 'T' is not assignable to type 'Required'. @@ -67,6 +70,9 @@ tests/cases/conformance/types/mapped/mappedTypes6.ts(120,4): error TS2540: Canno ~ !!! error TS2322: Type 'Required' is not assignable to type 'Denullified'. !!! error TS2322: Type 'T[P]' is not assignable to type 'NonNullable'. +!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'NonNullable'. +!!! error TS2322: Type 'T[string] | T[number] | T[symbol]' is not assignable to type 'NonNullable'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'NonNullable'. w = y; // Error ~ !!! error TS2322: Type 'T' is not assignable to type 'Denullified'. diff --git a/tests/baselines/reference/nonPrimitiveConstraintOfIndexAccessType.errors.txt b/tests/baselines/reference/nonPrimitiveConstraintOfIndexAccessType.errors.txt index 6cf3c0196a1..a69a3d29b45 100644 --- a/tests/baselines/reference/nonPrimitiveConstraintOfIndexAccessType.errors.txt +++ b/tests/baselines/reference/nonPrimitiveConstraintOfIndexAccessType.errors.txt @@ -9,8 +9,7 @@ tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessTy Type 'string' is not assignable to type '(radix?: number | undefined) => string'. tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts(21,5): error TS2322: Type 'string' is not assignable to type 'T[P]'. Type 'string' is not assignable to type 'T[number] & T["toString"] & T["valueOf"] & T["charAt"] & T["charCodeAt"] & T["concat"] & T["indexOf"] & T["lastIndexOf"] & T["localeCompare"] & T["match"] & T["replace"] & T["search"] & T["slice"] & T["split"] & T["substring"] & T["toLowerCase"] & T["toLocaleLowerCase"] & T["toUpperCase"] & T["toLocaleUpperCase"] & T["trim"] & T["length"] & T["substr"]'. - Type 'string' is not assignable to type 'T["toString"]'. - Type 'string' is not assignable to type '() => string'. + Type 'string' is not assignable to type 'T[number]'. tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts(24,5): error TS2322: Type 'string' is not assignable to type 'T[P]'. tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts(27,5): error TS2322: Type 'string' is not assignable to type 'T[P]'. Type 'string' is not assignable to type 'T["a"]'. @@ -61,8 +60,7 @@ tests/cases/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessTy ~~ !!! error TS2322: Type 'string' is not assignable to type 'T[P]'. !!! error TS2322: Type 'string' is not assignable to type 'T[number] & T["toString"] & T["valueOf"] & T["charAt"] & T["charCodeAt"] & T["concat"] & T["indexOf"] & T["lastIndexOf"] & T["localeCompare"] & T["match"] & T["replace"] & T["search"] & T["slice"] & T["split"] & T["substring"] & T["toLowerCase"] & T["toLocaleLowerCase"] & T["toUpperCase"] & T["toLocaleUpperCase"] & T["trim"] & T["length"] & T["substr"]'. -!!! error TS2322: Type 'string' is not assignable to type 'T["toString"]'. -!!! error TS2322: Type 'string' is not assignable to type '() => string'. +!!! error TS2322: Type 'string' is not assignable to type 'T[number]'. } function l(s: string, tp: T[P]): void { tp = s;