mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-10 18:04:18 -05:00
Issue implicit any errors for mapped types without annotations (#21104)
* Fixed #21011 * Updated code of merged message * Reversed message code change and moved error to it's appropriate position * Applied suggested improvements * Fixed wrong diagnostics message in checker * Reverted diagnostic message change
This commit is contained in:
committed by
Mohamed Hegazy
parent
8bce69e6bd
commit
03fd77657d
@@ -11281,6 +11281,9 @@ namespace ts {
|
||||
}
|
||||
diagnostic = Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type;
|
||||
break;
|
||||
case SyntaxKind.MappedType:
|
||||
error(declaration, Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type);
|
||||
return;
|
||||
default:
|
||||
diagnostic = Diagnostics.Variable_0_implicitly_has_an_1_type;
|
||||
}
|
||||
@@ -20312,6 +20315,11 @@ namespace ts {
|
||||
function checkMappedType(node: MappedTypeNode) {
|
||||
checkSourceElement(node.typeParameter);
|
||||
checkSourceElement(node.type);
|
||||
|
||||
if (noImplicitAny && !node.type) {
|
||||
reportImplicitAnyError(node, anyType);
|
||||
}
|
||||
|
||||
const type = <MappedType>getTypeFromMappedTypeNode(node);
|
||||
const constraintType = getConstraintTypeFromMappedType(type);
|
||||
checkTypeAssignableTo(constraintType, stringType, node.typeParameter.constraint);
|
||||
|
||||
@@ -3571,7 +3571,10 @@
|
||||
"category": "Error",
|
||||
"code": 7038
|
||||
},
|
||||
|
||||
"Mapped object type implicitly has an 'any' template type.": {
|
||||
"category": "Error",
|
||||
"code": 7039
|
||||
},
|
||||
"You cannot rename this element.": {
|
||||
"category": "Error",
|
||||
"code": 8000
|
||||
|
||||
Reference in New Issue
Block a user