From f5d4aa7d9c0a3fbe5c731e0b4288839538541e5d Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 27 Oct 2015 11:52:57 -0700 Subject: [PATCH] addressed PR feedback (change command line flag description), added tests --- src/compiler/commandLineParser.ts | 2 +- src/compiler/diagnosticMessages.json | 3 +-- tests/cases/unittests/moduleResolution.ts | 25 +++++++++++++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 1d4ad8ae4d..90373b1a94 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -251,7 +251,7 @@ namespace ts { { name: "forceConsistentCasingInFileNames", type: "boolean", - description: Diagnostics.Raise_error_if_two_file_names_in_program_differ_only_in_case + description: Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file }, ]; diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 7202713cbe..edfe1fc577 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2298,11 +2298,10 @@ "category": "Message", "code": 6072 }, - "Raise error if two file names in program differ only in case.": { + "Disallow inconsistently-cased references to the same file.": { "category": "Message", "code": 6073 }, - "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", "code": 7005 diff --git a/tests/cases/unittests/moduleResolution.ts b/tests/cases/unittests/moduleResolution.ts index 0758fe7cfd..a76428a62a 100644 --- a/tests/cases/unittests/moduleResolution.ts +++ b/tests/cases/unittests/moduleResolution.ts @@ -254,6 +254,14 @@ export = C; }; test(files, "/parent/app",["myapp.ts"], 2, []); }); + + it("should find file referenced via absolute and relative names", () => { + const files: Map = { + "/a/b/c.ts": `/// `, + "/a/b/b.ts": "var x" + }; + test(files, "/a/b", ["c.ts", "/a/b/b.ts"], 2, []); + }); }); describe("Files with different casing", () => { @@ -320,6 +328,14 @@ export = C; test(files, { module: ts.ModuleKind.AMD, forceConsistentCasingInFileNames: true }, "/a/b", /* useCaseSensitiveFileNames */ false, ["c.ts", "d.ts"], [1149]); }); + it("should fail when two files used in program differ only in casing (imports, relative module names)", () => { + const files: Map = { + "moduleA.ts": `import {x} from "./ModuleB"`, + "moduleB.ts": "export var x" + }; + test(files, { module: ts.ModuleKind.CommonJS, forceConsistentCasingInFileNames: true }, "", /* useCaseSensitiveFileNames */ false, ["moduleA.ts", "moduleB.ts"], [1149]); + }); + it("should fail when two files exist on disk that differs only in casing", () => { const files: Map = { "/a/b/c.ts": `import {x} from "D"`, @@ -328,5 +344,14 @@ export = C; }; test(files, { module: ts.ModuleKind.AMD }, "/a/b", /* useCaseSensitiveFileNames */ true, ["c.ts", "d.ts"], [1149]); }); + + it("should fail when module name in 'require' calls has inconsistent casing", () => { + const files: Map = { + "moduleA.ts": `import a = require("./ModuleC")`, + "moduleB.ts": `import a = require("./moduleC")`, + "moduleC.ts": "export var x" + }; + test(files, { module: ts.ModuleKind.CommonJS, forceConsistentCasingInFileNames: true }, "", /* useCaseSensitiveFileNames */ false, ["moduleA.ts", "moduleB.ts", "moduleC.ts"], [1149, 1149]); + }) }); } \ No newline at end of file