mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-13 11:46:08 -05:00
Add --ignoreConfig and dont allow specifying files on commandline without it if there is config file present (#62477)
This commit is contained in:
@@ -119,6 +119,7 @@ export * from "./unittests/tsc/composite.js";
|
||||
export * from "./unittests/tsc/declarationEmit.js";
|
||||
export * from "./unittests/tsc/extends.js";
|
||||
export * from "./unittests/tsc/forceConsistentCasingInFileNames.js";
|
||||
export * from "./unittests/tsc/ignoreConfig.js";
|
||||
export * from "./unittests/tsc/incremental.js";
|
||||
export * from "./unittests/tsc/libraryResolution.js";
|
||||
export * from "./unittests/tsc/listFilesOnly.js";
|
||||
|
||||
58
src/testRunner/unittests/tsc/ignoreConfig.ts
Normal file
58
src/testRunner/unittests/tsc/ignoreConfig.ts
Normal file
@@ -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"]);
|
||||
});
|
||||
@@ -424,7 +424,7 @@ declare module "fs" {
|
||||
],
|
||||
});
|
||||
}
|
||||
verifyIgnore("watch without configFile", ["--w", `/user/username/projects/myproject/test.ts`]);
|
||||
verifyIgnore("watch without configFile", ["--w", "--ignoreConfig", `/user/username/projects/myproject/test.ts`]);
|
||||
verifyIgnore("watch with configFile", ["--w", "-p", `/user/username/projects/myproject/tsconfig.json`]);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user