@@ -56,7 +56,9 @@ namespace ts {
56
56
const modulekind = getEmitModuleKind(compilerOptions);
57
57
const noUnusedIdentifiers = !!compilerOptions.noUnusedLocals || !!compilerOptions.noUnusedParameters;
58
58
const allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === ModuleKind.System;
59
- const strictNullChecks = compilerOptions.strictNullChecks;
59
+ const strictNullChecks = compilerOptions.strictNullChecks === undefined ? compilerOptions.strict : compilerOptions.strictNullChecks;
60
+ const noImplicitAny = compilerOptions.noImplicitAny === undefined ? compilerOptions.strict : compilerOptions.noImplicitAny;
61
+ const noImplicitThis = compilerOptions.noImplicitThis === undefined ? compilerOptions.strict : compilerOptions.noImplicitThis;
60
62
61
63
const emitResolver = createResolver();
62
64
@@ -1571,7 +1573,7 @@ namespace ts {
1571
1573
error(errorNode, diag, moduleReference, resolvedModule.resolvedFileName);
1572
1574
return undefined;
1573
1575
}
1574
- else if (compilerOptions. noImplicitAny && moduleNotFoundError) {
1576
+ else if (noImplicitAny && moduleNotFoundError) {
1575
1577
error(errorNode,
1576
1578
Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type,
1577
1579
moduleReference,
@@ -3414,7 +3416,7 @@ namespace ts {
3414
3416
return addOptionality(declaredType, /*optional*/ declaration.questionToken && includeOptionality);
3415
3417
}
3416
3418
3417
- if ((compilerOptions. noImplicitAny || declaration.flags & NodeFlags.JavaScriptFile) &&
3419
+ if ((noImplicitAny || declaration.flags & NodeFlags.JavaScriptFile) &&
3418
3420
declaration.kind === SyntaxKind.VariableDeclaration && !isBindingPattern(declaration.name) &&
3419
3421
!(getCombinedModifierFlags(declaration) & ModifierFlags.Export) && !isInAmbientContext(declaration)) {
3420
3422
// If --noImplicitAny is on or the declaration is in a Javascript file,
@@ -3516,7 +3518,7 @@ namespace ts {
3516
3518
if (isBindingPattern(element.name)) {
3517
3519
return getTypeFromBindingPattern(<BindingPattern>element.name, includePatternInType, reportErrors);
3518
3520
}
3519
- if (reportErrors && compilerOptions. noImplicitAny && !declarationBelongsToPrivateAmbientMember(element)) {
3521
+ if (reportErrors && noImplicitAny && !declarationBelongsToPrivateAmbientMember(element)) {
3520
3522
reportImplicitAnyError(element, anyType);
3521
3523
}
3522
3524
return anyType;
@@ -3614,7 +3616,7 @@ namespace ts {
3614
3616
type = declaration.dotDotDotToken ? anyArrayType : anyType;
3615
3617
3616
3618
// Report implicit any errors unless this is a private property within an ambient declaration
3617
- if (reportErrors && compilerOptions. noImplicitAny) {
3619
+ if (reportErrors && noImplicitAny) {
3618
3620
if (!declarationBelongsToPrivateAmbientMember(declaration)) {
3619
3621
reportImplicitAnyError(declaration, type);
3620
3622
}
@@ -3733,7 +3735,7 @@ namespace ts {
3733
3735
}
3734
3736
// Otherwise, fall back to 'any'.
3735
3737
else {
3736
- if (compilerOptions. noImplicitAny) {
3738
+ if (noImplicitAny) {
3737
3739
if (setter) {
3738
3740
error(setter, Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol));
3739
3741
}
@@ -3748,7 +3750,7 @@ namespace ts {
3748
3750
}
3749
3751
if (!popTypeResolution()) {
3750
3752
type = anyType;
3751
- if (compilerOptions. noImplicitAny) {
3753
+ if (noImplicitAny) {
3752
3754
const getter = <AccessorDeclaration>getDeclarationOfKind(symbol, SyntaxKind.GetAccessor);
3753
3755
error(getter, Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol));
3754
3756
}
@@ -3831,7 +3833,7 @@ namespace ts {
3831
3833
return unknownType;
3832
3834
}
3833
3835
// Otherwise variable has initializer that circularly references the variable itself
3834
- if (compilerOptions. noImplicitAny) {
3836
+ if (noImplicitAny) {
3835
3837
error(symbol.valueDeclaration, Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer,
3836
3838
symbolToString(symbol));
3837
3839
}
@@ -5592,7 +5594,7 @@ namespace ts {
5592
5594
}
5593
5595
if (!popTypeResolution()) {
5594
5596
type = anyType;
5595
- if (compilerOptions. noImplicitAny) {
5597
+ if (noImplicitAny) {
5596
5598
const declaration = <Declaration>signature.declaration;
5597
5599
if (declaration.name) {
5598
5600
error(declaration.name, Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, declarationNameToString(declaration.name));
@@ -6552,7 +6554,7 @@ namespace ts {
6552
6554
return indexInfo.type;
6553
6555
}
6554
6556
if (accessExpression && !isConstEnumObjectType(objectType)) {
6555
- if (compilerOptions. noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) {
6557
+ if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) {
6556
6558
if (getIndexTypeOfType(objectType, IndexKind.Number)) {
6557
6559
error(accessExpression.argumentExpression, Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number);
6558
6560
}
@@ -9146,7 +9148,7 @@ namespace ts {
9146
9148
}
9147
9149
9148
9150
function reportErrorsFromWidening(declaration: Declaration, type: Type) {
9149
- if (produceDiagnostics && compilerOptions. noImplicitAny && type.flags & TypeFlags.ContainsWideningType) {
9151
+ if (produceDiagnostics && noImplicitAny && type.flags & TypeFlags.ContainsWideningType) {
9150
9152
// Report implicit any error within type if possible, otherwise report error on declaration
9151
9153
if (!reportWideningErrorsInType(type)) {
9152
9154
reportImplicitAnyError(declaration, type);
@@ -11056,7 +11058,7 @@ namespace ts {
11056
11058
// control flow based type does include undefined.
11057
11059
if (type === autoType || type === autoArrayType) {
11058
11060
if (flowType === autoType || flowType === autoArrayType) {
11059
- if (compilerOptions. noImplicitAny) {
11061
+ if (noImplicitAny) {
11060
11062
error(declaration.name, Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol), typeToString(flowType));
11061
11063
error(node, Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType));
11062
11064
}
@@ -11326,7 +11328,7 @@ namespace ts {
11326
11328
}
11327
11329
}
11328
11330
11329
- if (compilerOptions. noImplicitThis) {
11331
+ if (noImplicitThis) {
11330
11332
// With noImplicitThis, functions may not reference 'this' if it has type 'any'
11331
11333
error(node, Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation);
11332
11334
}
@@ -12599,7 +12601,7 @@ namespace ts {
12599
12601
return links.resolvedSymbol = unknownSymbol;
12600
12602
}
12601
12603
else {
12602
- if (compilerOptions. noImplicitAny) {
12604
+ if (noImplicitAny) {
12603
12605
error(node, Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, JsxNames.IntrinsicElements);
12604
12606
}
12605
12607
return links.resolvedSymbol = unknownSymbol;
@@ -12987,7 +12989,7 @@ namespace ts {
12987
12989
}
12988
12990
12989
12991
if (jsxElementType === undefined) {
12990
- if (compilerOptions. noImplicitAny) {
12992
+ if (noImplicitAny) {
12991
12993
error(errorNode, Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist);
12992
12994
}
12993
12995
}
@@ -14810,7 +14812,7 @@ namespace ts {
14810
14812
if (funcSymbol && funcSymbol.members && funcSymbol.flags & SymbolFlags.Function) {
14811
14813
return getInferredClassType(funcSymbol);
14812
14814
}
14813
- else if (compilerOptions. noImplicitAny) {
14815
+ else if (noImplicitAny) {
14814
14816
error(node, Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type);
14815
14817
}
14816
14818
return anyType;
@@ -15070,7 +15072,7 @@ namespace ts {
15070
15072
const iterableIteratorAny = functionFlags & FunctionFlags.Async
15071
15073
? createAsyncIterableIteratorType(anyType) // AsyncGenerator function
15072
15074
: createIterableIteratorType(anyType); // Generator function
15073
- if (compilerOptions. noImplicitAny) {
15075
+ if (noImplicitAny) {
15074
15076
error(func.asteriskToken,
15075
15077
Diagnostics.Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type, typeToString(iterableIteratorAny));
15076
15078
}
@@ -16619,7 +16621,7 @@ namespace ts {
16619
16621
16620
16622
if (produceDiagnostics) {
16621
16623
checkCollisionWithArgumentsInGeneratedCode(node);
16622
- if (compilerOptions. noImplicitAny && !node.type) {
16624
+ if (noImplicitAny && !node.type) {
16623
16625
switch (node.kind) {
16624
16626
case SyntaxKind.ConstructSignature:
16625
16627
error(node, Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
@@ -17921,7 +17923,7 @@ namespace ts {
17921
17923
if (produceDiagnostics && !node.type) {
17922
17924
// Report an implicit any error if there is no body, no explicit return type, and node is not a private method
17923
17925
// in an ambient context
17924
- if (compilerOptions. noImplicitAny && nodeIsMissing(node.body) && !isPrivateWithinAmbient(node)) {
17926
+ if (noImplicitAny && nodeIsMissing(node.body) && !isPrivateWithinAmbient(node)) {
17925
17927
reportImplicitAnyError(node, anyType);
17926
17928
}
17927
17929
0 commit comments