diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts
index 1b6b31f9586..99f60ee15ce 100644
--- a/src/compiler/checker.ts
+++ b/src/compiler/checker.ts
@@ -1028,16 +1028,12 @@ namespace ts {
// Module names are escaped in our symbol table. However, string literal values aren't.
// Escape the name in the "require(...)" clause to ensure we find the right symbol.
- let moduleName = escapeIdentifier(moduleReferenceLiteral.text);
+ const moduleName = escapeIdentifier(moduleReferenceLiteral.text);
if (moduleName === undefined) {
return;
}
- if (moduleName.indexOf("!") >= 0) {
- moduleName = moduleName.substr(0, moduleName.indexOf("!"));
- }
-
const isRelative = isExternalModuleNameRelative(moduleName);
if (!isRelative) {
const symbol = getSymbol(globals, "\"" + moduleName + "\"", SymbolFlags.ValueModule);
@@ -5228,9 +5224,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/bangInModuleName.js b/tests/baselines/reference/bangInModuleName.js
new file mode 100644
index 00000000000..769ccbf1d42
--- /dev/null
+++ b/tests/baselines/reference/bangInModuleName.js
@@ -0,0 +1,23 @@
+//// [tests/cases/compiler/bangInModuleName.ts] ////
+
+//// [a.d.ts]
+
+
+declare module "http" {
+}
+
+declare module 'intern/dojo/node!http' {
+ import http = require('http');
+ export = http;
+}
+
+//// [a.ts]
+
+///
+
+import * as http from 'intern/dojo/node!http';
+
+//// [a.js]
+///
+define(["require", "exports"], function (require, exports) {
+});
diff --git a/tests/baselines/reference/bangInModuleName.symbols b/tests/baselines/reference/bangInModuleName.symbols
new file mode 100644
index 00000000000..63ba5d106d8
--- /dev/null
+++ b/tests/baselines/reference/bangInModuleName.symbols
@@ -0,0 +1,21 @@
+=== tests/cases/compiler/a.ts ===
+
+///
+
+import * as http from 'intern/dojo/node!http';
+>http : Symbol(http, Decl(a.ts, 3, 6))
+
+=== tests/cases/compiler/a.d.ts ===
+
+
+declare module "http" {
+}
+
+declare module 'intern/dojo/node!http' {
+ import http = require('http');
+>http : Symbol(http, Decl(a.d.ts, 5, 40))
+
+ export = http;
+>http : Symbol(http, Decl(a.d.ts, 5, 40))
+}
+
diff --git a/tests/baselines/reference/bangInModuleName.types b/tests/baselines/reference/bangInModuleName.types
new file mode 100644
index 00000000000..06a602e2ff8
--- /dev/null
+++ b/tests/baselines/reference/bangInModuleName.types
@@ -0,0 +1,21 @@
+=== tests/cases/compiler/a.ts ===
+
+///
+
+import * as http from 'intern/dojo/node!http';
+>http : typeof http
+
+=== tests/cases/compiler/a.d.ts ===
+
+
+declare module "http" {
+}
+
+declare module 'intern/dojo/node!http' {
+ import http = require('http');
+>http : typeof http
+
+ export = http;
+>http : typeof http
+}
+
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/bangInModuleName.ts b/tests/cases/compiler/bangInModuleName.ts
new file mode 100644
index 00000000000..6e8f7163109
--- /dev/null
+++ b/tests/cases/compiler/bangInModuleName.ts
@@ -0,0 +1,17 @@
+// @module: amd
+
+// @filename: a.d.ts
+
+declare module "http" {
+}
+
+declare module 'intern/dojo/node!http' {
+ import http = require('http');
+ export = http;
+}
+
+// @filename: a.ts
+
+///
+
+import * as http from 'intern/dojo/node!http';
\ 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);
]