diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 32a51de899e3d..a490ba39a46fd 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -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(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. diff --git a/tests/baselines/reference/paramterDestrcuturingDeclaration.js b/tests/baselines/reference/paramterDestrcuturingDeclaration.js new file mode 100644 index 0000000000000..6920f22b0d404 --- /dev/null +++ b/tests/baselines/reference/paramterDestrcuturingDeclaration.js @@ -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; +} diff --git a/tests/baselines/reference/paramterDestrcuturingDeclaration.symbols b/tests/baselines/reference/paramterDestrcuturingDeclaration.symbols new file mode 100644 index 0000000000000..dd11b302eea31 --- /dev/null +++ b/tests/baselines/reference/paramterDestrcuturingDeclaration.symbols @@ -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)) +} + diff --git a/tests/baselines/reference/paramterDestrcuturingDeclaration.types b/tests/baselines/reference/paramterDestrcuturingDeclaration.types new file mode 100644 index 0000000000000..4b49ce22035c7 --- /dev/null +++ b/tests/baselines/reference/paramterDestrcuturingDeclaration.types @@ -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 +} + diff --git a/tests/cases/compiler/paramterDestrcuturingDeclaration.ts b/tests/cases/compiler/paramterDestrcuturingDeclaration.ts new file mode 100644 index 0000000000000..d05d6076bf066 --- /dev/null +++ b/tests/cases/compiler/paramterDestrcuturingDeclaration.ts @@ -0,0 +1,6 @@ +// @declaration: true + +interface C { + ({p: name}): any; + new ({p: boolean}): any; +}