-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Add --ignoreConfig and dont allow specifying files on commandline without it if there is config file present #62477
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
Conversation
|
I just realised that this was marked as draft unintentionally for many days. Sorry about that. |
There was a problem hiding this 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
--ignoreConfigcompiler option to bypass tsconfig.json discovery - Enforces error when files are specified on command line with tsconfig.json present (unless
--ignoreConfigis 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) { |
Copilot
AI
Nov 24, 2025
There was a problem hiding this comment.
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.
| // if (!commandLine.options.ignoreConfig) { | |
| // if (!commandLine.options.ignoreConfig) { | ||
| if (commandLine.fileNames.length !== 0) { | ||
| if (configFileName) { | ||
| // Error to not specify config file |
Copilot
AI
Nov 24, 2025
There was a problem hiding this comment.
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.
| // Error to not specify config file | |
| // Error when files are specified on command line but tsconfig.json is present |
| } | ||
| } | ||
| else if (commandLine.fileNames.length === 0) { | ||
| else if (!commandLine.options.ignoreConfig || commandLine.fileNames.length === 0) { |
Copilot
AI
Nov 24, 2025
There was a problem hiding this comment.
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.
Fixes #62197