mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-16 06:35:35 -05:00
Check for number of binding elements in parameter patterns.
This commit is contained in:
@@ -3142,12 +3142,17 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isBindingPattern(parameter.name)) {
|
||||
writeLine();
|
||||
write("var ");
|
||||
emitDestructuring(parameter, /*isAssignmentExpressionStatement*/ false, tempParameters[tempIndex]);
|
||||
write(";");
|
||||
tempIndex++;
|
||||
let paramName = parameter.name;
|
||||
if (isBindingPattern(paramName)) {
|
||||
// In cases where a binding patternm is simply '[]' or '{}',
|
||||
// we don't want to emit anything.
|
||||
if (paramName.elements.length > 0) {
|
||||
writeLine();
|
||||
write("var ");
|
||||
emitDestructuring(parameter, /*isAssignmentExpressionStatement*/ false, tempParameters[tempIndex]);
|
||||
write(";");
|
||||
tempIndex++;
|
||||
}
|
||||
}
|
||||
else if (parameter.initializer) {
|
||||
writeLine();
|
||||
|
||||
@@ -1067,7 +1067,7 @@ namespace ts {
|
||||
return SyntaxKind.FirstTemplateToken <= kind && kind <= SyntaxKind.LastTemplateToken;
|
||||
}
|
||||
|
||||
export function isBindingPattern(node: Node) {
|
||||
export function isBindingPattern(node: Node): node is BindingPattern {
|
||||
return !!node && (node.kind === SyntaxKind.ArrayBindingPattern || node.kind === SyntaxKind.ObjectBindingPattern);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user