Fix #3912: emit declaration for binding elements correctelly
This commit is contained in:
parent
fe51b456d8
commit
7f49375f3e
5 changed files with 55 additions and 4 deletions
|
@ -1501,11 +1501,8 @@ namespace ts {
|
||||||
// emit : declare function foo({y: [a, b, c]}: { y: [any, any, any] }) void;
|
// emit : declare function foo({y: [a, b, c]}: { y: [any, any, any] }) void;
|
||||||
writeTextOfNode(currentSourceFile, bindingElement.propertyName);
|
writeTextOfNode(currentSourceFile, bindingElement.propertyName);
|
||||||
write(": ");
|
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 (isBindingPattern(bindingElement.name)) {
|
||||||
// If it is a nested binding pattern, we will recursively descend into each element and emit each one separately.
|
// 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.
|
// In the case of rest element, we will omit rest element.
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
|
@ -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))
|
||||||
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
||||||
|
|
6
tests/cases/compiler/paramterDestrcuturingDeclaration.ts
Normal file
6
tests/cases/compiler/paramterDestrcuturingDeclaration.ts
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
// @declaration: true
|
||||||
|
|
||||||
|
interface C {
|
||||||
|
({p: name}): any;
|
||||||
|
new ({p: boolean}): any;
|
||||||
|
}
|
Loading…
Reference in a new issue