mirror of
https://gitee.com/openharmony/third_party_typescript
synced 2024-11-23 23:10:34 +00:00
Switch to createCompilerDiagnostic for an invalid root file
This commit is contained in:
parent
50b0516df0
commit
31eae88b86
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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'.
|
@ -0,0 +1,13 @@
|
||||
{
|
||||
"scenario": "InvalidRootFile",
|
||||
"projectRoot": "tests/cases/projects/InvalidRootFile",
|
||||
"inputFiles": [
|
||||
"a",
|
||||
"a.t",
|
||||
"a.ts"
|
||||
],
|
||||
"resolvedInputFiles": [
|
||||
"lib.d.ts"
|
||||
],
|
||||
"emittedFiles": []
|
||||
}
|
@ -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'.
|
@ -0,0 +1,13 @@
|
||||
{
|
||||
"scenario": "InvalidRootFile",
|
||||
"projectRoot": "tests/cases/projects/InvalidRootFile",
|
||||
"inputFiles": [
|
||||
"a",
|
||||
"a.t",
|
||||
"a.ts"
|
||||
],
|
||||
"resolvedInputFiles": [
|
||||
"lib.d.ts"
|
||||
],
|
||||
"emittedFiles": []
|
||||
}
|
9
tests/cases/project/invalidRootFile.json
Normal file
9
tests/cases/project/invalidRootFile.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"scenario": "InvalidRootFile",
|
||||
"projectRoot": "tests/cases/projects/InvalidRootFile",
|
||||
"inputFiles": [
|
||||
"a",
|
||||
"a.t",
|
||||
"a.ts"
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user