-
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
Changes from 3 commits
5e5aaa9
fb5c30a
a9c97f3
6baf767
45f24e2
9b4787b
7541cc8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -614,20 +614,27 @@ function executeCommandLineWorker( | |||||
| } | ||||||
| } | ||||||
| } | ||||||
| else if (commandLine.fileNames.length === 0) { | ||||||
| else if (!commandLine.options.ignoreConfig || commandLine.fileNames.length === 0) { | ||||||
|
||||||
| const searchPath = normalizePath(sys.getCurrentDirectory()); | ||||||
| configFileName = findConfigFile(searchPath, fileName => sys.fileExists(fileName)); | ||||||
| } | ||||||
|
|
||||||
| 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) { | ||||||
|
||||||
| // 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.
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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import * as ts from "../../_namespaces/ts.js"; | ||
| import { jsonToReadableText } from "../helpers.js"; | ||
| import { verifyTsc } from "../helpers/tsc.js"; | ||
| import { TestServerHost } from "../helpers/virtualFileSystemWithWatch.js"; | ||
|
|
||
| describe("unittests:: tsc:: ignoreConfig::", () => { | ||
| function sysWithoutConfig() { | ||
| return TestServerHost.createWatchedSystem({ | ||
| "/home/src/workspaces/project/src/a.ts": "export const a = 10;", | ||
| "/home/src/workspaces/project/src/b.ts": "export const b = 10;", | ||
| "/home/src/workspaces/project/c.ts": "export const c = 10;", | ||
| }); | ||
| } | ||
| function sysWithConfig() { | ||
| const sys = sysWithoutConfig(); | ||
| sys.writeFile( | ||
| "/home/src/workspaces/project/tsconfig.json", | ||
| jsonToReadableText({ | ||
| include: ["src"], | ||
| }), | ||
| ); | ||
| return sys; | ||
| } | ||
| function runScenario(subScenario: string, commandLineArgs: readonly string[]) { | ||
| verifyTsc({ | ||
| scenario: "ignoreConfig", | ||
| subScenario, | ||
| sys: sysWithConfig, | ||
| commandLineArgs, | ||
| }); | ||
|
|
||
| verifyTsc({ | ||
| scenario: "ignoreConfig", | ||
| subScenario: subScenario + " with --ignoreConfig", | ||
| sys: sysWithConfig, | ||
| commandLineArgs: commandLineArgs.concat("--ignoreConfig"), | ||
| }); | ||
|
|
||
| verifyTsc({ | ||
| scenario: "ignoreConfig", | ||
| subScenario: subScenario + " when config file absent", | ||
| sys: sysWithoutConfig, | ||
| commandLineArgs, | ||
| }); | ||
|
|
||
| verifyTsc({ | ||
| scenario: "ignoreConfig", | ||
| subScenario: subScenario + " when config file absent with --ignoreConfig", | ||
| sys: sysWithoutConfig, | ||
| commandLineArgs: commandLineArgs.concat("--ignoreConfig"), | ||
| }); | ||
| } | ||
|
|
||
| runScenario("without any options", ts.emptyArray); | ||
| runScenario("specifying files", ["src/a.ts"]); | ||
| runScenario("specifying project", ["-p", "."]); | ||
| runScenario("mixing project and files", ["-p", ".", "src/a.ts", "c.ts"]); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "ignoreConfig": true | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.