Skip to content

Commit e21f7cf

Browse files
Support reporting via a flag, though temporarily ignore it.
1 parent abd44b1 commit e21f7cf

5 files changed

+15
-4
lines changed

src/compiler/checker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6558,7 +6558,7 @@ module ts {
65586558
if (index < 0) {
65596559

65606560
// Check for type arguments inferred as '{}'.
6561-
if (originalCandidate.typeParameters && inferenceResult) {
6561+
if (/*compilerOptions.noInferredEmptyObject &&*/ originalCandidate.typeParameters && inferenceResult) {
65626562
for (var i = 0, len = typeArgumentTypes.length; i < len; i++) {
65636563

65646564
if (typeArgumentTypes[i] === emptyObjectType && getInferenceCandidates(inferenceResult, i).length === 0) {

src/compiler/commandLineParser.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,12 @@ module ts {
7272
{
7373
name: "noImplicitAny",
7474
type: "boolean",
75-
description: Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type,
75+
description: Diagnostics.Raise_an_error_when_the_any_type_is_inferred_for_a_declaration
76+
},
77+
{
78+
name: "noInferredEmptyObject",
79+
type: "boolean",
80+
description: Diagnostics.Raise_an_error_when_inferring_for_type_arguments
7681
},
7782
{
7883
name: "noLib",

src/compiler/diagnosticInformationMap.generated.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -458,12 +458,13 @@ module ts {
458458
Unsupported_locale_0: { code: 6049, category: DiagnosticCategory.Error, key: "Unsupported locale '{0}'." },
459459
Unable_to_open_file_0: { code: 6050, category: DiagnosticCategory.Error, key: "Unable to open file '{0}'." },
460460
Corrupted_locale_file_0: { code: 6051, category: DiagnosticCategory.Error, key: "Corrupted locale file {0}." },
461-
Raise_error_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: DiagnosticCategory.Message, key: "Raise error on expressions and declarations with an implied 'any' type." },
461+
Raise_an_error_when_the_any_type_is_inferred_for_a_declaration: { code: 6052, category: DiagnosticCategory.Message, key: "Raise an error when the 'any' type is inferred for a declaration." },
462462
File_0_not_found: { code: 6053, category: DiagnosticCategory.Error, key: "File '{0}' not found." },
463463
File_0_must_have_extension_ts_or_d_ts: { code: 6054, category: DiagnosticCategory.Error, key: "File '{0}' must have extension '.ts' or '.d.ts'." },
464464
Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." },
465465
Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: DiagnosticCategory.Message, key: "Do not emit declarations for code that has an '@internal' annotation." },
466466
Preserve_new_lines_when_emitting_code: { code: 6057, category: DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." },
467+
Raise_an_error_when_inferring_for_type_arguments: { code: 6058, category: DiagnosticCategory.Message, key: "Raise an error when inferring '{}' for type arguments." },
467468
Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
468469
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
469470
Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },

src/compiler/diagnosticMessages.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -1824,7 +1824,7 @@
18241824
"category": "Error",
18251825
"code": 6051
18261826
},
1827-
"Raise error on expressions and declarations with an implied 'any' type.": {
1827+
"Raise an error when the 'any' type is inferred for a declaration.": {
18281828
"category": "Message",
18291829
"code": 6052
18301830
},
@@ -1848,6 +1848,10 @@
18481848
"category": "Message",
18491849
"code": 6057
18501850
},
1851+
"Raise an error when inferring '{}' for type arguments.": {
1852+
"category": "Message",
1853+
"code": 6058
1854+
},
18511855

18521856
"Variable '{0}' implicitly has an '{1}' type.": {
18531857
"category": "Error",

src/compiler/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1539,6 +1539,7 @@ module ts {
15391539
noEmitOnError?: boolean;
15401540
noErrorTruncation?: boolean;
15411541
noImplicitAny?: boolean;
1542+
noInferredEmptyObject?: boolean;
15421543
noLib?: boolean;
15431544
noLibCheck?: boolean;
15441545
noResolve?: boolean;

0 commit comments

Comments
 (0)