Skip to content

Fix --showConfig to work when no input files are found #62047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/compiler/executeCommandLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,8 @@ function executeCommandLineWorker(
const extendedConfigCache = new Map<string, ExtendedConfigCacheEntry>();
const configParseResult = parseConfigFileWithSystem(configFileName, commandLineOptions, extendedConfigCache, commandLine.watchOptions, sys, reportDiagnostic)!; // TODO: GH#18217
if (commandLineOptions.showConfig) {
// eslint-disable-next-line no-restricted-syntax
sys.write(JSON.stringify(convertToTSConfig(configParseResult, configFileName, sys), null, 4) + sys.newLine);
if (configParseResult.errors.length !== 0) {
reportDiagnostic = updateReportDiagnostic(
sys,
Expand All @@ -648,8 +650,6 @@ function executeCommandLineWorker(
configParseResult.errors.forEach(reportDiagnostic);
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
}
// eslint-disable-next-line no-restricted-syntax
sys.write(JSON.stringify(convertToTSConfig(configParseResult, configFileName, sys), null, 4) + sys.newLine);
return sys.exit(ExitStatus.Success);
}
reportDiagnostic = updateReportDiagnostic(
Expand Down
5 changes: 5 additions & 0 deletions src/testRunner/unittests/config/showConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ describe("unittests:: config:: showConfig", () => {
files: ["${configDir}/main.ts"], // eslint-disable-line no-template-curly-in-string
});

// Test that --showConfig works even when no input files are found
showTSConfigCorrectly("Show TSConfig with no input files", ["-p", "tsconfig.json"], {
include: ["./*"],
});

// Bulk validation of all option declarations
for (const option of ts.optionDeclarations) {
baselineOption(option, /*isCompilerOptions*/ true);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compilerOptions": {},
"include": [
"./*"
]
}
Loading