Forbid renaming a propertyin function type parameters

This commit is contained in:
uhyo committed 2022-06-08 21:09:00 +09:00
1 parent 7bff2dd28b
commit 4aec8efd18
2 files changed
+12

No files matched your search

+8
View File
@@ -37905,6 +37905,14 @@ namespace ts {
}
if (isBindingElement(node)) {
if (node.propertyName && isIdentifier(node.name) && isParameterDeclaration(node) && nodeIsMissing((getContainingFunction(node) as FunctionLikeDeclaration).body)) {
// type F = ({a: string}) => void;
// ^^^^^^
// variable renaming in function type notation is confusing, so forbid it
error(node.name, Diagnostics.Renaming_a_property_in_destructuring_assignment_is_only_allowed_in_a_function_or_constructor_implementation);
return;
}
if (isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < ScriptTarget.ES2018) {
checkExternalEmitHelpers(node, ExternalEmitHelpers.Rest);
}
+4
View File
@@ -3487,6 +3487,10 @@
"category": "Error",
"code": 2841
},
"Renaming a property in destructuring assignment is only allowed in a function or constructor implementation.": {
"category": "Error",
"code": 2842
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",