mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-11-18 20:11:14 +00:00
Forbid renaming a propertyin function type parameters
This commit is contained in:
1 parent
7bff2dd28b
commit
4aec8efd18
2 files changed
+12
No files matched your search
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in new issue
Block a user