From 0a1eabc9aa494f3ca0e0f1335dffbfa14bc47940 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 9 Dec 2014 14:08:44 -0800 Subject: [PATCH 1/4] Add new compiler flag to suppress noImplicitAny errors for object access --- src/compiler/checker.ts | 2 +- src/compiler/commandLineParser.ts | 11 +- .../diagnosticInformationMap.generated.ts | 3 + src/compiler/diagnosticMessages.json | 13 ++ src/compiler/parser.ts | 2 +- src/compiler/types.ts | 7 +- src/harness/harness.ts | 12 +- .../noImplicitAnyIndexingSuppressed.js | 81 ++++++++++++ .../noImplicitAnyIndexingSuppressed.types | 118 ++++++++++++++++++ .../noImplicitAnyIndexingSuppressed.ts | 49 ++++++++ 10 files changed, 292 insertions(+), 6 deletions(-) create mode 100644 tests/baselines/reference/noImplicitAnyIndexingSuppressed.js create mode 100644 tests/baselines/reference/noImplicitAnyIndexingSuppressed.types create mode 100644 tests/cases/compiler/noImplicitAnyIndexingSuppressed.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6d913f7360cb9..81450948b68a7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5385,7 +5385,7 @@ module ts { } // Fall back to any. - if (compilerOptions.noImplicitAny && objectType !== anyType) { + if (compilerOptions.noImplicitAny && (compilerOptions.suppress & ErrorGroup.ImplicitAnyIndex) === 0 && objectType !== anyType) { error(node, Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type); } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 3fabf6c8588ac..394a1422543cb 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -128,9 +128,16 @@ module ts { name: "preserveConstEnums", type: "boolean", description: Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code - } + }, + { + name: "suppress", + type: { "implicitanyindex": ErrorGroup.ImplicitAnyIndex}, + description: Diagnostics.Suppress_a_set_of_compiler_checks, + paramType: Diagnostics.ERRORGROUP, + error: Diagnostics.Argument_for_suppress_option_can_only_be_implicitAnyIndex + }, ]; - + var shortOptionNames: Map = {}; var optionNameMap: Map = {}; diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 7377c42b238cc..75c73ccde172f 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -398,6 +398,7 @@ module ts { VERSION: { code: 6036, category: DiagnosticCategory.Message, key: "VERSION" }, LOCATION: { code: 6037, category: DiagnosticCategory.Message, key: "LOCATION" }, DIRECTORY: { code: 6038, category: DiagnosticCategory.Message, key: "DIRECTORY" }, + ERRORGROUP: { code: 6039, category: DiagnosticCategory.Message, key: "ERRORGROUP" }, Compilation_complete_Watching_for_file_changes: { code: 6042, category: DiagnosticCategory.Message, key: "Compilation complete. Watching for file changes." }, Generates_corresponding_map_file: { code: 6043, category: DiagnosticCategory.Message, key: "Generates corresponding '.map' file." }, Compiler_option_0_expects_an_argument: { code: 6044, category: DiagnosticCategory.Error, key: "Compiler option '{0}' expects an argument." }, @@ -411,6 +412,8 @@ module ts { Warn_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: DiagnosticCategory.Message, key: "Warn on expressions and declarations with an implied 'any' type." }, File_0_not_found: { code: 6053, category: DiagnosticCategory.Error, key: "File '{0}' not found." }, File_0_must_have_extension_ts_or_d_ts: { code: 6054, category: DiagnosticCategory.Error, key: "File '{0}' must have extension '.ts' or '.d.ts'." }, + Suppress_a_set_of_compiler_checks: { code: 6055, category: DiagnosticCategory.Message, key: "Suppress a set of compiler checks." }, + Argument_for_suppress_option_can_only_be_implicitAnyIndex: { code: 6056, category: DiagnosticCategory.Error, key: "Argument for '--suppress' option can only be 'implicitAnyIndex'." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index f0dba54e1a1a4..54ca28e69acd3 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1591,6 +1591,10 @@ "category": "Message", "code": 6038 }, + "ERRORGROUP": { + "category": "Message", + "code": 6039 + }, "Compilation complete. Watching for file changes.": { "category": "Message", "code": 6042 @@ -1643,6 +1647,15 @@ "category": "Error", "code": 6054 }, + "Suppress a set of compiler checks.": { + "category": "Message", + "code": 6055 + }, + "Argument for '--suppress' option can only be 'implicitAnyIndex'.": { + "category": "Error", + "code": 6056 + }, + "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index deb2eb17fc8db..ec6a78496383e 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -27,7 +27,7 @@ module ts { node.parserContextFlags |= ParserContextFlags.ContainsError; } - // Also mark that we've propogated the child information to this node. This way we can + // Also mark that we've propagated the child information to this node. This way we can // always consult the bit directly on this node without needing to check its children // again. node.parserContextFlags |= ParserContextFlags.HasPropagatedChildContainsErrorFlag; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index c2d57876e6a76..ecfb266f08806 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1381,6 +1381,7 @@ module ts { watch?: boolean; preserveConstEnums?: boolean; allowNonTsExtensions?: boolean; + suppress?: ErrorGroup; [option: string]: string | number | boolean; } @@ -1555,7 +1556,11 @@ module ts { tab = 0x09, // \t verticalTab = 0x0B, // \v } - + + export const enum ErrorGroup { + ImplicitAnyIndex = 0x01 + } + export interface CancellationToken { isCancellationRequested(): boolean; } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index c0d3ddedce325..d94804375db6c 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -777,6 +777,16 @@ module Harness { case 'preserveconstenums': options.preserveConstEnums = setting.value === 'true'; break; + + case 'suppress': + if (typeof setting.value === 'string' && setting.value.toLowerCase() === 'implicitanyindex') { + options.suppress = ts.ErrorGroup.ImplicitAnyIndex; + } + else { + throw new Error('Unkown value for suppress ' + setting.value); + } + break; + default: throw new Error('Unsupported compiler setting ' + setting.flag); } @@ -1162,7 +1172,7 @@ module Harness { var optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines // List of allowed metadata names - var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noemitonerror","noimplicitany", "noresolve", "newline", "newlines", "emitbom", "errortruncation", "usecasesensitivefilenames", "preserveconstenums"]; + var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noemitonerror", "noimplicitany", "noresolve", "newline", "newlines", "emitbom", "errortruncation", "usecasesensitivefilenames", "preserveconstenums", "suppress"]; function extractCompilerSettings(content: string): CompilerSetting[] { diff --git a/tests/baselines/reference/noImplicitAnyIndexingSuppressed.js b/tests/baselines/reference/noImplicitAnyIndexingSuppressed.js new file mode 100644 index 0000000000000..5185a9b8db846 --- /dev/null +++ b/tests/baselines/reference/noImplicitAnyIndexingSuppressed.js @@ -0,0 +1,81 @@ +//// [noImplicitAnyIndexingSuppressed.ts] + +enum MyEmusEnum { + emu +} + +// Should be okay; should be a string. +var strRepresentation1 = MyEmusEnum[0] + +// Should be okay; should be a string. +var strRepresentation2 = MyEmusEnum[MyEmusEnum.emu] + +// Should be okay, as we suppress implicit 'any' property access checks +var strRepresentation3 = MyEmusEnum["monehh"]; + +// Should be okay; should be a MyEmusEnum +var strRepresentation4 = MyEmusEnum["emu"]; + + +// Should be okay, as we suppress implicit 'any' property access checks +var x = {}["hi"]; + +// Should be okay, as we suppress implicit 'any' property access checks +var y = {}[10]; + +var hi: any = "hi"; + +var emptyObj = {}; + +// Should be okay, as we suppress implicit 'any' property access checks +var z1 = emptyObj[hi]; +var z2 = (emptyObj)[hi]; + +interface MyMap { + [key: string]: T; +} + +var m: MyMap = { + "0": 0, + "1": 1, + "2": 2, + "Okay that's enough for today.": NaN +}; + +var mResult1 = m[MyEmusEnum.emu]; +var mResult2 = m[MyEmusEnum[MyEmusEnum.emu]]; +var mResult3 = m[hi]; + + + +//// [noImplicitAnyIndexingSuppressed.js] +var MyEmusEnum; +(function (MyEmusEnum) { + MyEmusEnum[MyEmusEnum["emu"] = 0] = "emu"; +})(MyEmusEnum || (MyEmusEnum = {})); +// Should be okay; should be a string. +var strRepresentation1 = MyEmusEnum[0]; +// Should be okay; should be a string. +var strRepresentation2 = MyEmusEnum[0 /* emu */]; +// Should be okay, as we suppress implicit 'any' property access checks +var strRepresentation3 = MyEmusEnum["monehh"]; +// Should be okay; should be a MyEmusEnum +var strRepresentation4 = 0 /* "emu" */; +// Should be okay, as we suppress implicit 'any' property access checks +var x = {}["hi"]; +// Should be okay, as we suppress implicit 'any' property access checks +var y = {}[10]; +var hi = "hi"; +var emptyObj = {}; +// Should be okay, as we suppress implicit 'any' property access checks +var z1 = emptyObj[hi]; +var z2 = emptyObj[hi]; +var m = { + "0": 0, + "1": 1, + "2": 2, + "Okay that's enough for today.": NaN +}; +var mResult1 = m[0 /* emu */]; +var mResult2 = m[MyEmusEnum[0 /* emu */]]; +var mResult3 = m[hi]; diff --git a/tests/baselines/reference/noImplicitAnyIndexingSuppressed.types b/tests/baselines/reference/noImplicitAnyIndexingSuppressed.types new file mode 100644 index 0000000000000..20be75dc29e29 --- /dev/null +++ b/tests/baselines/reference/noImplicitAnyIndexingSuppressed.types @@ -0,0 +1,118 @@ +=== tests/cases/compiler/noImplicitAnyIndexingSuppressed.ts === + +enum MyEmusEnum { +>MyEmusEnum : MyEmusEnum + + emu +>emu : MyEmusEnum +} + +// Should be okay; should be a string. +var strRepresentation1 = MyEmusEnum[0] +>strRepresentation1 : string +>MyEmusEnum[0] : string +>MyEmusEnum : typeof MyEmusEnum + +// Should be okay; should be a string. +var strRepresentation2 = MyEmusEnum[MyEmusEnum.emu] +>strRepresentation2 : string +>MyEmusEnum[MyEmusEnum.emu] : string +>MyEmusEnum : typeof MyEmusEnum +>MyEmusEnum.emu : MyEmusEnum +>MyEmusEnum : typeof MyEmusEnum +>emu : MyEmusEnum + +// Should be okay, as we suppress implicit 'any' property access checks +var strRepresentation3 = MyEmusEnum["monehh"]; +>strRepresentation3 : any +>MyEmusEnum["monehh"] : any +>MyEmusEnum : typeof MyEmusEnum + +// Should be okay; should be a MyEmusEnum +var strRepresentation4 = MyEmusEnum["emu"]; +>strRepresentation4 : MyEmusEnum +>MyEmusEnum["emu"] : MyEmusEnum +>MyEmusEnum : typeof MyEmusEnum + + +// Should be okay, as we suppress implicit 'any' property access checks +var x = {}["hi"]; +>x : any +>{}["hi"] : any +>{} : {} + +// Should be okay, as we suppress implicit 'any' property access checks +var y = {}[10]; +>y : any +>{}[10] : any +>{} : {} + +var hi: any = "hi"; +>hi : any + +var emptyObj = {}; +>emptyObj : {} +>{} : {} + +// Should be okay, as we suppress implicit 'any' property access checks +var z1 = emptyObj[hi]; +>z1 : any +>emptyObj[hi] : any +>emptyObj : {} +>hi : any + +var z2 = (emptyObj)[hi]; +>z2 : any +>(emptyObj)[hi] : any +>(emptyObj) : any +>emptyObj : any +>emptyObj : {} +>hi : any + +interface MyMap { +>MyMap : MyMap +>T : T + + [key: string]: T; +>key : string +>T : T +} + +var m: MyMap = { +>m : MyMap +>MyMap : MyMap +>{ "0": 0, "1": 1, "2": 2, "Okay that's enough for today.": NaN} : { [x: string]: number; "0": number; "1": number; "2": number; "Okay that's enough for today.": number; } + + "0": 0, + "1": 1, + "2": 2, + "Okay that's enough for today.": NaN +>NaN : number + +}; + +var mResult1 = m[MyEmusEnum.emu]; +>mResult1 : number +>m[MyEmusEnum.emu] : number +>m : MyMap +>MyEmusEnum.emu : MyEmusEnum +>MyEmusEnum : typeof MyEmusEnum +>emu : MyEmusEnum + +var mResult2 = m[MyEmusEnum[MyEmusEnum.emu]]; +>mResult2 : number +>m[MyEmusEnum[MyEmusEnum.emu]] : number +>m : MyMap +>MyEmusEnum[MyEmusEnum.emu] : string +>MyEmusEnum : typeof MyEmusEnum +>MyEmusEnum.emu : MyEmusEnum +>MyEmusEnum : typeof MyEmusEnum +>emu : MyEmusEnum + +var mResult3 = m[hi]; +>mResult3 : number +>m[hi] : number +>m : MyMap +>hi : any + + diff --git a/tests/cases/compiler/noImplicitAnyIndexingSuppressed.ts b/tests/cases/compiler/noImplicitAnyIndexingSuppressed.ts new file mode 100644 index 0000000000000..02121d254dd00 --- /dev/null +++ b/tests/cases/compiler/noImplicitAnyIndexingSuppressed.ts @@ -0,0 +1,49 @@ +//@noImplicitAny: true +//@suppress: implicitAnyIndex + +enum MyEmusEnum { + emu +} + +// Should be okay; should be a string. +var strRepresentation1 = MyEmusEnum[0] + +// Should be okay; should be a string. +var strRepresentation2 = MyEmusEnum[MyEmusEnum.emu] + +// Should be okay, as we suppress implicit 'any' property access checks +var strRepresentation3 = MyEmusEnum["monehh"]; + +// Should be okay; should be a MyEmusEnum +var strRepresentation4 = MyEmusEnum["emu"]; + + +// Should be okay, as we suppress implicit 'any' property access checks +var x = {}["hi"]; + +// Should be okay, as we suppress implicit 'any' property access checks +var y = {}[10]; + +var hi: any = "hi"; + +var emptyObj = {}; + +// Should be okay, as we suppress implicit 'any' property access checks +var z1 = emptyObj[hi]; +var z2 = (emptyObj)[hi]; + +interface MyMap { + [key: string]: T; +} + +var m: MyMap = { + "0": 0, + "1": 1, + "2": 2, + "Okay that's enough for today.": NaN +}; + +var mResult1 = m[MyEmusEnum.emu]; +var mResult2 = m[MyEmusEnum[MyEmusEnum.emu]]; +var mResult3 = m[hi]; + From 06e73d33bec6870ce5fa12aeda06c4bff13b825f Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 9 Dec 2014 14:13:44 -0800 Subject: [PATCH 2/4] Commandline definitions use a property "paramType" to specify the name of thier type e.g. File, Version, etc.., that was changed in the defintion to paramName, without changing the use site, changing it back to paramType. --- src/compiler/tsc.ts | 10 +++++----- src/compiler/types.ts | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index fbe596ee0f771..b9e5b5710b431 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -447,12 +447,12 @@ module ts { var usageText = " "; if (option.shortName) { usageText += "-" + option.shortName; - usageText += getParamName(option); + usageText += getParamType(option); usageText += ", "; } usageText += "--" + option.name; - usageText += getParamName(option); + usageText += getParamType(option); usageColumn.push(usageText); descriptionColumn.push(getDiagnosticText(option.description)); @@ -477,9 +477,9 @@ module ts { sys.write(output); return; - function getParamName(option: CommandLineOption) { - if (option.paramName !== undefined) { - return " " + getDiagnosticText(option.paramName); + function getParamType(option: CommandLineOption) { + if (option.paramType !== undefined) { + return " " + getDiagnosticText(option.paramType); } return ""; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index ecfb266f08806..7868c4e970ae0 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1418,7 +1418,7 @@ module ts { type: string | Map; // "string", "number", "boolean", or an object literal mapping named values to actual values shortName?: string; // A short mnemonic for convenience - for instance, 'h' can be used in place of 'help'. description?: DiagnosticMessage; // The message describing what the command line switch does - paramName?: DiagnosticMessage; // The name to be used for a non-boolean option's parameter. + paramType?: DiagnosticMessage; // The name to be used for a non-boolean option's parameter. error?: DiagnosticMessage; // The error given when the argument does not fit a customized 'type'. } From b0574cbdf95e16149422c1d4506404e7a41163d2 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 10 Dec 2014 12:37:09 -0800 Subject: [PATCH 3/4] Respond to code review comments --- src/compiler/checker.ts | 2 +- src/compiler/commandLineParser.ts | 22 +++++++++---------- .../diagnosticInformationMap.generated.ts | 4 +--- src/compiler/diagnosticMessages.json | 11 +--------- src/compiler/types.ts | 10 +++------ src/harness/harness.ts | 11 +++------- .../noImplicitAnyIndexingSuppressed.ts | 2 +- 7 files changed, 20 insertions(+), 42 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 81450948b68a7..62312c115d289 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5385,7 +5385,7 @@ module ts { } // Fall back to any. - if (compilerOptions.noImplicitAny && (compilerOptions.suppress & ErrorGroup.ImplicitAnyIndex) === 0 && objectType !== anyType) { + if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && objectType !== anyType) { error(node, Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type); } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 394a1422543cb..cbe69b37167c7 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -88,6 +88,11 @@ module ts { description: Diagnostics.Redirect_output_structure_to_the_directory, paramType: Diagnostics.DIRECTORY, }, + { + name: "preserveConstEnums", + type: "boolean", + description: Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code + }, { name: "removeComments", type: "boolean", @@ -104,6 +109,11 @@ module ts { description: Diagnostics.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, paramType: Diagnostics.LOCATION, }, + { + name: "suppressImplicitAnyIndexErrors", + type: "boolean", + description: Diagnostics.Suppress_noImplicitAny_errors_for_indexing_into_objects_lacking_index_signatures, + }, { name: "target", shortName: "t", @@ -124,18 +134,6 @@ module ts { type: "boolean", description: Diagnostics.Watch_input_files, }, - { - name: "preserveConstEnums", - type: "boolean", - description: Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code - }, - { - name: "suppress", - type: { "implicitanyindex": ErrorGroup.ImplicitAnyIndex}, - description: Diagnostics.Suppress_a_set_of_compiler_checks, - paramType: Diagnostics.ERRORGROUP, - error: Diagnostics.Argument_for_suppress_option_can_only_be_implicitAnyIndex - }, ]; var shortOptionNames: Map = {}; diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 75c73ccde172f..daacddaeddbbe 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -398,7 +398,6 @@ module ts { VERSION: { code: 6036, category: DiagnosticCategory.Message, key: "VERSION" }, LOCATION: { code: 6037, category: DiagnosticCategory.Message, key: "LOCATION" }, DIRECTORY: { code: 6038, category: DiagnosticCategory.Message, key: "DIRECTORY" }, - ERRORGROUP: { code: 6039, category: DiagnosticCategory.Message, key: "ERRORGROUP" }, Compilation_complete_Watching_for_file_changes: { code: 6042, category: DiagnosticCategory.Message, key: "Compilation complete. Watching for file changes." }, Generates_corresponding_map_file: { code: 6043, category: DiagnosticCategory.Message, key: "Generates corresponding '.map' file." }, Compiler_option_0_expects_an_argument: { code: 6044, category: DiagnosticCategory.Error, key: "Compiler option '{0}' expects an argument." }, @@ -412,8 +411,7 @@ module ts { Warn_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: DiagnosticCategory.Message, key: "Warn on expressions and declarations with an implied 'any' type." }, File_0_not_found: { code: 6053, category: DiagnosticCategory.Error, key: "File '{0}' not found." }, File_0_must_have_extension_ts_or_d_ts: { code: 6054, category: DiagnosticCategory.Error, key: "File '{0}' must have extension '.ts' or '.d.ts'." }, - Suppress_a_set_of_compiler_checks: { code: 6055, category: DiagnosticCategory.Message, key: "Suppress a set of compiler checks." }, - Argument_for_suppress_option_can_only_be_implicitAnyIndex: { code: 6056, category: DiagnosticCategory.Error, key: "Argument for '--suppress' option can only be 'implicitAnyIndex'." }, + Suppress_noImplicitAny_errors_for_indexing_into_objects_lacking_index_signatures: { code: 6055, category: DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing into objects lacking index signatures." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 54ca28e69acd3..da24c88125359 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1591,10 +1591,6 @@ "category": "Message", "code": 6038 }, - "ERRORGROUP": { - "category": "Message", - "code": 6039 - }, "Compilation complete. Watching for file changes.": { "category": "Message", "code": 6042 @@ -1647,15 +1643,10 @@ "category": "Error", "code": 6054 }, - "Suppress a set of compiler checks.": { + "Suppress noImplicitAny errors for indexing into objects lacking index signatures.": { "category": "Message", "code": 6055 }, - "Argument for '--suppress' option can only be 'implicitAnyIndex'.": { - "category": "Error", - "code": 6056 - }, - "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 7868c4e970ae0..7262938d61ef2 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1356,6 +1356,7 @@ module ts { } export interface CompilerOptions { + allowNonTsExtensions?: boolean; charset?: string; codepage?: number; declaration?: boolean; @@ -1373,15 +1374,14 @@ module ts { noResolve?: boolean; out?: string; outDir?: string; + preserveConstEnums?: boolean; removeComments?: boolean; sourceMap?: boolean; sourceRoot?: string; + suppressImplicitAnyIndexErrors?: boolean; target?: ScriptTarget; version?: boolean; watch?: boolean; - preserveConstEnums?: boolean; - allowNonTsExtensions?: boolean; - suppress?: ErrorGroup; [option: string]: string | number | boolean; } @@ -1557,10 +1557,6 @@ module ts { verticalTab = 0x0B, // \v } - export const enum ErrorGroup { - ImplicitAnyIndex = 0x01 - } - export interface CancellationToken { isCancellationRequested(): boolean; } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index d94804375db6c..6404d70befb27 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -778,13 +778,8 @@ module Harness { options.preserveConstEnums = setting.value === 'true'; break; - case 'suppress': - if (typeof setting.value === 'string' && setting.value.toLowerCase() === 'implicitanyindex') { - options.suppress = ts.ErrorGroup.ImplicitAnyIndex; - } - else { - throw new Error('Unkown value for suppress ' + setting.value); - } + case 'suppressimplicitanyindexerrors': + options.suppressImplicitAnyIndexErrors = setting.value === 'true'; break; default: @@ -1172,7 +1167,7 @@ module Harness { var optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines // List of allowed metadata names - var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noemitonerror", "noimplicitany", "noresolve", "newline", "newlines", "emitbom", "errortruncation", "usecasesensitivefilenames", "preserveconstenums", "suppress"]; + var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noemitonerror", "noimplicitany", "noresolve", "newline", "newlines", "emitbom", "errortruncation", "usecasesensitivefilenames", "preserveconstenums", "suppressimplicitanyindexerrors"]; function extractCompilerSettings(content: string): CompilerSetting[] { diff --git a/tests/cases/compiler/noImplicitAnyIndexingSuppressed.ts b/tests/cases/compiler/noImplicitAnyIndexingSuppressed.ts index 02121d254dd00..42ae529fddce5 100644 --- a/tests/cases/compiler/noImplicitAnyIndexingSuppressed.ts +++ b/tests/cases/compiler/noImplicitAnyIndexingSuppressed.ts @@ -1,5 +1,5 @@ //@noImplicitAny: true -//@suppress: implicitAnyIndex +//@suppressImplicitAnyIndexErrors: true enum MyEmusEnum { emu From d2c7c01ff3556a36ad8c0ecb2f4b8b461cffc786 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 10 Dec 2014 17:51:14 -0800 Subject: [PATCH 4/4] Respond to code review commments --- src/compiler/commandLineParser.ts | 2 +- src/compiler/diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index cbe69b37167c7..ae4c751869c5c 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -112,7 +112,7 @@ module ts { { name: "suppressImplicitAnyIndexErrors", type: "boolean", - description: Diagnostics.Suppress_noImplicitAny_errors_for_indexing_into_objects_lacking_index_signatures, + description: Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, }, { name: "target", diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index daacddaeddbbe..6ce7579588ef3 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -411,7 +411,7 @@ module ts { Warn_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: DiagnosticCategory.Message, key: "Warn on expressions and declarations with an implied 'any' type." }, File_0_not_found: { code: 6053, category: DiagnosticCategory.Error, key: "File '{0}' not found." }, File_0_must_have_extension_ts_or_d_ts: { code: 6054, category: DiagnosticCategory.Error, key: "File '{0}' must have extension '.ts' or '.d.ts'." }, - Suppress_noImplicitAny_errors_for_indexing_into_objects_lacking_index_signatures: { code: 6055, category: DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing into objects lacking index signatures." }, + Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index da24c88125359..3e5ac7ae1d653 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1643,7 +1643,7 @@ "category": "Error", "code": 6054 }, - "Suppress noImplicitAny errors for indexing into objects lacking index signatures.": { + "Suppress noImplicitAny errors for indexing objects lacking index signatures.": { "category": "Message", "code": 6055 },