Skip to content

Commit 34c3233

Browse files
committed
Allow --incremental to be command line option
1 parent 09747e5 commit 34c3233

File tree

19 files changed

+60
-35
lines changed

19 files changed

+60
-35
lines changed

src/compiler/commandLineParser.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,13 @@ namespace ts {
136136
category: Diagnostics.Advanced_Options,
137137
description: Diagnostics.Show_verbose_diagnostic_information
138138
},
139+
{
140+
name: "incremental",
141+
shortName: "i",
142+
type: "boolean",
143+
category: Diagnostics.Basic_Options,
144+
description: Diagnostics.Enable_incremental_compilation,
145+
},
139146
];
140147

141148
/* @internal */
@@ -331,13 +338,6 @@ namespace ts {
331338
category: Diagnostics.Basic_Options,
332339
description: Diagnostics.Enable_project_compilation,
333340
},
334-
{
335-
name: "incremental",
336-
type: "boolean",
337-
isTSConfigOnly: true,
338-
category: Diagnostics.Basic_Options,
339-
description: Diagnostics.Enable_incremental_compilation,
340-
},
341341
{
342342
name: "tsBuildInfoFile",
343343
type: "string",

src/compiler/diagnosticMessages.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3072,6 +3072,10 @@
30723072
"category": "Error",
30733073
"code": 5073
30743074
},
3075+
"Option '--incremental' can only be speicified when using tsconfig.": {
3076+
"category": "Error",
3077+
"code": 5074
3078+
},
30753079

30763080
"Generates a sourcemap for each corresponding '.d.ts' file.": {
30773081
"category": "Message",

src/compiler/program.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2722,6 +2722,10 @@ namespace ts {
27222722
createDiagnosticForOptionName(Diagnostics.Option_paths_cannot_be_used_without_specifying_baseUrl_option, "paths");
27232723
}
27242724

2725+
if (options.incremental && !options.configFilePath) {
2726+
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_incremental_can_only_be_speicified_when_using_tsconfig));
2727+
}
2728+
27252729
if (options.composite) {
27262730
if (options.declaration === false) {
27272731
createDiagnosticForOptionName(Diagnostics.Composite_projects_may_not_disable_declaration_emit, "declaration");

src/compiler/tsbuild.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ namespace ts {
3030
listEmittedFiles?: boolean;
3131
listFiles?: boolean;
3232
pretty?: boolean;
33+
incremental?: boolean;
3334

3435
traceResolution?: boolean;
3536
/* @internal */ diagnostics?: boolean;
@@ -363,7 +364,7 @@ namespace ts {
363364
function getCompilerOptionsOfBuildOptions(buildOptions: BuildOptions): CompilerOptions {
364365
const result = {} as CompilerOptions;
365366
commonOptionsWithBuild.forEach(option => {
366-
result[option.name] = buildOptions[option.name];
367+
if (hasProperty(buildOptions, option.name)) result[option.name] = buildOptions[option.name];
367368
});
368369
return result;
369370
}

src/testRunner/unittests/config/commandLineParsing.ts

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -370,16 +370,9 @@ namespace ts {
370370
// --lib es6 0.ts
371371
assertParseResult(["--incremental", "0.ts"],
372372
{
373-
errors: [{
374-
messageText: "Option 'incremental' can only be specified in 'tsconfig.json' file.",
375-
category: Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file.category,
376-
code: Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file.code,
377-
file: undefined,
378-
start: undefined,
379-
length: undefined,
380-
}],
373+
errors: [],
381374
fileNames: ["0.ts"],
382-
options: {}
375+
options: { incremental: true }
383376
});
384377
});
385378
});
@@ -477,16 +470,9 @@ namespace ts {
477470
// --lib es6 0.ts
478471
assertParseResult(["--incremental", "tests"],
479472
{
480-
errors: [{
481-
messageText: "Unknown build option '--incremental'.",
482-
category: Diagnostics.Unknown_build_option_0.category,
483-
code: Diagnostics.Unknown_build_option_0.code,
484-
file: undefined,
485-
start: undefined,
486-
length: undefined,
487-
}],
473+
errors: [],
488474
projects: ["tests"],
489-
buildOptions: { }
475+
buildOptions: { incremental: true }
490476
});
491477
});
492478

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error TS5074: Option '--incremental' can only be speicified when using tsconfig.
2+
3+
4+
!!! error TS5074: Option '--incremental' can only be speicified when using tsconfig.
5+
==== tests/cases/compiler/invalidIncremental.ts (0 errors) ====
6+
const x = 10;
7+
8+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//// [invalidIncremental.ts]
2+
const x = 10;
3+
4+
5+
6+
//// [invalidIncremental.js]
7+
var x = 10;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
=== tests/cases/compiler/invalidIncremental.ts ===
2+
const x = 10;
3+
>x : Symbol(x, Decl(invalidIncremental.ts, 0, 5))
4+
5+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
=== tests/cases/compiler/invalidIncremental.ts ===
2+
const x = 10;
3+
>x : 10
4+
>10 : 10
5+
6+

tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"compilerOptions": {
33
/* Basic Options */
4+
// "incremental": true, /* Enable incremental compilation */
45
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
56
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
67
// "lib": [], /* Specify library files to be included in the compilation. */
@@ -14,7 +15,6 @@
1415
// "outDir": "./", /* Redirect output structure to the directory. */
1516
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
1617
// "composite": true, /* Enable project compilation */
17-
// "incremental": true, /* Enable incremental compilation */
1818
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
1919
// "removeComments": true, /* Do not emit comments to output. */
2020
// "noEmit": true, /* Do not emit outputs. */

0 commit comments

Comments
 (0)