Clarified file-not-found error for reference paths without extensions (#35956)

* Clarified file-not-found error for reference paths without extensions

* Updated error message to include extensions

* update baselines missed in merge

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
This commit is contained in:
Josh Goldberg
2020-03-17 14:21:23 -07:00
committed by GitHub
co-authored by Nathan Shively-Sanders
parent e60bbac84f
commit 878f447798
9 changed files with 48 additions and 4 deletions
+4
View File
@@ -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",
+2 -2
View File
@@ -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;
}
}
@@ -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) ====
/// <reference path="invalid" />
~~~~~~~
!!! error TS6231: Could not resolve the path 'tests/cases/compiler/invalid' with the extensions: '.ts', '.tsx', '.d.ts', '.js', '.jsx'.
var x = 0;
@@ -0,0 +1,12 @@
//// [declarationEmitInvalidReferenceAllowJs.ts]
/// <reference path="invalid" />
var x = 0;
//// [declarationEmitInvalidReferenceAllowJs.js]
/// <reference path="invalid" />
var x = 0;
//// [declarationEmitInvalidReferenceAllowJs.d.ts]
declare var x: number;
@@ -0,0 +1,5 @@
=== tests/cases/compiler/declarationEmitInvalidReferenceAllowJs.ts ===
/// <reference path="invalid" />
var x = 0;
>x : Symbol(x, Decl(declarationEmitInvalidReferenceAllowJs.ts, 1, 3))
@@ -0,0 +1,6 @@
=== tests/cases/compiler/declarationEmitInvalidReferenceAllowJs.ts ===
/// <reference path="invalid" />
var x = 0;
>x : number
>0 : 0
@@ -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'.
!!! 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'.
@@ -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'.
!!! 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'.
@@ -0,0 +1,4 @@
// @allowJs: true
// @declaration: true
/// <reference path="invalid" />
var x = 0;