Skip to content

Commit 5360b7b

Browse files
committed
Initial change to allow noCheck on commandLine (including build) and tests
1 parent b258429 commit 5360b7b

File tree

66 files changed

+28759
-3261
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+28759
-3261
lines changed

src/compiler/commandLineParser.ts

+20-23
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,26 @@ export const commonOptionsWithBuild: CommandLineOption[] = [
502502
description: Diagnostics.Include_sourcemap_files_inside_the_emitted_JavaScript,
503503
defaultValueDescription: false,
504504
},
505+
{
506+
name: "noCheck",
507+
type: "boolean",
508+
showInSimplifiedHelpView: false,
509+
category: Diagnostics.Compiler_Diagnostics,
510+
description: Diagnostics.Disable_full_type_checking_only_critical_parse_and_emit_errors_will_be_reported,
511+
transpileOptionValue: true,
512+
defaultValueDescription: false,
513+
affectsSemanticDiagnostics: true,
514+
affectsBuildInfo: true,
515+
},
516+
{
517+
name: "noEmit",
518+
type: "boolean",
519+
showInSimplifiedHelpView: true,
520+
category: Diagnostics.Emit,
521+
description: Diagnostics.Disable_emitting_files_from_a_compilation,
522+
transpileOptionValue: undefined,
523+
defaultValueDescription: false,
524+
},
505525
{
506526
name: "assumeChangesOnlyAffectDirectDependencies",
507527
type: "boolean",
@@ -772,29 +792,6 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
772792
defaultValueDescription: false,
773793
description: Diagnostics.Disable_emitting_comments,
774794
},
775-
{
776-
name: "noCheck",
777-
type: "boolean",
778-
showInSimplifiedHelpView: false,
779-
category: Diagnostics.Compiler_Diagnostics,
780-
description: Diagnostics.Disable_full_type_checking_only_critical_parse_and_emit_errors_will_be_reported,
781-
transpileOptionValue: true,
782-
defaultValueDescription: false,
783-
affectsSemanticDiagnostics: true,
784-
affectsBuildInfo: true,
785-
extraValidation() {
786-
return [Diagnostics.Unknown_compiler_option_0, "noCheck"];
787-
},
788-
},
789-
{
790-
name: "noEmit",
791-
type: "boolean",
792-
showInSimplifiedHelpView: true,
793-
category: Diagnostics.Emit,
794-
description: Diagnostics.Disable_emitting_files_from_a_compilation,
795-
transpileOptionValue: undefined,
796-
defaultValueDescription: false,
797-
},
798795
{
799796
name: "importHelpers",
800797
type: "boolean",

src/testRunner/tests.ts

+1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ export * from "./unittests/tsc/incremental.js";
122122
export * from "./unittests/tsc/libraryResolution.js";
123123
export * from "./unittests/tsc/listFilesOnly.js";
124124
export * from "./unittests/tsc/moduleResolution.js";
125+
export * from "./unittests/tsc/noCheck.js";
125126
export * from "./unittests/tsc/noEmit.js";
126127
export * from "./unittests/tsc/noEmitOnError.js";
127128
export * from "./unittests/tsc/projectReferences.js";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import { jsonToReadableText } from "../helpers.js";
2+
import {
3+
noChangeRun,
4+
TestTscEdit,
5+
verifyTsc,
6+
} from "./tsc.js";
7+
import { loadProjectFromFiles } from "./vfs.js";
8+
9+
export function forEachTscScenarioWithNoCheck(buildType: "-b" | "-p") {
10+
const commandLineArgs = buildType === "-b" ?
11+
["-b", "/src/tsconfig.json", "-v"] :
12+
["-p", "/src/tsconfig.json"];
13+
14+
function forEachNoCheckScenarioWorker(
15+
subScenario: string,
16+
aText: string,
17+
) {
18+
const checkNoChangeRun: TestTscEdit = {
19+
...noChangeRun,
20+
caption: "No Change run with checking",
21+
commandLineArgs,
22+
};
23+
const noCheckFixError: TestTscEdit = {
24+
caption: "Fix `a` error with noCheck",
25+
edit: fs => fs.writeFileSync("/src/a.ts", `export const a = "hello";`),
26+
};
27+
const noCheckError: TestTscEdit = {
28+
caption: "Introduce error with noCheck",
29+
edit: fs => fs.writeFileSync("/src/a.ts", aText),
30+
};
31+
32+
[undefined, true].forEach(incremental => {
33+
[{}, { module: "amd", outFile: "../outFile.js" }].forEach(options => {
34+
verifyTsc({
35+
scenario: "noCheck",
36+
subScenario: `${options.outFile ? "outFile" : "multiFile"}/${subScenario}${incremental ? " with incremental" : ""}`,
37+
fs: () =>
38+
loadProjectFromFiles({
39+
"/src/a.ts": aText,
40+
"/src/b.ts": `export const b = 10;`,
41+
"/src/tsconfig.json": jsonToReadableText({
42+
compilerOptions: {
43+
declaration: true,
44+
incremental,
45+
...options,
46+
},
47+
}),
48+
}),
49+
commandLineArgs: [...commandLineArgs, "--noCheck"],
50+
edits: [
51+
noChangeRun, // Should be no op
52+
noCheckFixError, // Fix error with noCheck
53+
noChangeRun, // Should be no op
54+
checkNoChangeRun, // Check errors - should not report any errors - update buildInfo
55+
checkNoChangeRun, // Should be no op
56+
noChangeRun, // Should be no op
57+
noCheckError,
58+
noChangeRun, // Should be no op
59+
checkNoChangeRun, // Should check errors and update buildInfo
60+
noCheckFixError, // Fix error with noCheck
61+
checkNoChangeRun, // Should check errors and update buildInfo
62+
{
63+
caption: "Add file with error",
64+
edit: fs => fs.writeFileSync("/src/c.ts", `export const c: number = "hello";`),
65+
commandLineArgs,
66+
},
67+
noCheckError,
68+
noCheckFixError,
69+
checkNoChangeRun,
70+
noChangeRun, // Should be no op
71+
checkNoChangeRun, // Should be no op
72+
],
73+
baselinePrograms: true,
74+
});
75+
});
76+
});
77+
}
78+
forEachNoCheckScenarioWorker("syntax errors", `export const a = "hello`);
79+
forEachNoCheckScenarioWorker("semantic errors", `export const a: number = "hello";`);
80+
forEachNoCheckScenarioWorker("dts errors", `export const a = class { private p = 10; };`);
81+
}
+3-84
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,5 @@
1-
import {
2-
CommandLineOption,
3-
optionDeclarations,
4-
} from "../../_namespaces/ts.js";
5-
import { jsonToReadableText } from "../helpers.js";
6-
import {
7-
noChangeRun,
8-
verifyTsc,
9-
} from "../helpers/tsc.js";
10-
import { loadProjectFromFiles } from "../helpers/vfs.js";
1+
import { forEachTscScenarioWithNoCheck } from "../helpers/noCheck.js";
112

12-
function verifyNoCheckFlag(variant: string) {
13-
function verifyNoCheckWorker(subScenario: string, declAText: string, commandLineArgs: readonly string[]) {
14-
verifyTsc({
15-
scenario: variant,
16-
subScenario,
17-
fs: () =>
18-
loadProjectFromFiles({
19-
"/src/a.ts": getATsContent(declAText),
20-
"/src/tsconfig.json": jsonToReadableText({
21-
compilerOptions: { noCheck: true, emitDeclarationOnly: true, declaration: true },
22-
}),
23-
}),
24-
commandLineArgs,
25-
edits: [
26-
noChangeRun,
27-
{
28-
caption: "Fix `a` error",
29-
edit: fs => fs.writeFileSync("/src/a.ts", getATsContent(`const a = "hello"`)),
30-
},
31-
noChangeRun,
32-
{
33-
caption: "Disable noCheck",
34-
edit: fs =>
35-
fs.writeFileSync(
36-
"/src/tsconfig.json",
37-
jsonToReadableText({
38-
compilerOptions: { emitDeclarationOnly: true, declaration: true },
39-
}),
40-
),
41-
},
42-
noChangeRun,
43-
],
44-
baselinePrograms: true,
45-
});
46-
47-
function getATsContent(declAText: string) {
48-
return `const err: number = "error";
49-
${declAText}`;
50-
}
51-
}
52-
53-
function verifyNoCheck(subScenario: string, aTsContent: string) {
54-
verifyNoCheckWorker(subScenario, aTsContent, ["--b", "/src/tsconfig.json", "-v"]);
55-
verifyNoCheckWorker(`${subScenario} with incremental`, aTsContent, ["--b", "/src/tsconfig.json", "-v", "--incremental"]);
56-
}
57-
58-
verifyNoCheck("syntax errors", `const a = "hello`);
59-
verifyNoCheck("semantic errors", `const a: number = "hello"`);
60-
}
61-
62-
describe("unittests:: tsbuild:: noCheck", () => {
63-
// Enable the `noCheck` option on the CLI for testing purposes, to ensure it works with incremental/build
64-
let validate: CommandLineOption["extraValidation"];
65-
before(() => {
66-
for (const opt of optionDeclarations) {
67-
if (opt.name === "noCheck") {
68-
validate = opt.extraValidation;
69-
opt.extraValidation = () => undefined;
70-
}
71-
}
72-
});
73-
after(() => {
74-
for (const opt of optionDeclarations) {
75-
if (opt.name === "noCheck") {
76-
opt.extraValidation = validate;
77-
}
78-
}
79-
});
80-
81-
verifyNoCheckFlag("noCheck");
82-
});
83-
84-
describe("unittests:: tsbuild:: noCheck:: errors", () => {
85-
verifyNoCheckFlag("noCheck-errors");
3+
describe("unittests:: tsbuild:: noCheck::", () => {
4+
forEachTscScenarioWithNoCheck("-b");
865
});
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { forEachTscScenarioWithNoCheck } from "../helpers/noCheck.js";
2+
3+
describe("unittests:: tsc:: noCheck::", () => {
4+
forEachTscScenarioWithNoCheck("-p");
5+
});

tests/baselines/reference/config/initTSConfig/Default initialized TSConfig/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@
5454
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
5555
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
5656
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
57+
// "noEmit": true, /* Disable emitting files from a compilation. */
5758
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
5859
// "outDir": "./", /* Specify an output folder for all emitted files. */
5960
// "removeComments": true, /* Disable emitting comments. */
60-
// "noEmit": true, /* Disable emitting files from a compilation. */
6161
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
6262
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
6363
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */

tests/baselines/reference/config/initTSConfig/Initialized TSConfig with --help/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@
5454
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
5555
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
5656
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
57+
// "noEmit": true, /* Disable emitting files from a compilation. */
5758
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
5859
// "outDir": "./", /* Specify an output folder for all emitted files. */
5960
// "removeComments": true, /* Disable emitting comments. */
60-
// "noEmit": true, /* Disable emitting files from a compilation. */
6161
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
6262
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
6363
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */

tests/baselines/reference/config/initTSConfig/Initialized TSConfig with --watch/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@
5454
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
5555
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
5656
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
57+
// "noEmit": true, /* Disable emitting files from a compilation. */
5758
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
5859
// "outDir": "./", /* Specify an output folder for all emitted files. */
5960
// "removeComments": true, /* Disable emitting comments. */
60-
// "noEmit": true, /* Disable emitting files from a compilation. */
6161
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
6262
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
6363
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */

tests/baselines/reference/config/initTSConfig/Initialized TSConfig with advanced options/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@
5454
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
5555
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
5656
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
57+
// "noEmit": true, /* Disable emitting files from a compilation. */
5758
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
5859
// "outDir": "./", /* Specify an output folder for all emitted files. */
5960
// "removeComments": true, /* Disable emitting comments. */
60-
// "noEmit": true, /* Disable emitting files from a compilation. */
6161
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
6262
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
6363
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */

tests/baselines/reference/config/initTSConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@
5454
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
5555
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
5656
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
57+
// "noEmit": true, /* Disable emitting files from a compilation. */
5758
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
5859
// "outDir": "./", /* Specify an output folder for all emitted files. */
5960
// "removeComments": true, /* Disable emitting comments. */
60-
// "noEmit": true, /* Disable emitting files from a compilation. */
6161
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
6262
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
6363
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */

tests/baselines/reference/config/initTSConfig/Initialized TSConfig with enum value compiler options/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@
5454
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
5555
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
5656
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
57+
// "noEmit": true, /* Disable emitting files from a compilation. */
5758
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
5859
// "outDir": "./", /* Specify an output folder for all emitted files. */
5960
// "removeComments": true, /* Disable emitting comments. */
60-
// "noEmit": true, /* Disable emitting files from a compilation. */
6161
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
6262
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
6363
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */

tests/baselines/reference/config/initTSConfig/Initialized TSConfig with files options/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@
5454
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
5555
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
5656
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
57+
// "noEmit": true, /* Disable emitting files from a compilation. */
5758
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
5859
// "outDir": "./", /* Specify an output folder for all emitted files. */
5960
// "removeComments": true, /* Disable emitting comments. */
60-
// "noEmit": true, /* Disable emitting files from a compilation. */
6161
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
6262
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
6363
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */

0 commit comments

Comments
 (0)