From c73affdbc236c57007ae5ba486778dde64743fc2 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 21 Nov 2019 09:11:40 -0800 Subject: [PATCH 1/7] Normalize type references before relating them in isRelatedTo --- src/compiler/checker.ts | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e7befc3a4dce0..8f96efa7f3962 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14240,6 +14240,14 @@ namespace ts { return getObjectFlags(source) & ObjectFlags.JsxAttributes && !isUnhyphenatedJsxName(sourceProp.escapedName); } + function getNormalizedType(type: Type, writing: boolean): Type { + return isFreshLiteralType(type) ? (type).regularType : + getObjectFlags(type) & ObjectFlags.Reference && (type).node ? createTypeReference((type).target, getTypeArguments(type)) : + type.flags & TypeFlags.Substitution ? writing ? (type).typeVariable : (type).substitute : + type.flags & TypeFlags.Simplifiable ? getSimplifiedType(type, writing) : + type; + } + /** * Checks if 'source' is related to 'target' (e.g.: is a assignable to). * @param source The left-hand-side of the relation. @@ -14546,24 +14554,8 @@ namespace ts { * * Ternary.False if they are not related. */ function isRelatedTo(source: Type, target: Type, reportErrors = false, headMessage?: DiagnosticMessage, isApparentIntersectionConstituent?: boolean): Ternary { - if (isFreshLiteralType(source)) { - source = (source).regularType; - } - if (isFreshLiteralType(target)) { - target = (target).regularType; - } - if (source.flags & TypeFlags.Substitution) { - source = (source).substitute; - } - if (target.flags & TypeFlags.Substitution) { - target = (target).typeVariable; - } - if (source.flags & TypeFlags.Simplifiable) { - source = getSimplifiedType(source, /*writing*/ false); - } - if (target.flags & TypeFlags.Simplifiable) { - target = getSimplifiedType(target, /*writing*/ true); - } + source = getNormalizedType(source, /*writing*/ false); + target = getNormalizedType(target, /*writing*/ true); // Try to see if we're relating something like `Foo` -> `Bar | null | undefined`. // If so, reporting the `null` and `undefined` in the type is hardly useful. From b1cb35a9cb2d78986041d6449859b81c49187480 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 21 Nov 2019 11:13:40 -0800 Subject: [PATCH 2/7] Add comments --- src/compiler/checker.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8f96efa7f3962..bf05a1e22500b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14554,6 +14554,10 @@ namespace ts { * * Ternary.False if they are not related. */ function isRelatedTo(source: Type, target: Type, reportErrors = false, headMessage?: DiagnosticMessage, isApparentIntersectionConstituent?: boolean): Ternary { + // Normalize the source and target types: Turn fresh literal types into regular literal types, + // turn deferred type references into regular type references, simplify indexed access and + // conditional types, and resolve substitution types to either the substitution (on the source + // side) or the type variable (on the target side). source = getNormalizedType(source, /*writing*/ false); target = getNormalizedType(target, /*writing*/ true); From 99bcfb3e868c04fd53de04505328bb1642c7fa46 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 21 Nov 2019 11:14:40 -0800 Subject: [PATCH 3/7] Accept new baselines --- .../optionalTupleElements1.errors.txt | 24 +++++++++---------- .../recursiveTypeReferences1.errors.txt | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/baselines/reference/optionalTupleElements1.errors.txt b/tests/baselines/reference/optionalTupleElements1.errors.txt index bb5fd2c01d8cb..ac9f5f244da2d 100644 --- a/tests/baselines/reference/optionalTupleElements1.errors.txt +++ b/tests/baselines/reference/optionalTupleElements1.errors.txt @@ -1,25 +1,25 @@ tests/cases/conformance/types/tuple/optionalTupleElements1.ts(11,29): error TS1257: A required element cannot follow an optional element. -tests/cases/conformance/types/tuple/optionalTupleElements1.ts(15,5): error TS2322: Type 'T2' is not assignable to type 'T1'. +tests/cases/conformance/types/tuple/optionalTupleElements1.ts(15,5): error TS2322: Type '[number, string, (boolean | undefined)?]' is not assignable to type '[number, string, boolean]'. Types of property '2' are incompatible. Type 'boolean | undefined' is not assignable to type 'boolean'. Type 'undefined' is not assignable to type 'boolean'. -tests/cases/conformance/types/tuple/optionalTupleElements1.ts(16,5): error TS2322: Type 'T3' is not assignable to type 'T1'. +tests/cases/conformance/types/tuple/optionalTupleElements1.ts(16,5): error TS2322: Type '[number, (string | undefined)?, (boolean | undefined)?]' is not assignable to type '[number, string, boolean]'. Types of property '1' are incompatible. Type 'string | undefined' is not assignable to type 'string'. Type 'undefined' is not assignable to type 'string'. -tests/cases/conformance/types/tuple/optionalTupleElements1.ts(17,5): error TS2322: Type 'T4' is not assignable to type 'T1'. +tests/cases/conformance/types/tuple/optionalTupleElements1.ts(17,5): error TS2322: Type '[(number | undefined)?, (string | undefined)?, (boolean | undefined)?]' is not assignable to type '[number, string, boolean]'. Types of property '0' are incompatible. Type 'number | undefined' is not assignable to type 'number'. Type 'undefined' is not assignable to type 'number'. -tests/cases/conformance/types/tuple/optionalTupleElements1.ts(20,5): error TS2322: Type 'T3' is not assignable to type 'T2'. +tests/cases/conformance/types/tuple/optionalTupleElements1.ts(20,5): error TS2322: Type '[number, (string | undefined)?, (boolean | undefined)?]' is not assignable to type '[number, string, (boolean | undefined)?]'. Types of property '1' are incompatible. Type 'string | undefined' is not assignable to type 'string'. Type 'undefined' is not assignable to type 'string'. -tests/cases/conformance/types/tuple/optionalTupleElements1.ts(21,5): error TS2322: Type 'T4' is not assignable to type 'T2'. +tests/cases/conformance/types/tuple/optionalTupleElements1.ts(21,5): error TS2322: Type '[(number | undefined)?, (string | undefined)?, (boolean | undefined)?]' is not assignable to type '[number, string, (boolean | undefined)?]'. Types of property '0' are incompatible. Type 'number | undefined' is not assignable to type 'number'. Type 'undefined' is not assignable to type 'number'. -tests/cases/conformance/types/tuple/optionalTupleElements1.ts(25,5): error TS2322: Type 'T4' is not assignable to type 'T3'. +tests/cases/conformance/types/tuple/optionalTupleElements1.ts(25,5): error TS2322: Type '[(number | undefined)?, (string | undefined)?, (boolean | undefined)?]' is not assignable to type '[number, (string | undefined)?, (boolean | undefined)?]'. Types of property '0' are incompatible. Type 'number | undefined' is not assignable to type 'number'. Type 'undefined' is not assignable to type 'number'. @@ -44,19 +44,19 @@ tests/cases/conformance/types/tuple/optionalTupleElements1.ts(25,5): error TS232 t1 = t1; t1 = t2; // Error ~~ -!!! error TS2322: Type 'T2' is not assignable to type 'T1'. +!!! error TS2322: Type '[number, string, (boolean | undefined)?]' is not assignable to type '[number, string, boolean]'. !!! error TS2322: Types of property '2' are incompatible. !!! error TS2322: Type 'boolean | undefined' is not assignable to type 'boolean'. !!! error TS2322: Type 'undefined' is not assignable to type 'boolean'. t1 = t3; // Error ~~ -!!! error TS2322: Type 'T3' is not assignable to type 'T1'. +!!! error TS2322: Type '[number, (string | undefined)?, (boolean | undefined)?]' is not assignable to type '[number, string, boolean]'. !!! error TS2322: Types of property '1' are incompatible. !!! error TS2322: Type 'string | undefined' is not assignable to type 'string'. !!! error TS2322: Type 'undefined' is not assignable to type 'string'. t1 = t4; // Error ~~ -!!! error TS2322: Type 'T4' is not assignable to type 'T1'. +!!! error TS2322: Type '[(number | undefined)?, (string | undefined)?, (boolean | undefined)?]' is not assignable to type '[number, string, boolean]'. !!! error TS2322: Types of property '0' are incompatible. !!! error TS2322: Type 'number | undefined' is not assignable to type 'number'. !!! error TS2322: Type 'undefined' is not assignable to type 'number'. @@ -64,13 +64,13 @@ tests/cases/conformance/types/tuple/optionalTupleElements1.ts(25,5): error TS232 t2 = t2; t2 = t3; // Error ~~ -!!! error TS2322: Type 'T3' is not assignable to type 'T2'. +!!! error TS2322: Type '[number, (string | undefined)?, (boolean | undefined)?]' is not assignable to type '[number, string, (boolean | undefined)?]'. !!! error TS2322: Types of property '1' are incompatible. !!! error TS2322: Type 'string | undefined' is not assignable to type 'string'. !!! error TS2322: Type 'undefined' is not assignable to type 'string'. t2 = t4; // Error ~~ -!!! error TS2322: Type 'T4' is not assignable to type 'T2'. +!!! error TS2322: Type '[(number | undefined)?, (string | undefined)?, (boolean | undefined)?]' is not assignable to type '[number, string, (boolean | undefined)?]'. !!! error TS2322: Types of property '0' are incompatible. !!! error TS2322: Type 'number | undefined' is not assignable to type 'number'. !!! error TS2322: Type 'undefined' is not assignable to type 'number'. @@ -79,7 +79,7 @@ tests/cases/conformance/types/tuple/optionalTupleElements1.ts(25,5): error TS232 t3 = t3; t3 = t4; // Error ~~ -!!! error TS2322: Type 'T4' is not assignable to type 'T3'. +!!! error TS2322: Type '[(number | undefined)?, (string | undefined)?, (boolean | undefined)?]' is not assignable to type '[number, (string | undefined)?, (boolean | undefined)?]'. !!! error TS2322: Types of property '0' are incompatible. !!! error TS2322: Type 'number | undefined' is not assignable to type 'number'. !!! error TS2322: Type 'undefined' is not assignable to type 'number'. diff --git a/tests/baselines/reference/recursiveTypeReferences1.errors.txt b/tests/baselines/reference/recursiveTypeReferences1.errors.txt index b3ab2e9b8663e..6aca2422af8b7 100644 --- a/tests/baselines/reference/recursiveTypeReferences1.errors.txt +++ b/tests/baselines/reference/recursiveTypeReferences1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/types/typeRelationships/recursiveTypes/recursiveTypeReferences1.ts(45,7): error TS2322: Type '42' is not assignable to type 'Box2'. +tests/cases/conformance/types/typeRelationships/recursiveTypes/recursiveTypeReferences1.ts(45,7): error TS2322: Type '42' is not assignable to type 'Box'. tests/cases/conformance/types/typeRelationships/recursiveTypes/recursiveTypeReferences1.ts(60,7): error TS2322: Type 'number' is not assignable to type 'string | RecArray'. tests/cases/conformance/types/typeRelationships/recursiveTypes/recursiveTypeReferences1.ts(66,8): error TS2322: Type 'number' is not assignable to type 'string | string[]'. tests/cases/conformance/types/typeRelationships/recursiveTypes/recursiveTypeReferences1.ts(72,8): error TS2322: Type 'number' is not assignable to type 'string | (string | string[])[]'. @@ -60,7 +60,7 @@ tests/cases/conformance/types/typeRelationships/recursiveTypes/recursiveTypeRefe const b20: Box2 = 42; // Error ~~~ -!!! error TS2322: Type '42' is not assignable to type 'Box2'. +!!! error TS2322: Type '42' is not assignable to type 'Box'. const b21: Box2 = { value: 42 }; const b22: Box2 = { value: { value: { value: 42 }}}; From 2e432ecc72d9d66448870cf197304f35a90cd772 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 21 Nov 2019 11:22:57 -0800 Subject: [PATCH 4/7] Add regression tests --- .../unwitnessedTypeParameterVariance.ts | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/cases/compiler/unwitnessedTypeParameterVariance.ts diff --git a/tests/cases/compiler/unwitnessedTypeParameterVariance.ts b/tests/cases/compiler/unwitnessedTypeParameterVariance.ts new file mode 100644 index 0000000000000..0be2accdc3e3c --- /dev/null +++ b/tests/cases/compiler/unwitnessedTypeParameterVariance.ts @@ -0,0 +1,25 @@ +// @strict: true + +// Repros from #33872 + +export interface CalcObj { + read: (origin: O) => CalcValue; +} + +export type CalcValue = CalcObj; + +function foo() { + const unk: CalcObj = { read: (origin: unknown) => unk } + const x: CalcObj = unk; +} + +type A = B; + +interface B { + prop: A; +} + +declare let a: A; +declare let b: A<3>; + +b = a; From 0d99ec1be7cc27d05fcd28bbbdad0662c0206ea7 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 21 Nov 2019 11:23:06 -0800 Subject: [PATCH 5/7] Accept new baselines --- .../unwitnessedTypeParameterVariance.js | 35 ++++++++++ .../unwitnessedTypeParameterVariance.symbols | 67 +++++++++++++++++++ .../unwitnessedTypeParameterVariance.types | 47 +++++++++++++ 3 files changed, 149 insertions(+) create mode 100644 tests/baselines/reference/unwitnessedTypeParameterVariance.js create mode 100644 tests/baselines/reference/unwitnessedTypeParameterVariance.symbols create mode 100644 tests/baselines/reference/unwitnessedTypeParameterVariance.types diff --git a/tests/baselines/reference/unwitnessedTypeParameterVariance.js b/tests/baselines/reference/unwitnessedTypeParameterVariance.js new file mode 100644 index 0000000000000..b5e4e1066395c --- /dev/null +++ b/tests/baselines/reference/unwitnessedTypeParameterVariance.js @@ -0,0 +1,35 @@ +//// [unwitnessedTypeParameterVariance.ts] +// Repros from #33872 + +export interface CalcObj { + read: (origin: O) => CalcValue; +} + +export type CalcValue = CalcObj; + +function foo() { + const unk: CalcObj = { read: (origin: unknown) => unk } + const x: CalcObj = unk; +} + +type A = B; + +interface B { + prop: A; +} + +declare let a: A; +declare let b: A<3>; + +b = a; + + +//// [unwitnessedTypeParameterVariance.js] +"use strict"; +// Repros from #33872 +exports.__esModule = true; +function foo() { + var unk = { read: function (origin) { return unk; } }; + var x = unk; +} +b = a; diff --git a/tests/baselines/reference/unwitnessedTypeParameterVariance.symbols b/tests/baselines/reference/unwitnessedTypeParameterVariance.symbols new file mode 100644 index 0000000000000..d63b2f1924992 --- /dev/null +++ b/tests/baselines/reference/unwitnessedTypeParameterVariance.symbols @@ -0,0 +1,67 @@ +=== tests/cases/compiler/unwitnessedTypeParameterVariance.ts === +// Repros from #33872 + +export interface CalcObj { +>CalcObj : Symbol(CalcObj, Decl(unwitnessedTypeParameterVariance.ts, 0, 0)) +>O : Symbol(O, Decl(unwitnessedTypeParameterVariance.ts, 2, 25)) + + read: (origin: O) => CalcValue; +>read : Symbol(CalcObj.read, Decl(unwitnessedTypeParameterVariance.ts, 2, 29)) +>origin : Symbol(origin, Decl(unwitnessedTypeParameterVariance.ts, 3, 11)) +>O : Symbol(O, Decl(unwitnessedTypeParameterVariance.ts, 2, 25)) +>CalcValue : Symbol(CalcValue, Decl(unwitnessedTypeParameterVariance.ts, 4, 1)) +>O : Symbol(O, Decl(unwitnessedTypeParameterVariance.ts, 2, 25)) +} + +export type CalcValue = CalcObj; +>CalcValue : Symbol(CalcValue, Decl(unwitnessedTypeParameterVariance.ts, 4, 1)) +>O : Symbol(O, Decl(unwitnessedTypeParameterVariance.ts, 6, 22)) +>CalcObj : Symbol(CalcObj, Decl(unwitnessedTypeParameterVariance.ts, 0, 0)) +>O : Symbol(O, Decl(unwitnessedTypeParameterVariance.ts, 6, 22)) + +function foo() { +>foo : Symbol(foo, Decl(unwitnessedTypeParameterVariance.ts, 6, 38)) +>O : Symbol(O, Decl(unwitnessedTypeParameterVariance.ts, 8, 13)) + + const unk: CalcObj = { read: (origin: unknown) => unk } +>unk : Symbol(unk, Decl(unwitnessedTypeParameterVariance.ts, 9, 9)) +>CalcObj : Symbol(CalcObj, Decl(unwitnessedTypeParameterVariance.ts, 0, 0)) +>read : Symbol(read, Decl(unwitnessedTypeParameterVariance.ts, 9, 35)) +>origin : Symbol(origin, Decl(unwitnessedTypeParameterVariance.ts, 9, 43)) +>unk : Symbol(unk, Decl(unwitnessedTypeParameterVariance.ts, 9, 9)) + + const x: CalcObj = unk; +>x : Symbol(x, Decl(unwitnessedTypeParameterVariance.ts, 10, 9)) +>CalcObj : Symbol(CalcObj, Decl(unwitnessedTypeParameterVariance.ts, 0, 0)) +>O : Symbol(O, Decl(unwitnessedTypeParameterVariance.ts, 8, 13)) +>unk : Symbol(unk, Decl(unwitnessedTypeParameterVariance.ts, 9, 9)) +} + +type A = B; +>A : Symbol(A, Decl(unwitnessedTypeParameterVariance.ts, 11, 1)) +>T : Symbol(T, Decl(unwitnessedTypeParameterVariance.ts, 13, 7)) +>B : Symbol(B, Decl(unwitnessedTypeParameterVariance.ts, 13, 17)) +>T : Symbol(T, Decl(unwitnessedTypeParameterVariance.ts, 13, 7)) + +interface B { +>B : Symbol(B, Decl(unwitnessedTypeParameterVariance.ts, 13, 17)) +>T : Symbol(T, Decl(unwitnessedTypeParameterVariance.ts, 15, 12)) + + prop: A; +>prop : Symbol(B.prop, Decl(unwitnessedTypeParameterVariance.ts, 15, 16)) +>A : Symbol(A, Decl(unwitnessedTypeParameterVariance.ts, 11, 1)) +>T : Symbol(T, Decl(unwitnessedTypeParameterVariance.ts, 15, 12)) +} + +declare let a: A; +>a : Symbol(a, Decl(unwitnessedTypeParameterVariance.ts, 19, 11)) +>A : Symbol(A, Decl(unwitnessedTypeParameterVariance.ts, 11, 1)) + +declare let b: A<3>; +>b : Symbol(b, Decl(unwitnessedTypeParameterVariance.ts, 20, 11)) +>A : Symbol(A, Decl(unwitnessedTypeParameterVariance.ts, 11, 1)) + +b = a; +>b : Symbol(b, Decl(unwitnessedTypeParameterVariance.ts, 20, 11)) +>a : Symbol(a, Decl(unwitnessedTypeParameterVariance.ts, 19, 11)) + diff --git a/tests/baselines/reference/unwitnessedTypeParameterVariance.types b/tests/baselines/reference/unwitnessedTypeParameterVariance.types new file mode 100644 index 0000000000000..4eb72cee079ac --- /dev/null +++ b/tests/baselines/reference/unwitnessedTypeParameterVariance.types @@ -0,0 +1,47 @@ +=== tests/cases/compiler/unwitnessedTypeParameterVariance.ts === +// Repros from #33872 + +export interface CalcObj { + read: (origin: O) => CalcValue; +>read : (origin: O) => CalcValue +>origin : O +} + +export type CalcValue = CalcObj; +>CalcValue : CalcValue + +function foo() { +>foo : () => void + + const unk: CalcObj = { read: (origin: unknown) => unk } +>unk : CalcObj +>{ read: (origin: unknown) => unk } : { read: (origin: unknown) => CalcObj; } +>read : (origin: unknown) => CalcObj +>(origin: unknown) => unk : (origin: unknown) => CalcObj +>origin : unknown +>unk : CalcObj + + const x: CalcObj = unk; +>x : CalcObj +>unk : CalcObj +} + +type A = B; +>A : A + +interface B { + prop: A; +>prop : A +} + +declare let a: A; +>a : A + +declare let b: A<3>; +>b : A<3> + +b = a; +>b = a : A +>b : A<3> +>a : A + From 4bd698b97c1885684e4058728c93720a697e76fe Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 22 Nov 2019 08:22:45 -0800 Subject: [PATCH 6/7] Use aliases when available in error reporting --- src/compiler/checker.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index bf05a1e22500b..84f42770b9fed 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14553,13 +14553,13 @@ namespace ts { * * Ternary.Maybe if they are related with assumptions of other relationships, or * * Ternary.False if they are not related. */ - function isRelatedTo(source: Type, target: Type, reportErrors = false, headMessage?: DiagnosticMessage, isApparentIntersectionConstituent?: boolean): Ternary { + function isRelatedTo(originalSource: Type, originalTarget: Type, reportErrors = false, headMessage?: DiagnosticMessage, isApparentIntersectionConstituent?: boolean): Ternary { // Normalize the source and target types: Turn fresh literal types into regular literal types, // turn deferred type references into regular type references, simplify indexed access and // conditional types, and resolve substitution types to either the substitution (on the source // side) or the type variable (on the target side). - source = getNormalizedType(source, /*writing*/ false); - target = getNormalizedType(target, /*writing*/ true); + let source = getNormalizedType(originalSource, /*writing*/ false); + let target = getNormalizedType(originalTarget, /*writing*/ true); // Try to see if we're relating something like `Foo` -> `Bar | null | undefined`. // If so, reporting the `null` and `undefined` in the type is hardly useful. @@ -14692,6 +14692,8 @@ namespace ts { } if (!result && reportErrors) { + source = originalSource.aliasSymbol ? originalSource : source; + target = originalTarget.aliasSymbol ? originalTarget : target; let maybeSuppress = overrideNextErrorInfo > 0; if (maybeSuppress) { overrideNextErrorInfo--; From 88d0315759802080860b3c1fc32e2fd8dc59a36b Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 22 Nov 2019 08:23:06 -0800 Subject: [PATCH 7/7] Accept new baselines --- .../optionalTupleElements1.errors.txt | 24 +++++++++---------- .../recursiveTypeReferences1.errors.txt | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/baselines/reference/optionalTupleElements1.errors.txt b/tests/baselines/reference/optionalTupleElements1.errors.txt index ac9f5f244da2d..bb5fd2c01d8cb 100644 --- a/tests/baselines/reference/optionalTupleElements1.errors.txt +++ b/tests/baselines/reference/optionalTupleElements1.errors.txt @@ -1,25 +1,25 @@ tests/cases/conformance/types/tuple/optionalTupleElements1.ts(11,29): error TS1257: A required element cannot follow an optional element. -tests/cases/conformance/types/tuple/optionalTupleElements1.ts(15,5): error TS2322: Type '[number, string, (boolean | undefined)?]' is not assignable to type '[number, string, boolean]'. +tests/cases/conformance/types/tuple/optionalTupleElements1.ts(15,5): error TS2322: Type 'T2' is not assignable to type 'T1'. Types of property '2' are incompatible. Type 'boolean | undefined' is not assignable to type 'boolean'. Type 'undefined' is not assignable to type 'boolean'. -tests/cases/conformance/types/tuple/optionalTupleElements1.ts(16,5): error TS2322: Type '[number, (string | undefined)?, (boolean | undefined)?]' is not assignable to type '[number, string, boolean]'. +tests/cases/conformance/types/tuple/optionalTupleElements1.ts(16,5): error TS2322: Type 'T3' is not assignable to type 'T1'. Types of property '1' are incompatible. Type 'string | undefined' is not assignable to type 'string'. Type 'undefined' is not assignable to type 'string'. -tests/cases/conformance/types/tuple/optionalTupleElements1.ts(17,5): error TS2322: Type '[(number | undefined)?, (string | undefined)?, (boolean | undefined)?]' is not assignable to type '[number, string, boolean]'. +tests/cases/conformance/types/tuple/optionalTupleElements1.ts(17,5): error TS2322: Type 'T4' is not assignable to type 'T1'. Types of property '0' are incompatible. Type 'number | undefined' is not assignable to type 'number'. Type 'undefined' is not assignable to type 'number'. -tests/cases/conformance/types/tuple/optionalTupleElements1.ts(20,5): error TS2322: Type '[number, (string | undefined)?, (boolean | undefined)?]' is not assignable to type '[number, string, (boolean | undefined)?]'. +tests/cases/conformance/types/tuple/optionalTupleElements1.ts(20,5): error TS2322: Type 'T3' is not assignable to type 'T2'. Types of property '1' are incompatible. Type 'string | undefined' is not assignable to type 'string'. Type 'undefined' is not assignable to type 'string'. -tests/cases/conformance/types/tuple/optionalTupleElements1.ts(21,5): error TS2322: Type '[(number | undefined)?, (string | undefined)?, (boolean | undefined)?]' is not assignable to type '[number, string, (boolean | undefined)?]'. +tests/cases/conformance/types/tuple/optionalTupleElements1.ts(21,5): error TS2322: Type 'T4' is not assignable to type 'T2'. Types of property '0' are incompatible. Type 'number | undefined' is not assignable to type 'number'. Type 'undefined' is not assignable to type 'number'. -tests/cases/conformance/types/tuple/optionalTupleElements1.ts(25,5): error TS2322: Type '[(number | undefined)?, (string | undefined)?, (boolean | undefined)?]' is not assignable to type '[number, (string | undefined)?, (boolean | undefined)?]'. +tests/cases/conformance/types/tuple/optionalTupleElements1.ts(25,5): error TS2322: Type 'T4' is not assignable to type 'T3'. Types of property '0' are incompatible. Type 'number | undefined' is not assignable to type 'number'. Type 'undefined' is not assignable to type 'number'. @@ -44,19 +44,19 @@ tests/cases/conformance/types/tuple/optionalTupleElements1.ts(25,5): error TS232 t1 = t1; t1 = t2; // Error ~~ -!!! error TS2322: Type '[number, string, (boolean | undefined)?]' is not assignable to type '[number, string, boolean]'. +!!! error TS2322: Type 'T2' is not assignable to type 'T1'. !!! error TS2322: Types of property '2' are incompatible. !!! error TS2322: Type 'boolean | undefined' is not assignable to type 'boolean'. !!! error TS2322: Type 'undefined' is not assignable to type 'boolean'. t1 = t3; // Error ~~ -!!! error TS2322: Type '[number, (string | undefined)?, (boolean | undefined)?]' is not assignable to type '[number, string, boolean]'. +!!! error TS2322: Type 'T3' is not assignable to type 'T1'. !!! error TS2322: Types of property '1' are incompatible. !!! error TS2322: Type 'string | undefined' is not assignable to type 'string'. !!! error TS2322: Type 'undefined' is not assignable to type 'string'. t1 = t4; // Error ~~ -!!! error TS2322: Type '[(number | undefined)?, (string | undefined)?, (boolean | undefined)?]' is not assignable to type '[number, string, boolean]'. +!!! error TS2322: Type 'T4' is not assignable to type 'T1'. !!! error TS2322: Types of property '0' are incompatible. !!! error TS2322: Type 'number | undefined' is not assignable to type 'number'. !!! error TS2322: Type 'undefined' is not assignable to type 'number'. @@ -64,13 +64,13 @@ tests/cases/conformance/types/tuple/optionalTupleElements1.ts(25,5): error TS232 t2 = t2; t2 = t3; // Error ~~ -!!! error TS2322: Type '[number, (string | undefined)?, (boolean | undefined)?]' is not assignable to type '[number, string, (boolean | undefined)?]'. +!!! error TS2322: Type 'T3' is not assignable to type 'T2'. !!! error TS2322: Types of property '1' are incompatible. !!! error TS2322: Type 'string | undefined' is not assignable to type 'string'. !!! error TS2322: Type 'undefined' is not assignable to type 'string'. t2 = t4; // Error ~~ -!!! error TS2322: Type '[(number | undefined)?, (string | undefined)?, (boolean | undefined)?]' is not assignable to type '[number, string, (boolean | undefined)?]'. +!!! error TS2322: Type 'T4' is not assignable to type 'T2'. !!! error TS2322: Types of property '0' are incompatible. !!! error TS2322: Type 'number | undefined' is not assignable to type 'number'. !!! error TS2322: Type 'undefined' is not assignable to type 'number'. @@ -79,7 +79,7 @@ tests/cases/conformance/types/tuple/optionalTupleElements1.ts(25,5): error TS232 t3 = t3; t3 = t4; // Error ~~ -!!! error TS2322: Type '[(number | undefined)?, (string | undefined)?, (boolean | undefined)?]' is not assignable to type '[number, (string | undefined)?, (boolean | undefined)?]'. +!!! error TS2322: Type 'T4' is not assignable to type 'T3'. !!! error TS2322: Types of property '0' are incompatible. !!! error TS2322: Type 'number | undefined' is not assignable to type 'number'. !!! error TS2322: Type 'undefined' is not assignable to type 'number'. diff --git a/tests/baselines/reference/recursiveTypeReferences1.errors.txt b/tests/baselines/reference/recursiveTypeReferences1.errors.txt index 6aca2422af8b7..b3ab2e9b8663e 100644 --- a/tests/baselines/reference/recursiveTypeReferences1.errors.txt +++ b/tests/baselines/reference/recursiveTypeReferences1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/types/typeRelationships/recursiveTypes/recursiveTypeReferences1.ts(45,7): error TS2322: Type '42' is not assignable to type 'Box'. +tests/cases/conformance/types/typeRelationships/recursiveTypes/recursiveTypeReferences1.ts(45,7): error TS2322: Type '42' is not assignable to type 'Box2'. tests/cases/conformance/types/typeRelationships/recursiveTypes/recursiveTypeReferences1.ts(60,7): error TS2322: Type 'number' is not assignable to type 'string | RecArray'. tests/cases/conformance/types/typeRelationships/recursiveTypes/recursiveTypeReferences1.ts(66,8): error TS2322: Type 'number' is not assignable to type 'string | string[]'. tests/cases/conformance/types/typeRelationships/recursiveTypes/recursiveTypeReferences1.ts(72,8): error TS2322: Type 'number' is not assignable to type 'string | (string | string[])[]'. @@ -60,7 +60,7 @@ tests/cases/conformance/types/typeRelationships/recursiveTypes/recursiveTypeRefe const b20: Box2 = 42; // Error ~~~ -!!! error TS2322: Type '42' is not assignable to type 'Box'. +!!! error TS2322: Type '42' is not assignable to type 'Box2'. const b21: Box2 = { value: 42 }; const b22: Box2 = { value: { value: { value: 42 }}};