Fix #3912: emit declaration for binding elements correctelly

This commit is contained in:
Mohamed Hegazy 2015-07-28 14:30:27 -07:00
parent fe51b456d8
commit 7f49375f3e
5 changed files with 55 additions and 4 deletions

View file

@ -1501,11 +1501,8 @@ namespace ts {
// emit : declare function foo({y: [a, b, c]}: { y: [any, any, any] }) void;
writeTextOfNode(currentSourceFile, bindingElement.propertyName);
write(": ");
// If bindingElement has propertyName property, then its name must be another bindingPattern of SyntaxKind.ObjectBindingPattern
emitBindingPattern(<BindingPattern>bindingElement.name);
}
else if (bindingElement.name) {
if (bindingElement.name) {
if (isBindingPattern(bindingElement.name)) {
// If it is a nested binding pattern, we will recursively descend into each element and emit each one separately.
// In the case of rest element, we will omit rest element.

View file

@ -0,0 +1,20 @@
//// [paramterDestrcuturingDeclaration.ts]
interface C {
({p: name}): any;
new ({p: boolean}): any;
}
//// [paramterDestrcuturingDeclaration.js]
//// [paramterDestrcuturingDeclaration.d.ts]
interface C {
({p: name}: {
p: any;
}): any;
new ({p: boolean}: {
p: any;
}): any;
}

View file

@ -0,0 +1,14 @@
=== tests/cases/compiler/paramterDestrcuturingDeclaration.ts ===
interface C {
>C : Symbol(C, Decl(paramterDestrcuturingDeclaration.ts, 0, 0))
({p: name}): any;
>p : Symbol(p)
>name : Symbol(name, Decl(paramterDestrcuturingDeclaration.ts, 2, 6))
new ({p: boolean}): any;
>p : Symbol(p)
>boolean : Symbol(boolean, Decl(paramterDestrcuturingDeclaration.ts, 3, 10))
}

View file

@ -0,0 +1,14 @@
=== tests/cases/compiler/paramterDestrcuturingDeclaration.ts ===
interface C {
>C : C
({p: name}): any;
>p : any
>name : any
new ({p: boolean}): any;
>p : any
>boolean : any
}

View file

@ -0,0 +1,6 @@
// @declaration: true
interface C {
({p: name}): any;
new ({p: boolean}): any;
}