Switch to createCompilerDiagnostic for an invalid root file

This commit is contained in:
Jason Freeman 2014-09-16 15:10:41 -07:00
parent 50b0516df0
commit 31eae88b86
6 changed files with 65 additions and 3 deletions

View File

@ -3686,17 +3686,28 @@ module ts {
var start = refPos;
var length = refEnd - refPos;
}
var diagnostic: DiagnosticMessage;
if (hasExtension(filename)) {
if (!fileExtensionIs(filename, ".ts")) {
errors.push(createFileDiagnostic(refFile, start, length, Diagnostics.File_0_must_have_extension_ts_or_d_ts, filename));
diagnostic = Diagnostics.File_0_must_have_extension_ts_or_d_ts;
}
else if (!findSourceFile(filename, isDefaultLib, refFile, refPos, refEnd)) {
errors.push(createFileDiagnostic(refFile, start, length, Diagnostics.File_0_not_found, filename));
diagnostic = Diagnostics.File_0_not_found;
}
}
else {
if (!(findSourceFile(filename + ".ts", isDefaultLib, refFile, refPos, refEnd) || findSourceFile(filename + ".d.ts", isDefaultLib, refFile, refPos, refEnd))) {
errors.push(createFileDiagnostic(refFile, start, length, Diagnostics.File_0_not_found, filename + ".ts"));
diagnostic = Diagnostics.File_0_not_found;
filename += ".ts";
}
}
if (diagnostic) {
if (refFile) {
errors.push(createFileDiagnostic(refFile, start, length, diagnostic, filename));
}
else {
errors.push(createCompilerDiagnostic(diagnostic, filename));
}
}
}

View File

@ -0,0 +1,8 @@
error TS6053: File 'a.ts' not found.
error TS6053: File 'a.ts' not found.
error TS6054: File 'a.t' must have extension '.ts' or '.d.ts'.
!!! error TS6053: File 'a.ts' not found.
!!! error TS6053: File 'a.ts' not found.
!!! error TS6054: File 'a.t' must have extension '.ts' or '.d.ts'.

View File

@ -0,0 +1,13 @@
{
"scenario": "InvalidRootFile",
"projectRoot": "tests/cases/projects/InvalidRootFile",
"inputFiles": [
"a",
"a.t",
"a.ts"
],
"resolvedInputFiles": [
"lib.d.ts"
],
"emittedFiles": []
}

View File

@ -0,0 +1,8 @@
error TS6053: File 'a.ts' not found.
error TS6053: File 'a.ts' not found.
error TS6054: File 'a.t' must have extension '.ts' or '.d.ts'.
!!! error TS6053: File 'a.ts' not found.
!!! error TS6053: File 'a.ts' not found.
!!! error TS6054: File 'a.t' must have extension '.ts' or '.d.ts'.

View File

@ -0,0 +1,13 @@
{
"scenario": "InvalidRootFile",
"projectRoot": "tests/cases/projects/InvalidRootFile",
"inputFiles": [
"a",
"a.t",
"a.ts"
],
"resolvedInputFiles": [
"lib.d.ts"
],
"emittedFiles": []
}

View File

@ -0,0 +1,9 @@
{
"scenario": "InvalidRootFile",
"projectRoot": "tests/cases/projects/InvalidRootFile",
"inputFiles": [
"a",
"a.t",
"a.ts"
]
}