Skip to content

Commit 320adf5

Browse files
a-tarasyukDanielRosenwasser
authored andcommitted
show an error if --showConfig is enabled and tsconfig.json does not exist (#35723)
1 parent a39a675 commit 320adf5

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/compiler/diagnosticMessages.json

+4
Original file line numberDiff line numberDiff line change
@@ -3329,6 +3329,10 @@
33293329
"category": "Error",
33303330
"code": 5080
33313331
},
3332+
"Cannot find a tsconfig.json file at the current directory: {0}.": {
3333+
"category": "Error",
3334+
"code": 5081
3335+
},
33323336

33333337
"Generates a sourcemap for each corresponding '.d.ts' file.": {
33343338
"category": "Message",

src/executeCommandLine/executeCommandLine.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,15 @@ namespace ts {
241241
}
242242

243243
if (commandLine.fileNames.length === 0 && !configFileName) {
244-
printVersion(sys);
245-
printHelp(sys, getOptionsForHelp(commandLine));
246-
return sys.exit(ExitStatus.Success);
244+
if (commandLine.options.showConfig) {
245+
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Cannot_find_a_tsconfig_json_file_at_the_current_directory_Colon_0, normalizePath(sys.getCurrentDirectory())));
246+
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
247+
}
248+
else {
249+
printVersion(sys);
250+
printHelp(sys, getOptionsForHelp(commandLine));
251+
return sys.exit(ExitStatus.Success);
252+
}
247253
}
248254

249255
const currentDirectory = sys.getCurrentDirectory();

0 commit comments

Comments
 (0)