Skip to content

Commit 7b9bf2c

Browse files
switch to better user-facing name, matches default of true
internal name remains to match default falsy value of undefined.
1 parent 601f5f2 commit 7b9bf2c

File tree

8 files changed

+12
-11
lines changed

8 files changed

+12
-11
lines changed

Diff for: src/compiler/checker.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ namespace ts {
6464
const noUnusedIdentifiers = !!compilerOptions.noUnusedLocals || !!compilerOptions.noUnusedParameters;
6565
const allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === ModuleKind.System;
6666
const strictNullChecks = compilerOptions.strictNullChecks === undefined ? compilerOptions.strict : compilerOptions.strictNullChecks;
67-
const granularConst = compilerOptions.granularConst;
67+
const widenTypes = compilerOptions.widenTypes === undefined ? true : compilerOptions.widenTypes;
68+
const granularConst = !widenTypes;
6869
const noImplicitAny = compilerOptions.noImplicitAny === undefined ? compilerOptions.strict : compilerOptions.noImplicitAny;
6970
const noImplicitThis = compilerOptions.noImplicitThis === undefined ? compilerOptions.strict : compilerOptions.noImplicitThis;
7071

Diff for: src/compiler/commandLineParser.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -270,11 +270,11 @@ namespace ts {
270270
description: Diagnostics.Enable_strict_null_checks
271271
},
272272
{
273-
name: "granularConst",
273+
name: "widenTypes",
274274
type: "boolean",
275275
showInSimplifiedHelpView: true,
276276
category: Diagnostics.Strict_Type_Checking_Options,
277-
description: Diagnostics.Enable_granular_type_inference_using_const
277+
description: Diagnostics.Automatically_widen_types_even_in_params_and_const
278278
},
279279
{
280280
name: "noImplicitThis",

Diff for: src/compiler/diagnosticMessages.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3302,7 +3302,7 @@
33023302
"category": "Message",
33033303
"code": 6185
33043304
},
3305-
"Enable granular type inference using `const`.": {
3305+
"Automatically widen types even in params and `const`.": {
33063306
"category": "Message",
33073307
"code": 6186
33083308
},

Diff for: src/compiler/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3622,7 +3622,7 @@ namespace ts {
36223622
sourceRoot?: string;
36233623
strict?: boolean;
36243624
strictNullChecks?: boolean; // Always combine with strict property
3625-
granularConst?: boolean;
3625+
widenTypes?: boolean;
36263626
/* @internal */ stripInternal?: boolean;
36273627
suppressExcessPropertyErrors?: boolean;
36283628
suppressImplicitAnyIndexErrors?: boolean;

Diff for: src/harness/unittests/configurationExtension.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ namespace ts {
1616
strictNullChecks: false
1717
}
1818
},
19-
"/dev/tsconfig.granularconst.json": {
19+
"/dev/tsconfig.widenTypes.json": {
2020
extends: "./tsconfig",
2121
compilerOptions: {
22-
granularConst: true
22+
widenTypes: false
2323
}
2424
},
2525
"/dev/configs/base.json": {

Diff for: src/harness/unittests/transpile.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,8 @@ var x = 0;`, {
413413
options: { compilerOptions: { strictNullChecks: true }, fileName: "input.js", reportDiagnostics: true }
414414
});
415415

416-
transpilesCorrectly("Supports setting 'granularConst'", "x;", {
417-
options: { compilerOptions: { granularConst: true }, fileName: "input.js", reportDiagnostics: true }
416+
transpilesCorrectly("Supports setting 'widenTypes'", "x;", {
417+
options: { compilerOptions: { widenTypes: true }, fileName: "input.js", reportDiagnostics: true }
418418
});
419419

420420
transpilesCorrectly("Supports setting 'stripInternal'", "x;", {

Diff for: src/server/protocol.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2448,7 +2448,7 @@ namespace ts.server.protocol {
24482448
sourceRoot?: string;
24492449
strict?: boolean;
24502450
strictNullChecks?: boolean;
2451-
granularConst?: boolean;
2451+
widenTypes?: boolean;
24522452
suppressExcessPropertyErrors?: boolean;
24532453
suppressImplicitAnyIndexErrors?: boolean;
24542454
target?: ScriptTarget | ts.ScriptTarget;

Diff for: tests/cases/compiler/dontWiden.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// @granularConst: true
1+
// @widenTypes: false
22

33
const c = [1, 'a'];
44
const d = { a: 1, b: 'c' };

0 commit comments

Comments
 (0)