diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1b6b31f9586..bd7b02e5c1d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5228,9 +5228,12 @@ namespace ts { const id = relation !== identityRelation || apparentSource.id < target.id ? apparentSource.id + "," + target.id : target.id + "," + apparentSource.id; const related = relation[id]; if (related !== undefined) { - // If we computed this relation already and it was failed and reported, or if we're not being asked to elaborate - // errors, we can use the cached value. Otherwise, recompute the relation - if (!elaborateErrors || (related === RelationComparisonResult.FailedAndReported)) { + if (elaborateErrors && related === RelationComparisonResult.Failed) { + // We are elaborating errors and the cached result is an unreported failure. Record the result as a reported + // failure and continue computing the relation such that errors get reported. + relation[id] = RelationComparisonResult.FailedAndReported; + } + else { return related === RelationComparisonResult.Succeeded ? Ternary.True : Ternary.False; } } diff --git a/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt index 95524d4bf4d..c8037255a32 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt +++ b/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt @@ -8,6 +8,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts( Type 'number | string[][] | string' is not assignable to type 'number | string[][]'. Type 'string' is not assignable to type 'number | string[][]'. Type 'string' is not assignable to type 'string[][]'. + Property 'push' is missing in type 'String'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(16,8): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(16,16): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(23,14): error TS2345: Argument of type '{ x: string; y: boolean; }' is not assignable to parameter of type '{ x: number; y: any; }'. @@ -77,6 +78,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts( !!! error TS2345: Type 'number | string[][] | string' is not assignable to type 'number | string[][]'. !!! error TS2345: Type 'string' is not assignable to type 'number | string[][]'. !!! error TS2345: Type 'string' is not assignable to type 'string[][]'. +!!! error TS2345: Property 'push' is missing in type 'String'. // If the declaration includes an initializer expression (which is permitted only diff --git a/tests/baselines/reference/errorElaboration.errors.txt b/tests/baselines/reference/errorElaboration.errors.txt new file mode 100644 index 00000000000..94742d7d98b --- /dev/null +++ b/tests/baselines/reference/errorElaboration.errors.txt @@ -0,0 +1,25 @@ +tests/cases/compiler/errorElaboration.ts(12,5): error TS2345: Argument of type '() => Container>' is not assignable to parameter of type '() => Container>'. + Type 'Container>' is not assignable to type 'Container>'. + Type 'Ref' is not assignable to type 'Ref'. + Type 'string' is not assignable to type 'number'. + + +==== tests/cases/compiler/errorElaboration.ts (1 errors) ==== + // Repro for #5712 + + interface Ref { + prop: T; + } + interface Container { + m1: Container>; + m2: T; + } + declare function foo(x: () => Container>): void; + let a: () => Container>; + foo(a); + ~ +!!! error TS2345: Argument of type '() => Container>' is not assignable to parameter of type '() => Container>'. +!!! error TS2345: Type 'Container>' is not assignable to type 'Container>'. +!!! error TS2345: Type 'Ref' is not assignable to type 'Ref'. +!!! error TS2345: Type 'string' is not assignable to type 'number'. + \ No newline at end of file diff --git a/tests/baselines/reference/errorElaboration.js b/tests/baselines/reference/errorElaboration.js new file mode 100644 index 00000000000..eed8bbd7c6b --- /dev/null +++ b/tests/baselines/reference/errorElaboration.js @@ -0,0 +1,19 @@ +//// [errorElaboration.ts] +// Repro for #5712 + +interface Ref { + prop: T; +} +interface Container { + m1: Container>; + m2: T; +} +declare function foo(x: () => Container>): void; +let a: () => Container>; +foo(a); + + +//// [errorElaboration.js] +// Repro for #5712 +var a; +foo(a); diff --git a/tests/baselines/reference/promisePermutations3.errors.txt b/tests/baselines/reference/promisePermutations3.errors.txt index 72276745c41..b17021a02b9 100644 --- a/tests/baselines/reference/promisePermutations3.errors.txt +++ b/tests/baselines/reference/promisePermutations3.errors.txt @@ -81,7 +81,9 @@ tests/cases/compiler/promisePermutations3.ts(159,21): error TS2345: Argument of Type 'number' is not assignable to type 'string'. tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of type '{ (x: T): IPromise; (x: T, y: T): Promise; }' is not assignable to parameter of type '(value: (x: any) => any) => Promise'. Type 'IPromise' is not assignable to type 'Promise'. - Property 'done' is optional in type 'IPromise' but required in type 'Promise'. + Types of property 'then' are incompatible. + Type '(success?: (value: any) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise' is not assignable to type '{ (success?: (value: any) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: any) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: any) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: any) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }'. + Type 'IPromise' is not assignable to type 'Promise'. ==== tests/cases/compiler/promisePermutations3.ts (35 errors) ==== @@ -368,5 +370,7 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of ~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '{ (x: T): IPromise; (x: T, y: T): Promise; }' is not assignable to parameter of type '(value: (x: any) => any) => Promise'. !!! error TS2345: Type 'IPromise' is not assignable to type 'Promise'. -!!! error TS2345: Property 'done' is optional in type 'IPromise' but required in type 'Promise'. +!!! error TS2345: Types of property 'then' are incompatible. +!!! error TS2345: Type '(success?: (value: any) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise' is not assignable to type '{ (success?: (value: any) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: any) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: any) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: any) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }'. +!!! error TS2345: Type 'IPromise' is not assignable to type 'Promise'. var s12c = s12.then(testFunction12P, testFunction12, testFunction12); // ok \ No newline at end of file diff --git a/tests/cases/compiler/errorElaboration.ts b/tests/cases/compiler/errorElaboration.ts new file mode 100644 index 00000000000..97ec0dde61c --- /dev/null +++ b/tests/cases/compiler/errorElaboration.ts @@ -0,0 +1,12 @@ +// Repro for #5712 + +interface Ref { + prop: T; +} +interface Container { + m1: Container>; + m2: T; +} +declare function foo(x: () => Container>): void; +let a: () => Container>; +foo(a);