Code Inspections in TypeScript
In TypeScript, ReSharper 2020.2 provides two kinds of code inspections: 141 inspections that detect errors such as broken syntax, unresolved symbols, compiler errors, and so on (you cannot configure or disable any of these inspections), and 51 proprietary code inspections, any of which you can disable or change its severity level.
These code inspections help you detect code issues in design time in all open files, and additionally they allow you to find code issues in specific scope.
Configurable TypeScript inspections are listed below, grouped by their categories.
Common Practices and Code Improvements (4 inspections)
This category groups inspections that hunt for medium severity issues that mainly affect code readability. Inspection ID EditorConfig property | Default severity |
---|---|
Constructor of an abstract class can be made protectedAbstractClassConstructorCanBeMadeProtected resharper_abstract_class_constructor_can_be_made_protected_highlighting | Hint |
Introducing variable will allow to apply type guardIntroduceVariableToApplyGuard resharper_introduce_variable_to_apply_guard_highlighting | Hint |
Private class field can be made readonlyPrivateVariableCanBeMadeReadonly resharper_private_variable_can_be_made_readonly_highlighting | Hint |
String literal usage allows creating specialized overloadCreateSpecializedOverload resharper_create_specialized_overload_highlighting | Hint |
Language Usage Opportunities (9 inspections)
This category includes code inspections, mostly with the suggestion severity level, which notify you when more advanced language constructs can be used. These inspections detect syntax of outdated language versions and suggest using features from more modern language versions. For most of the supported languages, language version can be detected automatically or set manually. Inspection ID EditorConfig property | Default severity |
---|---|
AMD module may be converted to external moduleAmdExternalModule resharper_amd_external_module_highlighting | Suggestion |
Class emulation may be converted to classClass resharper_class_highlighting | Suggestion |
CommonJs module may be converted to external moduleCommonJsExternalModule resharper_common_js_external_module_highlighting | Suggestion |
Function expression may be converted to lambda expressionLambda resharper_lambda_highlighting | Suggestion |
Immediately-invoked function expression may be converted to internal moduleInternalModule resharper_internal_module_highlighting | Suggestion |
Invocation of parent class may be converted to super callSuperCall resharper_super_call_highlighting | Suggestion |
Member assigned by a function may be converted to function memberMethodSafeThis resharper_method_safe_this_highlighting | Suggestion |
Possible overloads may be inferred by function bodyOverloadSignatureInferring resharper_overload_signature_inferring_highlighting | Hint |
Use 'as' operator instead of type assertionUseAsInsteadOfTypeCast resharper_use_as_instead_of_type_cast_highlighting | Hint |
Potential Code Quality Issues (15 inspections)
This category includes inspections that detect critical issues (code smells), mostly with Error or Warning level. This category also includes inspections that ensure localization assistance. Inspection ID EditorConfig property | Default severity |
---|---|
Cannot resolve, probably symbol is located in inaccessible moduleTsResolvedFromInaccessibleModule resharper_ts_resolved_from_inaccessible_module_highlighting | Error |
Check 'amd-dependency' the same way as require() argumentAmdDependencyPathProblem resharper_amd_dependency_path_problem_highlighting | Disabled |
Duplicate identifierDuplicateIdentifierError resharper_duplicate_identifier_error_highlighting | Error |
Empty return value for type-annotated functionEmptyReturnValueForTypeAnnotatedFunction resharper_empty_return_value_for_type_annotated_function_highlighting | Warning |
Exported entity uses a private entityDeclarationVisibilityError resharper_declaration_visibility_error_highlighting | Error |
'Implicit any' inspection when NoImplicitAny is setImplicitAnyError resharper_implicit_any_error_highlighting | Error |
More specific signature follows less specificMoreSpecificSignatureAfterLessSpecific resharper_more_specific_signature_after_less_specific_highlighting | Warning |
Overload is less specific than the main signatureLessSpecificOverloadThanMainSignature resharper_less_specific_overload_than_main_signature_highlighting | Warning |
Parameter-property value assigned inside constructor won't be assigned to class propertyAssignedValueWontBeAssignedToCorrespondingField resharper_assigned_value_wont_be_assigned_to_corresponding_field_highlighting | Warning |
Suspicious 'instanceof' checkSuspiciousInstanceofCheck resharper_suspicious_instanceof_check_highlighting | Warning |
Suspicious 'this' usage in context of local function inside class memberSuspiciousThisUsage resharper_suspicious_this_usage_highlighting | Warning |
Suspicious 'typeof' checkSuspiciousTypeofCheck resharper_suspicious_typeof_check_highlighting | Warning |
Type parameter hides type parameter declared in outer scopeTypeParameterHidesTypeParamFromOuterScope resharper_type_parameter_hides_type_param_from_outer_scope_highlighting | Warning |
Use of possibly unassigned property in a static initializerUseOfPossiblyUnassignedProperty resharper_use_of_possibly_unassigned_property_highlighting | Warning |
Use of undeclared variableTsNotResolved resharper_ts_not_resolved_highlighting | Error |
Redundancies in Code (9 inspections)
Code inspections in this category look for redundancies and dead code, which affect code readability and style, and could be safely removed. Some code redundancies cannot be fixed automatically, and quick-fixes for them are performed in the interactive mode, requiring the user input. But the majority of the redundancies can be fixed without user interaction, using either fix in scope or code cleanup. Inspection ID EditorConfig property | Default severity |
---|---|
Comparison of boolean with boolean value is equivalent to value or negated valueRedundantComparisonWithBoolean resharper_redundant_comparison_with_boolean_highlighting | Warning |
Double negation of boolean is redundantDoubleNegationOfBoolean resharper_double_negation_of_boolean_highlighting | Warning |
Duplicate reference comment is redundantDuplicateReferenceComment resharper_duplicate_reference_comment_highlighting | Warning |
Redundant parent type specification in extends/implementsRedundantParentTypeDeclaration resharper_redundant_parent_type_declaration_highlighting | Warning |
Redundant qualifierRedundantQualifier resharper_redundant_qualifier_highlighting | Warning |
Reference comment creates cyclic dependencyCyclicReferenceComment resharper_cyclic_reference_comment_highlighting | Disabled |
Ternary operator may be replaced by it's conditionTernaryCanBeReplacedByItsCondition resharper_ternary_can_be_replaced_by_its_condition_highlighting | Warning |
Type cast is redundant: expression is always of provided typeRedundantTypeCast resharper_redundant_type_cast_highlighting | Warning |
Type cast is redundant: expression is of a structurally compatible typeRedundantTypeCastStructural resharper_redundant_type_cast_structural_highlighting | Warning |
Redundancies in Symbol Declarations (6 inspections)
This category includes code inspections, mostly with the warning severity level, which detect empty and unused symbol declarations. Inspection ID EditorConfig property | Default severity |
---|---|
Parameter doesn't participate in the main signatureParameterDoesntMakeAnySense resharper_parameter_doesnt_make_any_sense_highlighting | Warning |
Redundant empty constructor without parametersRedundantEmptyConstructor resharper_redundant_empty_constructor_highlighting | Warning |
Same item is imported twice with different namesSameImportsWithDifferentName resharper_same_imports_with_different_name_highlighting | Warning |
Type guard definitely produces 'never' type for the variableTypeGuardProducesNeverType resharper_type_guard_produces_never_type_highlighting | Warning |
Type guard doesn't affect variable's type in any wayTypeGuardDoesntAffectAnything resharper_type_guard_doesnt_affect_anything_highlighting | Warning |
Unused local importUnusedLocalImport resharper_unused_local_import_highlighting | Warning |
Spelling issues (3 inspections)
These inspections detect typos in various contexts. Inspection ID EditorConfig property | Default severity |
---|---|
Typo in commentCommentTypo resharper_comment_typo_highlighting | Suggestion |
Typo in identifierIdentifierTypo resharper_identifier_typo_highlighting | Suggestion |
Typo in string literalStringLiteralTypo resharper_string_literal_typo_highlighting | Suggestion |
Syntax Style (5 inspections)
Inspections in this category detect violations of code syntax styles. In contrast to most of other code inspections, these inspections can either detect the same code construct as a code issue or not depending on the corresponding code style rule configured on the page of ReSharper options (Alt+R O). You can also fix issues that these inspection detect using code cleanup. Inspection ID EditorConfig property | Default severity |
---|---|
Element has implicit 'any' typeImplicitAnyTypeWarning resharper_implicit_any_type_warning_highlighting | Warning |
Non-compliant path style inside 'require'WrongRequireRelativePath resharper_wrong_require_relative_path_highlighting | Hint |
Non-compliant 'public' modifier or its absenceWrongPublicModifierSpecification resharper_wrong_public_modifier_specification_highlighting | Hint |
Type of variable may be specified explicitlySpecifyVariableTypeExplicitly resharper_specify_variable_type_explicitly_highlighting | Hint |
Type specification is redundant, because variable type is contextually determined from the type of assigned valueRedundantVariableTypeSpecification resharper_redundant_variable_type_specification_highlighting | Hint |