Skip to content

Commit

Permalink
switch to better user-facing name, matches default of true
Browse files Browse the repository at this point in the history
internal name remains to match default falsy value of undefined.
  • Loading branch information
KiaraGrouwstra committed Aug 17, 2017
1 parent 601f5f2 commit 7b9bf2c
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ namespace ts {
const noUnusedIdentifiers = !!compilerOptions.noUnusedLocals || !!compilerOptions.noUnusedParameters;
const allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === ModuleKind.System;
const strictNullChecks = compilerOptions.strictNullChecks === undefined ? compilerOptions.strict : compilerOptions.strictNullChecks;
const granularConst = compilerOptions.granularConst;
const widenTypes = compilerOptions.widenTypes === undefined ? true : compilerOptions.widenTypes;
const granularConst = !widenTypes;
const noImplicitAny = compilerOptions.noImplicitAny === undefined ? compilerOptions.strict : compilerOptions.noImplicitAny;
const noImplicitThis = compilerOptions.noImplicitThis === undefined ? compilerOptions.strict : compilerOptions.noImplicitThis;

Expand Down
4 changes: 2 additions & 2 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,11 @@ namespace ts {
description: Diagnostics.Enable_strict_null_checks
},
{
name: "granularConst",
name: "widenTypes",
type: "boolean",
showInSimplifiedHelpView: true,
category: Diagnostics.Strict_Type_Checking_Options,
description: Diagnostics.Enable_granular_type_inference_using_const
description: Diagnostics.Automatically_widen_types_even_in_params_and_const
},
{
name: "noImplicitThis",
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -3302,7 +3302,7 @@
"category": "Message",
"code": 6185
},
"Enable granular type inference using `const`.": {
"Automatically widen types even in params and `const`.": {
"category": "Message",
"code": 6186
},
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3622,7 +3622,7 @@ namespace ts {
sourceRoot?: string;
strict?: boolean;
strictNullChecks?: boolean; // Always combine with strict property
granularConst?: boolean;
widenTypes?: boolean;
/* @internal */ stripInternal?: boolean;
suppressExcessPropertyErrors?: boolean;
suppressImplicitAnyIndexErrors?: boolean;
Expand Down
4 changes: 2 additions & 2 deletions src/harness/unittests/configurationExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ namespace ts {
strictNullChecks: false
}
},
"/dev/tsconfig.granularconst.json": {
"/dev/tsconfig.widenTypes.json": {
extends: "./tsconfig",
compilerOptions: {
granularConst: true
widenTypes: false
}
},
"/dev/configs/base.json": {
Expand Down
4 changes: 2 additions & 2 deletions src/harness/unittests/transpile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,8 @@ var x = 0;`, {
options: { compilerOptions: { strictNullChecks: true }, fileName: "input.js", reportDiagnostics: true }
});

transpilesCorrectly("Supports setting 'granularConst'", "x;", {
options: { compilerOptions: { granularConst: true }, fileName: "input.js", reportDiagnostics: true }
transpilesCorrectly("Supports setting 'widenTypes'", "x;", {
options: { compilerOptions: { widenTypes: true }, fileName: "input.js", reportDiagnostics: true }
});

transpilesCorrectly("Supports setting 'stripInternal'", "x;", {
Expand Down
2 changes: 1 addition & 1 deletion src/server/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2448,7 +2448,7 @@ namespace ts.server.protocol {
sourceRoot?: string;
strict?: boolean;
strictNullChecks?: boolean;
granularConst?: boolean;
widenTypes?: boolean;
suppressExcessPropertyErrors?: boolean;
suppressImplicitAnyIndexErrors?: boolean;
target?: ScriptTarget | ts.ScriptTarget;
Expand Down
2 changes: 1 addition & 1 deletion tests/cases/compiler/dontWiden.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @granularConst: true
// @widenTypes: false

const c = [1, 'a'];
const d = { a: 1, b: 'c' };
Expand Down

0 comments on commit 7b9bf2c

Please sign in to comment.