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 1 commit
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
Prev Previous commit
Next Next commit
Fix --showConfig to work when no input files are found
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
  • Loading branch information
Copilot and RyanCavanaugh committed Jul 11, 2025
commit d4fb9b4068beba8fae7e125643269c8ea210581e
31 changes: 18 additions & 13 deletions src/compiler/executeCommandLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -638,19 +638,24 @@ function executeCommandLineWorker(
if (configFileName) {
const extendedConfigCache = new Map<string, ExtendedConfigCacheEntry>();
const configParseResult = parseConfigFileWithSystem(configFileName, commandLineOptions, extendedConfigCache, commandLine.watchOptions, sys, reportDiagnostic)!; // TODO: GH#18217
if (commandLineOptions.showConfig) {
if (configParseResult.errors.length !== 0) {
reportDiagnostic = updateReportDiagnostic(
sys,
reportDiagnostic,
configParseResult.options,
);
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);
if (commandLineOptions.showConfig) {
// For --showConfig, filter out "no inputs found" errors since the purpose is to show configuration, not compile
const errorsExcludingNoInputs = configParseResult.errors.filter(error =>
error.code !== Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2.code
);

if (errorsExcludingNoInputs.length !== 0) {
reportDiagnostic = updateReportDiagnostic(
sys,
reportDiagnostic,
configParseResult.options,
);
errorsExcludingNoInputs.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(
sys,
Expand Down
11 changes: 8 additions & 3 deletions src/testRunner/unittests/config/showConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,14 @@ describe("unittests:: config:: showConfig", () => {
include: [
"${configDir}/src/**/*", // eslint-disable-line no-template-curly-in-string
],
files: ["${configDir}/main.ts"], // eslint-disable-line no-template-curly-in-string
});

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
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy