@@ -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
@@ -1564,7 +1566,7 @@ namespace ts {
1564
1566
error(errorNode, diag, moduleReference, resolvedModule.resolvedFileName);
1565
1567
return undefined;
1566
1568
}
1567
- else if (compilerOptions. noImplicitAny && moduleNotFoundError) {
1569
+ else if (noImplicitAny && moduleNotFoundError) {
1568
1570
error(errorNode,
1569
1571
Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type,
1570
1572
moduleReference,
@@ -3407,7 +3409,7 @@ namespace ts {
3407
3409
return addOptionality(declaredType, /*optional*/ declaration.questionToken && includeOptionality);
3408
3410
}
3409
3411
3410
- if ((compilerOptions. noImplicitAny || declaration.flags & NodeFlags.JavaScriptFile) &&
3412
+ if ((noImplicitAny || declaration.flags & NodeFlags.JavaScriptFile) &&
3411
3413
declaration.kind === SyntaxKind.VariableDeclaration && !isBindingPattern(declaration.name) &&
3412
3414
!(getCombinedModifierFlags(declaration) & ModifierFlags.Export) && !isInAmbientContext(declaration)) {
3413
3415
// If --noImplicitAny is on or the declaration is in a Javascript file,
@@ -3509,7 +3511,7 @@ namespace ts {
3509
3511
if (isBindingPattern(element.name)) {
3510
3512
return getTypeFromBindingPattern(<BindingPattern>element.name, includePatternInType, reportErrors);
3511
3513
}
3512
- if (reportErrors && compilerOptions. noImplicitAny && !declarationBelongsToPrivateAmbientMember(element)) {
3514
+ if (reportErrors && noImplicitAny && !declarationBelongsToPrivateAmbientMember(element)) {
3513
3515
reportImplicitAnyError(element, anyType);
3514
3516
}
3515
3517
return anyType;
@@ -3607,7 +3609,7 @@ namespace ts {
3607
3609
type = declaration.dotDotDotToken ? anyArrayType : anyType;
3608
3610
3609
3611
// Report implicit any errors unless this is a private property within an ambient declaration
3610
- if (reportErrors && compilerOptions. noImplicitAny) {
3612
+ if (reportErrors && noImplicitAny) {
3611
3613
if (!declarationBelongsToPrivateAmbientMember(declaration)) {
3612
3614
reportImplicitAnyError(declaration, type);
3613
3615
}
@@ -3726,7 +3728,7 @@ namespace ts {
3726
3728
}
3727
3729
// Otherwise, fall back to 'any'.
3728
3730
else {
3729
- if (compilerOptions. noImplicitAny) {
3731
+ if (noImplicitAny) {
3730
3732
if (setter) {
3731
3733
error(setter, Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol));
3732
3734
}
@@ -3741,7 +3743,7 @@ namespace ts {
3741
3743
}
3742
3744
if (!popTypeResolution()) {
3743
3745
type = anyType;
3744
- if (compilerOptions. noImplicitAny) {
3746
+ if (noImplicitAny) {
3745
3747
const getter = <AccessorDeclaration>getDeclarationOfKind(symbol, SyntaxKind.GetAccessor);
3746
3748
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));
3747
3749
}
@@ -3824,7 +3826,7 @@ namespace ts {
3824
3826
return unknownType;
3825
3827
}
3826
3828
// Otherwise variable has initializer that circularly references the variable itself
3827
- if (compilerOptions. noImplicitAny) {
3829
+ if (noImplicitAny) {
3828
3830
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,
3829
3831
symbolToString(symbol));
3830
3832
}
@@ -5585,7 +5587,7 @@ namespace ts {
5585
5587
}
5586
5588
if (!popTypeResolution()) {
5587
5589
type = anyType;
5588
- if (compilerOptions. noImplicitAny) {
5590
+ if (noImplicitAny) {
5589
5591
const declaration = <Declaration>signature.declaration;
5590
5592
if (declaration.name) {
5591
5593
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));
@@ -6540,7 +6542,7 @@ namespace ts {
6540
6542
return indexInfo.type;
6541
6543
}
6542
6544
if (accessExpression && !isConstEnumObjectType(objectType)) {
6543
- if (compilerOptions. noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) {
6545
+ if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) {
6544
6546
if (getIndexTypeOfType(objectType, IndexKind.Number)) {
6545
6547
error(accessExpression.argumentExpression, Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number);
6546
6548
}
@@ -9126,7 +9128,7 @@ namespace ts {
9126
9128
}
9127
9129
9128
9130
function reportErrorsFromWidening(declaration: Declaration, type: Type) {
9129
- if (produceDiagnostics && compilerOptions. noImplicitAny && type.flags & TypeFlags.ContainsWideningType) {
9131
+ if (produceDiagnostics && noImplicitAny && type.flags & TypeFlags.ContainsWideningType) {
9130
9132
// Report implicit any error within type if possible, otherwise report error on declaration
9131
9133
if (!reportWideningErrorsInType(type)) {
9132
9134
reportImplicitAnyError(declaration, type);
@@ -11007,7 +11009,7 @@ namespace ts {
11007
11009
// control flow based type does include undefined.
11008
11010
if (type === autoType || type === autoArrayType) {
11009
11011
if (flowType === autoType || flowType === autoArrayType) {
11010
- if (compilerOptions. noImplicitAny) {
11012
+ if (noImplicitAny) {
11011
11013
error(declaration.name, Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol), typeToString(flowType));
11012
11014
error(node, Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType));
11013
11015
}
@@ -11277,7 +11279,7 @@ namespace ts {
11277
11279
}
11278
11280
}
11279
11281
11280
- if (compilerOptions. noImplicitThis) {
11282
+ if (noImplicitThis) {
11281
11283
// With noImplicitThis, functions may not reference 'this' if it has type 'any'
11282
11284
error(node, Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation);
11283
11285
}
@@ -12531,7 +12533,7 @@ namespace ts {
12531
12533
return links.resolvedSymbol = unknownSymbol;
12532
12534
}
12533
12535
else {
12534
- if (compilerOptions. noImplicitAny) {
12536
+ if (noImplicitAny) {
12535
12537
error(node, Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, JsxNames.IntrinsicElements);
12536
12538
}
12537
12539
return links.resolvedSymbol = unknownSymbol;
@@ -12919,7 +12921,7 @@ namespace ts {
12919
12921
}
12920
12922
12921
12923
if (jsxElementType === undefined) {
12922
- if (compilerOptions. noImplicitAny) {
12924
+ if (noImplicitAny) {
12923
12925
error(errorNode, Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist);
12924
12926
}
12925
12927
}
@@ -14742,7 +14744,7 @@ namespace ts {
14742
14744
if (funcSymbol && funcSymbol.members && funcSymbol.flags & SymbolFlags.Function) {
14743
14745
return getInferredClassType(funcSymbol);
14744
14746
}
14745
- else if (compilerOptions. noImplicitAny) {
14747
+ else if (noImplicitAny) {
14746
14748
error(node, Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type);
14747
14749
}
14748
14750
return anyType;
@@ -15002,7 +15004,7 @@ namespace ts {
15002
15004
const iterableIteratorAny = functionFlags & FunctionFlags.Async
15003
15005
? createAsyncIterableIteratorType(anyType) // AsyncGenerator function
15004
15006
: createIterableIteratorType(anyType); // Generator function
15005
- if (compilerOptions. noImplicitAny) {
15007
+ if (noImplicitAny) {
15006
15008
error(func.asteriskToken,
15007
15009
Diagnostics.Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type, typeToString(iterableIteratorAny));
15008
15010
}
@@ -16544,7 +16546,7 @@ namespace ts {
16544
16546
16545
16547
if (produceDiagnostics) {
16546
16548
checkCollisionWithArgumentsInGeneratedCode(node);
16547
- if (compilerOptions. noImplicitAny && !node.type) {
16549
+ if (noImplicitAny && !node.type) {
16548
16550
switch (node.kind) {
16549
16551
case SyntaxKind.ConstructSignature:
16550
16552
error(node, Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
@@ -17856,7 +17858,7 @@ namespace ts {
17856
17858
if (produceDiagnostics && !node.type) {
17857
17859
// Report an implicit any error if there is no body, no explicit return type, and node is not a private method
17858
17860
// in an ambient context
17859
- if (compilerOptions. noImplicitAny && nodeIsMissing(node.body) && !isPrivateWithinAmbient(node)) {
17861
+ if (noImplicitAny && nodeIsMissing(node.body) && !isPrivateWithinAmbient(node)) {
17860
17862
reportImplicitAnyError(node, anyType);
17861
17863
}
17862
17864
0 commit comments