Skip to content

Conversation

@sheetalkamat
Copy link
Member

@sheetalkamat sheetalkamat commented Sep 22, 2025

Fixes #62197

@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Sep 22, 2025
@sheetalkamat sheetalkamat changed the title Add --ignoreConfig Add --ignoreConfig and dont allow specifying files on commandline without it if there is config file present Sep 25, 2025
@sheetalkamat sheetalkamat marked this pull request as ready for review November 24, 2025 19:49
Copilot AI review requested due to automatic review settings November 24, 2025 19:49
@sheetalkamat
Copy link
Member Author

I just realised that this was marked as draft unintentionally for many days. Sorry about that.

@sheetalkamat sheetalkamat merged commit 669c25c into main Nov 24, 2025
36 of 37 checks passed
@sheetalkamat sheetalkamat deleted the ignoreConfig branch November 24, 2025 19:50
Copilot finished reviewing on behalf of sheetalkamat November 24, 2025 19:51
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements a new --ignoreConfig command-line flag for the TypeScript compiler that addresses issue #62197. The flag allows users to explicitly ignore any tsconfig.json file and compile with command-line options and files instead. Additionally, it introduces a breaking behavior change: when files are specified on the command line and a tsconfig.json is present, the compiler now requires the --ignoreConfig flag to proceed.

Key Changes:

  • Adds --ignoreConfig compiler option to bypass tsconfig.json discovery
  • Enforces error when files are specified on command line with tsconfig.json present (unless --ignoreConfig is used)
  • Updates help text to document the new flag

Reviewed changes

Copilot reviewed 30 out of 30 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/compiler/types.ts Adds ignoreConfig boolean property to CompilerOptions interface
src/compiler/commandLineParser.ts Defines the --ignoreConfig command-line option with help text
src/compiler/executeCommandLine.ts Implements logic to handle --ignoreConfig flag and error when files conflict with tsconfig.json
src/compiler/diagnosticMessages.json Adds two new diagnostic messages for the flag description and error
src/testRunner/unittests/tsc/ignoreConfig.ts New test file with comprehensive test scenarios for the flag
src/testRunner/unittests/tscWatch/resolutionCache.ts Updates existing test to include --ignoreConfig when needed
src/testRunner/tests.ts Exports the new ignoreConfig test module
tests/baselines/reference/* Updates test baselines for help commands and adds baselines for new ignoreConfig tests

if (commandLine.fileNames.length === 0 && !configFileName) {
if (commandLine.options.showConfig) {
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Cannot_find_a_tsconfig_json_file_at_the_current_directory_Colon_0, normalizePath(sys.getCurrentDirectory())));
// if (!commandLine.options.ignoreConfig) {
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove commented-out code. This leftover comment should be deleted as it doesn't serve any purpose and clutters the implementation.

Suggested change
// if (!commandLine.options.ignoreConfig) {

Copilot uses AI. Check for mistakes.
// if (!commandLine.options.ignoreConfig) {
if (commandLine.fileNames.length !== 0) {
if (configFileName) {
// Error to not specify config file
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is unclear and grammatically incorrect. It should be "Error when files are specified on command line but tsconfig.json is present" to accurately describe what's happening.

Suggested change
// Error to not specify config file
// Error when files are specified on command line but tsconfig.json is present

Copilot uses AI. Check for mistakes.
}
}
else if (commandLine.fileNames.length === 0) {
else if (!commandLine.options.ignoreConfig || commandLine.fileNames.length === 0) {
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The logic here is hard to follow. When ignoreConfig is true AND fileNames.length > 0, this condition is false and configFileName remains undefined (desired). When ignoreConfig is false OR no files specified, we search for config. Consider extracting this condition to a named boolean variable like shouldSearchForConfig to improve readability.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error if command-line options are specified when a tsconfig.json is present

5 participants