diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json
index a9f531c901c..968a5019b8a 100644
--- a/src/compiler/diagnosticMessages.json
+++ b/src/compiler/diagnosticMessages.json
@@ -4324,6 +4324,10 @@
"category": "Error",
"code": 6230
},
+ "Could not resolve the path '{0}' with the extensions: {1}.": {
+ "category": "Error",
+ "code": 6231
+ },
"Projects to reference": {
"category": "Message",
diff --git a/src/compiler/program.ts b/src/compiler/program.ts
index 7b056a722e1..e3f3e27a827 100644
--- a/src/compiler/program.ts
+++ b/src/compiler/program.ts
@@ -1925,7 +1925,7 @@ namespace ts {
diagnostics.push(createDiagnosticForNodeArray(nodes, Diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files));
return "skip";
}
- // falls through
+ // falls through
case SyntaxKind.VariableStatement:
// Check modifiers
@@ -2270,7 +2270,7 @@ namespace ts {
}
const sourceFileWithAddedExtension = forEach(supportedExtensions, extension => getSourceFile(fileName + extension));
- if (fail && !sourceFileWithAddedExtension) fail(Diagnostics.File_0_not_found, fileName + Extension.Ts);
+ if (fail && !sourceFileWithAddedExtension) fail(Diagnostics.Could_not_resolve_the_path_0_with_the_extensions_Colon_1, fileName, "'" + supportedExtensions.join("', '") + "'");
return sourceFileWithAddedExtension;
}
}
diff --git a/tests/baselines/reference/declarationEmitInvalidReferenceAllowJs.errors.txt b/tests/baselines/reference/declarationEmitInvalidReferenceAllowJs.errors.txt
new file mode 100644
index 00000000000..79f9afa5f34
--- /dev/null
+++ b/tests/baselines/reference/declarationEmitInvalidReferenceAllowJs.errors.txt
@@ -0,0 +1,9 @@
+tests/cases/compiler/declarationEmitInvalidReferenceAllowJs.ts(1,22): error TS6231: Could not resolve the path 'tests/cases/compiler/invalid' with the extensions: '.ts', '.tsx', '.d.ts', '.js', '.jsx'.
+
+
+==== tests/cases/compiler/declarationEmitInvalidReferenceAllowJs.ts (1 errors) ====
+ ///
+ ~~~~~~~
+!!! error TS6231: Could not resolve the path 'tests/cases/compiler/invalid' with the extensions: '.ts', '.tsx', '.d.ts', '.js', '.jsx'.
+ var x = 0;
+
\ No newline at end of file
diff --git a/tests/baselines/reference/declarationEmitInvalidReferenceAllowJs.js b/tests/baselines/reference/declarationEmitInvalidReferenceAllowJs.js
new file mode 100644
index 00000000000..d6c7477a501
--- /dev/null
+++ b/tests/baselines/reference/declarationEmitInvalidReferenceAllowJs.js
@@ -0,0 +1,12 @@
+//// [declarationEmitInvalidReferenceAllowJs.ts]
+///
+var x = 0;
+
+
+//// [declarationEmitInvalidReferenceAllowJs.js]
+///
+var x = 0;
+
+
+//// [declarationEmitInvalidReferenceAllowJs.d.ts]
+declare var x: number;
diff --git a/tests/baselines/reference/declarationEmitInvalidReferenceAllowJs.symbols b/tests/baselines/reference/declarationEmitInvalidReferenceAllowJs.symbols
new file mode 100644
index 00000000000..f8e37157219
--- /dev/null
+++ b/tests/baselines/reference/declarationEmitInvalidReferenceAllowJs.symbols
@@ -0,0 +1,5 @@
+=== tests/cases/compiler/declarationEmitInvalidReferenceAllowJs.ts ===
+///
+var x = 0;
+>x : Symbol(x, Decl(declarationEmitInvalidReferenceAllowJs.ts, 1, 3))
+
diff --git a/tests/baselines/reference/declarationEmitInvalidReferenceAllowJs.types b/tests/baselines/reference/declarationEmitInvalidReferenceAllowJs.types
new file mode 100644
index 00000000000..4e004622fac
--- /dev/null
+++ b/tests/baselines/reference/declarationEmitInvalidReferenceAllowJs.types
@@ -0,0 +1,6 @@
+=== tests/cases/compiler/declarationEmitInvalidReferenceAllowJs.ts ===
+///
+var x = 0;
+>x : number
+>0 : 0
+
diff --git a/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt b/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt
index ed167c86571..d7128936cb6 100644
--- a/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt
+++ b/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt
@@ -1,6 +1,8 @@
error TS6053: File 'a.ts' not found.
error TS6054: File 'a.t' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'.
+error TS6231: Could not resolve the path 'a' with the extensions: '.ts', '.tsx', '.d.ts'.
!!! error TS6053: File 'a.ts' not found.
-!!! error TS6054: File 'a.t' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'.
\ No newline at end of file
+!!! error TS6054: File 'a.t' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'.
+!!! error TS6231: Could not resolve the path 'a' with the extensions: '.ts', '.tsx', '.d.ts'.
\ No newline at end of file
diff --git a/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt b/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt
index ed167c86571..d7128936cb6 100644
--- a/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt
+++ b/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt
@@ -1,6 +1,8 @@
error TS6053: File 'a.ts' not found.
error TS6054: File 'a.t' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'.
+error TS6231: Could not resolve the path 'a' with the extensions: '.ts', '.tsx', '.d.ts'.
!!! error TS6053: File 'a.ts' not found.
-!!! error TS6054: File 'a.t' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'.
\ No newline at end of file
+!!! error TS6054: File 'a.t' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'.
+!!! error TS6231: Could not resolve the path 'a' with the extensions: '.ts', '.tsx', '.d.ts'.
\ No newline at end of file
diff --git a/tests/cases/compiler/declarationEmitInvalidReferenceAllowJs.ts b/tests/cases/compiler/declarationEmitInvalidReferenceAllowJs.ts
new file mode 100644
index 00000000000..80c025c8e6b
--- /dev/null
+++ b/tests/cases/compiler/declarationEmitInvalidReferenceAllowJs.ts
@@ -0,0 +1,4 @@
+// @allowJs: true
+// @declaration: true
+///
+var x = 0;