mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
Merge pull request #748 from chrisbubernak/selfReferencingFileError
Fix issue #568 (no error for file self reference)
This commit is contained in:
@@ -5,6 +5,7 @@ module ts {
|
||||
Unterminated_string_literal: { code: 1002, category: DiagnosticCategory.Error, key: "Unterminated string literal." },
|
||||
Identifier_expected: { code: 1003, category: DiagnosticCategory.Error, key: "Identifier expected." },
|
||||
_0_expected: { code: 1005, category: DiagnosticCategory.Error, key: "'{0}' expected." },
|
||||
A_file_cannot_have_a_reference_to_itself: { code: 1006, category: DiagnosticCategory.Error, key: "A file cannot have a reference to itself." },
|
||||
Trailing_comma_not_allowed: { code: 1009, category: DiagnosticCategory.Error, key: "Trailing comma not allowed." },
|
||||
Asterisk_Slash_expected: { code: 1010, category: DiagnosticCategory.Error, key: "'*/' expected." },
|
||||
Unexpected_token: { code: 1012, category: DiagnosticCategory.Error, key: "Unexpected token." },
|
||||
|
||||
@@ -10,6 +10,10 @@
|
||||
"'{0}' expected.": {
|
||||
"category": "Error",
|
||||
"code": 1005
|
||||
},
|
||||
"A file cannot have a reference to itself.": {
|
||||
"category": "Error",
|
||||
"code": 1006
|
||||
},
|
||||
"Trailing comma not allowed.": {
|
||||
"category": "Error",
|
||||
@@ -1355,6 +1359,7 @@
|
||||
"category": "Error",
|
||||
"code": 5001
|
||||
},
|
||||
|
||||
"Cannot find the common subdirectory path for the input files.": {
|
||||
"category": "Error",
|
||||
"code": 5009
|
||||
|
||||
@@ -3831,15 +3831,17 @@ module ts {
|
||||
}
|
||||
else {
|
||||
var matchResult = fullTripleSlashReferencePathRegEx.exec(comment);
|
||||
var start = range.pos;
|
||||
var end = range.end;
|
||||
var length = end - start;
|
||||
|
||||
if (!matchResult) {
|
||||
var start = range.pos;
|
||||
var length = range.end - start;
|
||||
errorAtPos(start, length, Diagnostics.Invalid_reference_directive_syntax);
|
||||
}
|
||||
else {
|
||||
referencedFiles.push({
|
||||
pos: range.pos,
|
||||
end: range.end,
|
||||
pos: start,
|
||||
end: end,
|
||||
filename: matchResult[3]
|
||||
});
|
||||
}
|
||||
@@ -3956,6 +3958,9 @@ module ts {
|
||||
else if (!findSourceFile(filename, isDefaultLib, refFile, refPos, refEnd)) {
|
||||
diagnostic = Diagnostics.File_0_not_found;
|
||||
}
|
||||
else if (refFile && host.getCanonicalFileName(filename) === host.getCanonicalFileName(refFile.filename)) {
|
||||
diagnostic = Diagnostics.A_file_cannot_have_a_reference_to_itself;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!(findSourceFile(filename + ".ts", isDefaultLib, refFile, refPos, refEnd) || findSourceFile(filename + ".d.ts", isDefaultLib, refFile, refPos, refEnd))) {
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
main.ts(1,1): error TS1006: A file cannot have a reference to itself.
|
||||
main.ts(2,1): error TS6053: File 'nonExistingFile1.ts' not found.
|
||||
main.ts(3,1): error TS6053: File 'nonExistingFile2.ts' not found.
|
||||
|
||||
|
||||
==== main.ts (2 errors) ====
|
||||
==== main.ts (3 errors) ====
|
||||
/// <reference path="main.ts" />
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1006: A file cannot have a reference to itself.
|
||||
/// <reference path="nonExistingFile1.ts" />
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS6053: File 'nonExistingFile1.ts' not found.
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
main.ts(1,1): error TS1006: A file cannot have a reference to itself.
|
||||
main.ts(2,1): error TS6053: File 'nonExistingFile1.ts' not found.
|
||||
main.ts(3,1): error TS6053: File 'nonExistingFile2.ts' not found.
|
||||
|
||||
|
||||
==== main.ts (2 errors) ====
|
||||
==== main.ts (3 errors) ====
|
||||
/// <reference path="main.ts" />
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1006: A file cannot have a reference to itself.
|
||||
/// <reference path="nonExistingFile1.ts" />
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS6053: File 'nonExistingFile1.ts' not found.
|
||||
|
||||
11
tests/baselines/reference/selfReferencingFile.errors.txt
Normal file
11
tests/baselines/reference/selfReferencingFile.errors.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
tests/cases/compiler/selfReferencingFile.ts(1,1): error TS1006: A file cannot have a reference to itself.
|
||||
|
||||
|
||||
==== tests/cases/compiler/selfReferencingFile.ts (1 errors) ====
|
||||
///<reference path='selfReferencingFile.ts'/>
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1006: A file cannot have a reference to itself.
|
||||
|
||||
class selfReferencingFile {
|
||||
|
||||
}
|
||||
11
tests/baselines/reference/selfReferencingFile2.errors.txt
Normal file
11
tests/baselines/reference/selfReferencingFile2.errors.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
tests/cases/compiler/selfReferencingFile2.ts(1,1): error TS6053: File 'tests/cases/selfReferencingFile2.ts' not found.
|
||||
|
||||
|
||||
==== tests/cases/compiler/selfReferencingFile2.ts (1 errors) ====
|
||||
///<reference path='../selfReferencingFile2.ts'/>
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS6053: File 'selfReferencingFile2.ts' not found.
|
||||
|
||||
class selfReferencingFile2 {
|
||||
|
||||
}
|
||||
11
tests/baselines/reference/selfReferencingFile3.errors.txt
Normal file
11
tests/baselines/reference/selfReferencingFile3.errors.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
tests/cases/compiler/selfReferencingFile3.ts(1,1): error TS1006: A file cannot have a reference to itself.
|
||||
|
||||
|
||||
==== tests/cases/compiler/selfReferencingFile3.ts (1 errors) ====
|
||||
///<reference path='./selfReferencingFile3.ts'/>
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1006: A file cannot have a reference to itself.
|
||||
|
||||
class selfReferencingFile3 {
|
||||
|
||||
}
|
||||
5
tests/cases/compiler/selfReferencingFile.ts
Normal file
5
tests/cases/compiler/selfReferencingFile.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
///<reference path='selfReferencingFile.ts'/>
|
||||
|
||||
class selfReferencingFile {
|
||||
|
||||
}
|
||||
5
tests/cases/compiler/selfReferencingFile2.ts
Normal file
5
tests/cases/compiler/selfReferencingFile2.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
///<reference path='../selfReferencingFile2.ts'/>
|
||||
|
||||
class selfReferencingFile2 {
|
||||
|
||||
}
|
||||
5
tests/cases/compiler/selfReferencingFile3.ts
Normal file
5
tests/cases/compiler/selfReferencingFile3.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
///<reference path='./selfReferencingFile3.ts'/>
|
||||
|
||||
class selfReferencingFile3 {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user