From 62df49f3272b444664f702238b983af6b0bf0cf7 Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Sun, 20 Sep 2015 17:22:50 +0900 Subject: [PATCH 1/6] support tsconfig full path --- src/compiler/program.ts | 4 ++-- src/compiler/tsc.ts | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 3da3c354fb2..3043f6be708 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -862,8 +862,8 @@ namespace ts { const importedFile = findModuleSourceFile(resolution.resolvedFileName, file.imports[i]); if (importedFile && resolution.isExternalLibraryImport) { if (!isExternalModule(importedFile)) { - let start = getTokenPosOfNode(file.imports[i], file) - fileProcessingDiagnostics.add(createFileDiagnostic(file, start, file.imports[i].end - start, Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName)); + let start = getTokenPosOfNode(file.imports[i], file) + fileProcessingDiagnostics.add(createFileDiagnostic(file, start, file.imports[i].end - start, Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName)); } else if (!fileExtensionIs(importedFile.fileName, ".d.ts")) { let start = getTokenPosOfNode(file.imports[i], file) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 96759b68250..25e149cf6ca 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -180,11 +180,18 @@ namespace ts { reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--project")); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } - configFileName = normalizePath(combinePaths(commandLine.options.project, "tsconfig.json")); if (commandLine.fileNames.length !== 0) { reportDiagnostic(createCompilerDiagnostic(Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line)); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } + + let fileOrDirectory = normalizePath(commandLine.options.project); + if (!fileOrDirectory || sys.directoryExists(fileOrDirectory)) { + configFileName = combinePaths(fileOrDirectory, "tsconfig.json"); + } + else { + configFileName = fileOrDirectory; + } } else if (commandLine.fileNames.length === 0 && isJSONSupported()) { let searchPath = normalizePath(sys.getCurrentDirectory()); From 271003008edb8c68d365db95713e824e611cd85f Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Tue, 22 Sep 2015 17:53:20 +0900 Subject: [PATCH 2/6] format/existence check --- src/compiler/diagnosticMessages.json | 18 +++++++++++++----- src/compiler/tsc.ts | 8 ++++++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index c1657a81bab..1f187494639 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1623,7 +1623,7 @@ }, "Cannot assign an abstract constructor type to a non-abstract constructor type.": { "category": "Error", - "code":2517 + "code": 2517 }, "Only an ambient class can be merged with an interface.": { "category": "Error", @@ -1700,11 +1700,11 @@ "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead.": { "category": "Error", "code": 2652 - }, + }, "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'.": { "category": "Error", "code": 2653 - }, + }, "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition.": { "category": "Error", "code": 2654 @@ -1712,11 +1712,11 @@ "Exported external package typings can only be in '.d.ts' files. Please contact the package author to update the package definition.": { "category": "Error", "code": 2655 - }, + }, "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition.": { "category": "Error", "code": 2656 - }, + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 @@ -2057,6 +2057,14 @@ "category": "Error", "code": 5053 }, + "The project file name is not in 'tsconfig-*.json' format: '{0}'": { + "category": "Error", + "code": 5055 + }, + "Cannot find any project file in specified path: '{0}'": { + "category": "Error", + "code": 5056 + }, "Concatenate and emit output to single file.": { "category": "Message", diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 25e149cf6ca..3aedd5efd11 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -190,8 +190,16 @@ namespace ts { configFileName = combinePaths(fileOrDirectory, "tsconfig.json"); } else { + if (!/^tsconfig.*\.json$/.test(getBaseFileName(fileOrDirectory))) { + reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_project_file_name_is_not_in_tsconfig_Asterisk_json_format_Colon_0, commandLine.options.project)); + return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); + } configFileName = fileOrDirectory; } + if (!sys.fileExists(configFileName)) { + reportDiagnostic(createCompilerDiagnostic(Diagnostics.Cannot_find_any_project_file_in_specified_path_Colon_0, commandLine.options.project)); + return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); + } } else if (commandLine.fileNames.length === 0 && isJSONSupported()) { let searchPath = normalizePath(sys.getCurrentDirectory()); From 00a373a5ef29904e84c7c4ae026bf551393eac20 Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Tue, 22 Sep 2015 18:09:54 +0900 Subject: [PATCH 3/6] update regex for filename --- src/compiler/diagnosticMessages.json | 2 +- src/compiler/tsc.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 8fbea626eea..6c180921d4f 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2056,7 +2056,7 @@ "category": "Error", "code": 5054 }, - "The project file name is not in 'tsconfig-*.json' format: '{0}'": { + "The project file name is not in 'tsconfig(-*).json' format: '{0}'": { "category": "Error", "code": 5055 }, diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 3aedd5efd11..67f7ee2aaad 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -186,11 +186,11 @@ namespace ts { } let fileOrDirectory = normalizePath(commandLine.options.project); - if (!fileOrDirectory || sys.directoryExists(fileOrDirectory)) { + if (!fileOrDirectory /* current directory */ || sys.directoryExists(fileOrDirectory)) { configFileName = combinePaths(fileOrDirectory, "tsconfig.json"); } else { - if (!/^tsconfig.*\.json$/.test(getBaseFileName(fileOrDirectory))) { + if (!/^tsconfig(?:-.*)?.json$/.test(getBaseFileName(fileOrDirectory))) { reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_project_file_name_is_not_in_tsconfig_Asterisk_json_format_Colon_0, commandLine.options.project)); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } From c8509196141c9bc307836e59ac5c8058d212ac9f Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Tue, 22 Sep 2015 18:17:03 +0900 Subject: [PATCH 4/6] \. instead of . --- src/compiler/tsc.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 67f7ee2aaad..b133f9e986e 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -190,7 +190,7 @@ namespace ts { configFileName = combinePaths(fileOrDirectory, "tsconfig.json"); } else { - if (!/^tsconfig(?:-.*)?.json$/.test(getBaseFileName(fileOrDirectory))) { + if (!/^tsconfig(?:-.*)?\.json$/.test(getBaseFileName(fileOrDirectory))) { reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_project_file_name_is_not_in_tsconfig_Asterisk_json_format_Colon_0, commandLine.options.project)); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } From 8ca6b31faa4eb2c7b3ed1bba08b1201ed36a84bc Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Wed, 18 Nov 2015 18:09:31 +0900 Subject: [PATCH 5/6] const --- src/compiler/tsc.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index fda9d86d85a..d77699303c4 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -300,19 +300,19 @@ namespace ts { return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } - let fileOrDirectory = normalizePath(commandLine.options.project); + const fileOrDirectory = normalizePath(commandLine.options.project); if (!fileOrDirectory /* current directory */ || sys.directoryExists(fileOrDirectory)) { configFileName = combinePaths(fileOrDirectory, "tsconfig.json"); } else { if (!/^tsconfig(?:-.*)?\.json$/.test(getBaseFileName(fileOrDirectory))) { - reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_project_file_name_is_not_in_tsconfig_Asterisk_json_format_Colon_0, commandLine.options.project)); + reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_project_file_name_is_not_in_tsconfig_Asterisk_json_format_Colon_0, commandLine.options.project), /* compilerHost */ undefined); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } configFileName = fileOrDirectory; } if (!sys.fileExists(configFileName)) { - reportDiagnostic(createCompilerDiagnostic(Diagnostics.Cannot_find_any_project_file_in_specified_path_Colon_0, commandLine.options.project)); + reportDiagnostic(createCompilerDiagnostic(Diagnostics.Cannot_find_any_project_file_in_specified_path_Colon_0, commandLine.options.project), /* compilerHost */ undefined); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } } From 880db386a43e24a3a39f77da8349a1b0371da627 Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Tue, 24 Nov 2015 23:39:12 +0900 Subject: [PATCH 6/6] removing filename requirement --- src/compiler/diagnosticMessages.json | 4 ++-- src/compiler/tsc.ts | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 4efb3e11816..780f95d7f8c 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2068,11 +2068,11 @@ "category": "Error", "code": 5056 }, - "The project file name is not in 'tsconfig(-*).json' format: '{0}'": { + "Cannot find a tsconfig.json file at the specified directory: '{0}'": { "category": "Error", "code": 5057 }, - "Cannot find any project file in specified path: '{0}'": { + "The specified path does not exist: '{0}'": { "category": "Error", "code": 5058 }, diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 3b1b63aeae3..d064ec54c9c 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -301,19 +301,19 @@ namespace ts { } const fileOrDirectory = normalizePath(commandLine.options.project); - if (!fileOrDirectory /* current directory */ || sys.directoryExists(fileOrDirectory)) { + if (!fileOrDirectory /* current directory "." */ || sys.directoryExists(fileOrDirectory)) { configFileName = combinePaths(fileOrDirectory, "tsconfig.json"); - } - else { - if (!/^tsconfig(?:-.*)?\.json$/.test(getBaseFileName(fileOrDirectory))) { - reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_project_file_name_is_not_in_tsconfig_Asterisk_json_format_Colon_0, commandLine.options.project), /* compilerHost */ undefined); + if (!sys.fileExists(configFileName)) { + reportDiagnostic(createCompilerDiagnostic(Diagnostics.Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0, commandLine.options.project), /* compilerHost */ undefined); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } - configFileName = fileOrDirectory; } - if (!sys.fileExists(configFileName)) { - reportDiagnostic(createCompilerDiagnostic(Diagnostics.Cannot_find_any_project_file_in_specified_path_Colon_0, commandLine.options.project), /* compilerHost */ undefined); - return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); + else { + configFileName = fileOrDirectory; + if (!sys.fileExists(configFileName)) { + reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_specified_path_does_not_exist_Colon_0, commandLine.options.project), /* compilerHost */ undefined); + return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); + } } } else if (commandLine.fileNames.length === 0 && isJSONSupported()) {