From 217f5583c63b1d047ea96d4edc665e2bddb63ee6 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 24 Feb 2016 12:54:20 -0800 Subject: [PATCH 1/6] Correctelly serialize types with signatures containing binding patterns --- src/compiler/checker.ts | 66 +++++++++++++++-- ...rrayBindingPatternOmittedExpressions.types | 2 +- .../reference/arrowFunctionExpressions.types | 32 ++++---- .../declarationEmitDestructuring1.types | 2 +- .../declarationEmitDestructuring5.types | 10 +-- ...OptionalBindingParametersInOverloads.types | 4 +- .../destructuringInFunctionType.types | 8 +- ...destructuringWithLiteralInitializers.types | 74 +++++++++---------- .../reference/emitArrowFunctionES6.types | 32 ++++---- ...ableDeclarationBindingPatterns01_ES5.types | 4 +- ...ableDeclarationBindingPatterns01_ES6.types | 4 +- ...gParameterNestedObjectBindingPattern.types | 18 ++--- ...tedObjectBindingPatternDefaultValues.types | 51 +++---------- ...cturingParameterObjectBindingPattern.types | 18 ++--- ...terObjectBindingPatternDefaultValues.types | 18 ++--- ...cturingParametertArrayBindingPattern.types | 6 +- ...turingParametertArrayBindingPattern2.types | 6 +- ...tertArrayBindingPatternDefaultValues.types | 24 +++--- ...ertArrayBindingPatternDefaultValues2.types | 27 +++---- 19 files changed, 207 insertions(+), 199 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index cf3bd49751a..1503da355c7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2176,7 +2176,12 @@ namespace ts { if (isRestParameter(parameterNode)) { writePunctuation(writer, SyntaxKind.DotDotDotToken); } - appendSymbolNameOnly(p, writer); + if (isBindingPattern(parameterNode.name)) { + buildBindingPatternDisplay(parameterNode.name, writer, enclosingDeclaration, flags, symbolStack); + } + else { + appendSymbolNameOnly(p, writer); + } if (isOptionalParameter(parameterNode)) { writePunctuation(writer, SyntaxKind.QuestionToken); } @@ -2186,20 +2191,65 @@ namespace ts { buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } + function buildBindingPatternDisplay(bindingPattern: BindingPattern, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) { + // We have to explicitly emit square bracket and bracket because these tokens are not store inside the node. + if (bindingPattern.kind === SyntaxKind.ObjectBindingPattern) { + writePunctuation(writer, SyntaxKind.OpenBraceToken); + buildDisplatForCommaSeparatedList(bindingPattern.elements, writer, enclosingDeclaration, flags, symbolStack, buildBindingElementDisplay); + writePunctuation(writer, SyntaxKind.CloseBraceToken); + } + else if (bindingPattern.kind === SyntaxKind.ArrayBindingPattern) { + writePunctuation(writer, SyntaxKind.OpenBracketToken); + const elements = bindingPattern.elements; + buildDisplatForCommaSeparatedList(bindingPattern.elements, writer, enclosingDeclaration, flags, symbolStack, buildBindingElementDisplay); + if (elements && elements.hasTrailingComma) { + writePunctuation(writer, SyntaxKind.CommaToken); + } + writePunctuation(writer, SyntaxKind.CloseBracketToken); + } + } + + function buildBindingElementDisplay(bindingElement: BindingElement, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) { + if (bindingElement.kind === SyntaxKind.OmittedExpression) { + writeSpace(writer); + } + else if (bindingElement.kind === SyntaxKind.BindingElement) { + if (bindingElement.propertyName) { + writer.writeSymbol(getTextOfNode(bindingElement.propertyName), bindingElement.symbol); + writePunctuation(writer, SyntaxKind.ColonToken); + } + if (bindingElement.name) { + if (isBindingPattern(bindingElement.name)) { + buildBindingPatternDisplay(bindingElement.name, writer, enclosingDeclaration, flags, symbolStack); + } + else { + if (bindingElement.dotDotDotToken) { + writePunctuation(writer, SyntaxKind.DotDotDotToken); + } + appendSymbolNameOnly(bindingElement.symbol, writer); + } + } + } + } + function buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) { if (typeParameters && typeParameters.length) { writePunctuation(writer, SyntaxKind.LessThanToken); - for (let i = 0; i < typeParameters.length; i++) { - if (i > 0) { - writePunctuation(writer, SyntaxKind.CommaToken); - writeSpace(writer); - } - buildTypeParameterDisplay(typeParameters[i], writer, enclosingDeclaration, flags, symbolStack); - } + buildDisplatForCommaSeparatedList(typeParameters, writer, enclosingDeclaration, flags, symbolStack, buildTypeParameterDisplay); writePunctuation(writer, SyntaxKind.GreaterThanToken); } } + function buildDisplatForCommaSeparatedList(list: T[], writer: SymbolWriter, enclosingDeclaration: Node, flags: TypeFormatFlags, symbolStack: Symbol[], action: (item: T, writer: SymbolWriter, enclosingDeclaration: Node, flags: TypeFormatFlags, symbolStack: Symbol[]) => void) { + for (let i = 0; i < list.length; i++) { + if (i > 0) { + writePunctuation(writer, SyntaxKind.CommaToken); + writeSpace(writer); + } + action(list[i], writer, enclosingDeclaration, flags, symbolStack); + } + } + function buildDisplayForTypeArgumentsAndDelimiters(typeParameters: TypeParameter[], mapper: TypeMapper, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) { if (typeParameters && typeParameters.length) { writePunctuation(writer, SyntaxKind.LessThanToken); diff --git a/tests/baselines/reference/arrayBindingPatternOmittedExpressions.types b/tests/baselines/reference/arrayBindingPatternOmittedExpressions.types index e83aa6a17de..e529c7cdde5 100644 --- a/tests/baselines/reference/arrayBindingPatternOmittedExpressions.types +++ b/tests/baselines/reference/arrayBindingPatternOmittedExpressions.types @@ -25,7 +25,7 @@ var results: string[]; function f([, a, , b, , , , s, , , ] = results) { ->f : ([, a, , b, , , , s, , , ]?: string[]) => void +>f : ([ , a, , b, , , , s, , ,]?: string[]) => void > : undefined >a : string > : undefined diff --git a/tests/baselines/reference/arrowFunctionExpressions.types b/tests/baselines/reference/arrowFunctionExpressions.types index eedd20944fe..b2e6cf1e57b 100644 --- a/tests/baselines/reference/arrowFunctionExpressions.types +++ b/tests/baselines/reference/arrowFunctionExpressions.types @@ -65,43 +65,43 @@ var p2 = ([...a]) => { }; >a : any[] var p3 = ([, a]) => { }; ->p3 : ([, a]: [any, any]) => void ->([, a]) => { } : ([, a]: [any, any]) => void +>p3 : ([ , a]: [any, any]) => void +>([, a]) => { } : ([ , a]: [any, any]) => void > : undefined >a : any var p4 = ([, ...a]) => { }; ->p4 : ([, ...a]: any[]) => void ->([, ...a]) => { } : ([, ...a]: any[]) => void +>p4 : ([ , ...a]: any[]) => void +>([, ...a]) => { } : ([ , ...a]: any[]) => void > : undefined >a : any[] var p5 = ([a = 1]) => { }; ->p5 : ([a = 1]: [number]) => void ->([a = 1]) => { } : ([a = 1]: [number]) => void +>p5 : ([a]: [number]) => void +>([a = 1]) => { } : ([a]: [number]) => void >a : number >1 : number var p6 = ({ a }) => { }; ->p6 : ({ a }: { a: any; }) => void ->({ a }) => { } : ({ a }: { a: any; }) => void +>p6 : ({a}: { a: any; }) => void +>({ a }) => { } : ({a}: { a: any; }) => void >a : any var p7 = ({ a: { b } }) => { }; ->p7 : ({ a: { b } }: { a: { b: any; }; }) => void ->({ a: { b } }) => { } : ({ a: { b } }: { a: { b: any; }; }) => void +>p7 : ({a:{b}}: { a: { b: any; }; }) => void +>({ a: { b } }) => { } : ({a:{b}}: { a: { b: any; }; }) => void >a : any >b : any var p8 = ({ a = 1 }) => { }; ->p8 : ({ a = 1 }: { a?: number; }) => void ->({ a = 1 }) => { } : ({ a = 1 }: { a?: number; }) => void +>p8 : ({a}: { a?: number; }) => void +>({ a = 1 }) => { } : ({a}: { a?: number; }) => void >a : number >1 : number var p9 = ({ a: { b = 1 } = { b: 1 } }) => { }; ->p9 : ({ a: { b = 1 } = { b: 1 } }: { a?: { b?: number; }; }) => void ->({ a: { b = 1 } = { b: 1 } }) => { } : ({ a: { b = 1 } = { b: 1 } }: { a?: { b?: number; }; }) => void +>p9 : ({a:{b}}: { a?: { b?: number; }; }) => void +>({ a: { b = 1 } = { b: 1 } }) => { } : ({a:{b}}: { a?: { b?: number; }; }) => void >a : any >b : number >1 : number @@ -110,8 +110,8 @@ var p9 = ({ a: { b = 1 } = { b: 1 } }) => { }; >1 : number var p10 = ([{ value, done }]) => { }; ->p10 : ([{ value, done }]: [{ value: any; done: any; }]) => void ->([{ value, done }]) => { } : ([{ value, done }]: [{ value: any; done: any; }]) => void +>p10 : ([{value, done}]: [{ value: any; done: any; }]) => void +>([{ value, done }]) => { } : ([{value, done}]: [{ value: any; done: any; }]) => void >value : any >done : any diff --git a/tests/baselines/reference/declarationEmitDestructuring1.types b/tests/baselines/reference/declarationEmitDestructuring1.types index abba67981d8..a1c7acad853 100644 --- a/tests/baselines/reference/declarationEmitDestructuring1.types +++ b/tests/baselines/reference/declarationEmitDestructuring1.types @@ -21,7 +21,7 @@ function bar({a1, b1, c1}: { a1: number, b1: boolean, c1: string }): void { } >c1 : string function baz({a2, b2: {b1, c1}}: { a2: number, b2: { b1: boolean, c1: string } }): void { } ->baz : ({a2, b2: {b1, c1}}: { a2: number; b2: { b1: boolean; c1: string; }; }) => void +>baz : ({a2, b2:{b1, c1}}: { a2: number; b2: { b1: boolean; c1: string; }; }) => void >a2 : number >b2 : any >b1 : boolean diff --git a/tests/baselines/reference/declarationEmitDestructuring5.types b/tests/baselines/reference/declarationEmitDestructuring5.types index f09b1ebf50c..0b36373ebe2 100644 --- a/tests/baselines/reference/declarationEmitDestructuring5.types +++ b/tests/baselines/reference/declarationEmitDestructuring5.types @@ -1,23 +1,23 @@ === tests/cases/compiler/declarationEmitDestructuring5.ts === function baz([, z, , ]) { } ->baz : ([, z, , ]: [any, any, any]) => void +>baz : ([ , z, ,]: [any, any, any]) => void > : undefined >z : any > : undefined function foo([, b, ]: [any, any]): void { } ->foo : ([, b, ]: [any, any]) => void +>foo : ([ , b,]: [any, any]) => void > : undefined >b : any function bar([z, , , ]) { } ->bar : ([z, , , ]: [any, any, any]) => void +>bar : ([z, , ,]: [any, any, any]) => void >z : any > : undefined > : undefined function bar1([z, , , ] = [1, 3, 4, 6, 7]) { } ->bar1 : ([z, , , ]?: [number, number, number, number, number]) => void +>bar1 : ([z, , ,]?: [number, number, number, number, number]) => void >z : number > : undefined > : undefined @@ -29,7 +29,7 @@ function bar1([z, , , ] = [1, 3, 4, 6, 7]) { } >7 : number function bar2([,,z, , , ]) { } ->bar2 : ([,,z, , , ]: [any, any, any, any, any]) => void +>bar2 : ([ , , z, , ,]: [any, any, any, any, any]) => void > : undefined > : undefined >z : any diff --git a/tests/baselines/reference/declarationEmitDestructuringOptionalBindingParametersInOverloads.types b/tests/baselines/reference/declarationEmitDestructuringOptionalBindingParametersInOverloads.types index 1c75466f0c3..9eabfebe877 100644 --- a/tests/baselines/reference/declarationEmitDestructuringOptionalBindingParametersInOverloads.types +++ b/tests/baselines/reference/declarationEmitDestructuringOptionalBindingParametersInOverloads.types @@ -12,7 +12,7 @@ function foo(...rest: any[]) { } function foo2( { x, y, z }?: { x: string; y: number; z: boolean }); ->foo2 : ({ x, y, z }?: { x: string; y: number; z: boolean; }) => any +>foo2 : ({x, y, z}?: { x: string; y: number; z: boolean; }) => any >x : string >y : number >z : boolean @@ -21,7 +21,7 @@ function foo2( { x, y, z }?: { x: string; y: number; z: boolean }); >z : boolean function foo2(...rest: any[]) { ->foo2 : ({ x, y, z }?: { x: string; y: number; z: boolean; }) => any +>foo2 : ({x, y, z}?: { x: string; y: number; z: boolean; }) => any >rest : any[] } diff --git a/tests/baselines/reference/destructuringInFunctionType.types b/tests/baselines/reference/destructuringInFunctionType.types index 8786bbd0bb9..93e702225b5 100644 --- a/tests/baselines/reference/destructuringInFunctionType.types +++ b/tests/baselines/reference/destructuringInFunctionType.types @@ -29,7 +29,7 @@ type T2 = ({ a }); >a : any type F2 = ({ a }) => void; ->F2 : ({ a }: { a: any; }) => void +>F2 : ({a}: { a: any; }) => void >a : any type T3 = ([{ a: b }, { b: a }]); @@ -40,7 +40,7 @@ type T3 = ([{ a: b }, { b: a }]); >a : a type F3 = ([{ a: b }, { b: a }]) => void; ->F3 : ([{ a: b }, { b: a }]: [{ a: any; }, { b: any; }]) => void +>F3 : ([{a:b}, {b:a}]: [{ a: any; }, { b: any; }]) => void >a : any >b : any >b : any @@ -53,13 +53,13 @@ type T4 = ([{ a: [b, c] }]); >c : c type F4 = ([{ a: [b, c] }]) => void; ->F4 : ([{ a: [b, c] }]: [{ a: [any, any]; }]) => void +>F4 : ([{a:[b, c]}]: [{ a: [any, any]; }]) => void >a : any >b : any >c : any type C1 = new ([{ a: [b, c] }]) => void; ->C1 : new ([{ a: [b, c] }]: [{ a: [any, any]; }]) => void +>C1 : new ([{a:[b, c]}]: [{ a: [any, any]; }]) => void >a : any >b : any >c : any diff --git a/tests/baselines/reference/destructuringWithLiteralInitializers.types b/tests/baselines/reference/destructuringWithLiteralInitializers.types index da1e4bfd6f3..97e9b8d095a 100644 --- a/tests/baselines/reference/destructuringWithLiteralInitializers.types +++ b/tests/baselines/reference/destructuringWithLiteralInitializers.types @@ -1,13 +1,13 @@ === tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts === // (arg: { x: any, y: any }) => void function f1({ x, y }) { } ->f1 : ({ x, y }: { x: any; y: any; }) => void +>f1 : ({x, y}: { x: any; y: any; }) => void >x : any >y : any f1({ x: 1, y: 1 }); >f1({ x: 1, y: 1 }) : void ->f1 : ({ x, y }: { x: any; y: any; }) => void +>f1 : ({x, y}: { x: any; y: any; }) => void >{ x: 1, y: 1 } : { x: number; y: number; } >x : number >1 : number @@ -16,21 +16,21 @@ f1({ x: 1, y: 1 }); // (arg: { x: any, y?: number }) => void function f2({ x, y = 0 }) { } ->f2 : ({ x, y = 0 }: { x: any; y?: number; }) => void +>f2 : ({x, y}: { x: any; y?: number; }) => void >x : any >y : number >0 : number f2({ x: 1 }); >f2({ x: 1 }) : void ->f2 : ({ x, y = 0 }: { x: any; y?: number; }) => void +>f2 : ({x, y}: { x: any; y?: number; }) => void >{ x: 1 } : { x: number; } >x : number >1 : number f2({ x: 1, y: 1 }); >f2({ x: 1, y: 1 }) : void ->f2 : ({ x, y = 0 }: { x: any; y?: number; }) => void +>f2 : ({x, y}: { x: any; y?: number; }) => void >{ x: 1, y: 1 } : { x: number; y: number; } >x : number >1 : number @@ -39,7 +39,7 @@ f2({ x: 1, y: 1 }); // (arg: { x?: number, y?: number }) => void function f3({ x = 0, y = 0 }) { } ->f3 : ({ x = 0, y = 0 }: { x?: number; y?: number; }) => void +>f3 : ({x, y}: { x?: number; y?: number; }) => void >x : number >0 : number >y : number @@ -47,26 +47,26 @@ function f3({ x = 0, y = 0 }) { } f3({}); >f3({}) : void ->f3 : ({ x = 0, y = 0 }: { x?: number; y?: number; }) => void +>f3 : ({x, y}: { x?: number; y?: number; }) => void >{} : {} f3({ x: 1 }); >f3({ x: 1 }) : void ->f3 : ({ x = 0, y = 0 }: { x?: number; y?: number; }) => void +>f3 : ({x, y}: { x?: number; y?: number; }) => void >{ x: 1 } : { x: number; } >x : number >1 : number f3({ y: 1 }); >f3({ y: 1 }) : void ->f3 : ({ x = 0, y = 0 }: { x?: number; y?: number; }) => void +>f3 : ({x, y}: { x?: number; y?: number; }) => void >{ y: 1 } : { y: number; } >y : number >1 : number f3({ x: 1, y: 1 }); >f3({ x: 1, y: 1 }) : void ->f3 : ({ x = 0, y = 0 }: { x?: number; y?: number; }) => void +>f3 : ({x, y}: { x?: number; y?: number; }) => void >{ x: 1, y: 1 } : { x: number; y: number; } >x : number >1 : number @@ -75,7 +75,7 @@ f3({ x: 1, y: 1 }); // (arg?: { x: number, y: number }) => void function f4({ x, y } = { x: 0, y: 0 }) { } ->f4 : ({ x, y }?: { x: number; y: number; }) => void +>f4 : ({x, y}?: { x: number; y: number; }) => void >x : number >y : number >{ x: 0, y: 0 } : { x: number; y: number; } @@ -86,11 +86,11 @@ function f4({ x, y } = { x: 0, y: 0 }) { } f4(); >f4() : void ->f4 : ({ x, y }?: { x: number; y: number; }) => void +>f4 : ({x, y}?: { x: number; y: number; }) => void f4({ x: 1, y: 1 }); >f4({ x: 1, y: 1 }) : void ->f4 : ({ x, y }?: { x: number; y: number; }) => void +>f4 : ({x, y}?: { x: number; y: number; }) => void >{ x: 1, y: 1 } : { x: number; y: number; } >x : number >1 : number @@ -99,7 +99,7 @@ f4({ x: 1, y: 1 }); // (arg?: { x: number, y?: number }) => void function f5({ x, y = 0 } = { x: 0 }) { } ->f5 : ({ x, y = 0 }?: { x: number; y?: number; }) => void +>f5 : ({x, y}?: { x: number; y?: number; }) => void >x : number >y : number >0 : number @@ -109,18 +109,18 @@ function f5({ x, y = 0 } = { x: 0 }) { } f5(); >f5() : void ->f5 : ({ x, y = 0 }?: { x: number; y?: number; }) => void +>f5 : ({x, y}?: { x: number; y?: number; }) => void f5({ x: 1 }); >f5({ x: 1 }) : void ->f5 : ({ x, y = 0 }?: { x: number; y?: number; }) => void +>f5 : ({x, y}?: { x: number; y?: number; }) => void >{ x: 1 } : { x: number; } >x : number >1 : number f5({ x: 1, y: 1 }); >f5({ x: 1, y: 1 }) : void ->f5 : ({ x, y = 0 }?: { x: number; y?: number; }) => void +>f5 : ({x, y}?: { x: number; y?: number; }) => void >{ x: 1, y: 1 } : { x: number; y: number; } >x : number >1 : number @@ -129,7 +129,7 @@ f5({ x: 1, y: 1 }); // (arg?: { x?: number, y?: number }) => void function f6({ x = 0, y = 0 } = {}) { } ->f6 : ({ x = 0, y = 0 }?: { x?: number; y?: number; }) => void +>f6 : ({x, y}?: { x?: number; y?: number; }) => void >x : number >0 : number >y : number @@ -138,30 +138,30 @@ function f6({ x = 0, y = 0 } = {}) { } f6(); >f6() : void ->f6 : ({ x = 0, y = 0 }?: { x?: number; y?: number; }) => void +>f6 : ({x, y}?: { x?: number; y?: number; }) => void f6({}); >f6({}) : void ->f6 : ({ x = 0, y = 0 }?: { x?: number; y?: number; }) => void +>f6 : ({x, y}?: { x?: number; y?: number; }) => void >{} : {} f6({ x: 1 }); >f6({ x: 1 }) : void ->f6 : ({ x = 0, y = 0 }?: { x?: number; y?: number; }) => void +>f6 : ({x, y}?: { x?: number; y?: number; }) => void >{ x: 1 } : { x: number; } >x : number >1 : number f6({ y: 1 }); >f6({ y: 1 }) : void ->f6 : ({ x = 0, y = 0 }?: { x?: number; y?: number; }) => void +>f6 : ({x, y}?: { x?: number; y?: number; }) => void >{ y: 1 } : { y: number; } >y : number >1 : number f6({ x: 1, y: 1 }); >f6({ x: 1, y: 1 }) : void ->f6 : ({ x = 0, y = 0 }?: { x?: number; y?: number; }) => void +>f6 : ({x, y}?: { x?: number; y?: number; }) => void >{ x: 1, y: 1 } : { x: number; y: number; } >x : number >1 : number @@ -170,7 +170,7 @@ f6({ x: 1, y: 1 }); // (arg?: { a: { x?: number, y?: number } }) => void function f7({ a: { x = 0, y = 0 } } = { a: {} }) { } ->f7 : ({ a: { x = 0, y = 0 } }?: { a: { x?: number; y?: number; }; }) => void +>f7 : ({a:{x, y}}?: { a: { x?: number; y?: number; }; }) => void >a : any >x : number >0 : number @@ -182,18 +182,18 @@ function f7({ a: { x = 0, y = 0 } } = { a: {} }) { } f7(); >f7() : void ->f7 : ({ a: { x = 0, y = 0 } }?: { a: { x?: number; y?: number; }; }) => void +>f7 : ({a:{x, y}}?: { a: { x?: number; y?: number; }; }) => void f7({ a: {} }); >f7({ a: {} }) : void ->f7 : ({ a: { x = 0, y = 0 } }?: { a: { x?: number; y?: number; }; }) => void +>f7 : ({a:{x, y}}?: { a: { x?: number; y?: number; }; }) => void >{ a: {} } : { a: {}; } >a : {} >{} : {} f7({ a: { x: 1 } }); >f7({ a: { x: 1 } }) : void ->f7 : ({ a: { x = 0, y = 0 } }?: { a: { x?: number; y?: number; }; }) => void +>f7 : ({a:{x, y}}?: { a: { x?: number; y?: number; }; }) => void >{ a: { x: 1 } } : { a: { x: number; }; } >a : { x: number; } >{ x: 1 } : { x: number; } @@ -202,7 +202,7 @@ f7({ a: { x: 1 } }); f7({ a: { y: 1 } }); >f7({ a: { y: 1 } }) : void ->f7 : ({ a: { x = 0, y = 0 } }?: { a: { x?: number; y?: number; }; }) => void +>f7 : ({a:{x, y}}?: { a: { x?: number; y?: number; }; }) => void >{ a: { y: 1 } } : { a: { y: number; }; } >a : { y: number; } >{ y: 1 } : { y: number; } @@ -211,7 +211,7 @@ f7({ a: { y: 1 } }); f7({ a: { x: 1, y: 1 } }); >f7({ a: { x: 1, y: 1 } }) : void ->f7 : ({ a: { x = 0, y = 0 } }?: { a: { x?: number; y?: number; }; }) => void +>f7 : ({a:{x, y}}?: { a: { x?: number; y?: number; }; }) => void >{ a: { x: 1, y: 1 } } : { a: { x: number; y: number; }; } >a : { x: number; y: number; } >{ x: 1, y: 1 } : { x: number; y: number; } @@ -235,7 +235,7 @@ g1([1, 1]); // (arg: [number, number]) => void function g2([x = 0, y = 0]) { } ->g2 : ([x = 0, y = 0]: [number, number]) => void +>g2 : ([x, y]: [number, number]) => void >x : number >0 : number >y : number @@ -243,7 +243,7 @@ function g2([x = 0, y = 0]) { } g2([1, 1]); >g2([1, 1]) : void ->g2 : ([x = 0, y = 0]: [number, number]) => void +>g2 : ([x, y]: [number, number]) => void >[1, 1] : [number, number] >1 : number >1 : number @@ -270,7 +270,7 @@ g3([1, 1]); // (arg?: [number, number]) => void function g4([x, y = 0] = [0]) { } ->g4 : ([x, y = 0]?: [number, number]) => void +>g4 : ([x, y]?: [number, number]) => void >x : number >y : number >0 : number @@ -279,18 +279,18 @@ function g4([x, y = 0] = [0]) { } g4(); >g4() : void ->g4 : ([x, y = 0]?: [number, number]) => void +>g4 : ([x, y]?: [number, number]) => void g4([1, 1]); >g4([1, 1]) : void ->g4 : ([x, y = 0]?: [number, number]) => void +>g4 : ([x, y]?: [number, number]) => void >[1, 1] : [number, number] >1 : number >1 : number // (arg?: [number, number]) => void function g5([x = 0, y = 0] = []) { } ->g5 : ([x = 0, y = 0]?: [number, number]) => void +>g5 : ([x, y]?: [number, number]) => void >x : number >0 : number >y : number @@ -299,11 +299,11 @@ function g5([x = 0, y = 0] = []) { } g5(); >g5() : void ->g5 : ([x = 0, y = 0]?: [number, number]) => void +>g5 : ([x, y]?: [number, number]) => void g5([1, 1]); >g5([1, 1]) : void ->g5 : ([x = 0, y = 0]?: [number, number]) => void +>g5 : ([x, y]?: [number, number]) => void >[1, 1] : [number, number] >1 : number >1 : number diff --git a/tests/baselines/reference/emitArrowFunctionES6.types b/tests/baselines/reference/emitArrowFunctionES6.types index cc48cecd96a..21340956c59 100644 --- a/tests/baselines/reference/emitArrowFunctionES6.types +++ b/tests/baselines/reference/emitArrowFunctionES6.types @@ -52,43 +52,43 @@ var p2 = ([...a]) => { }; >a : any[] var p3 = ([, a]) => { }; ->p3 : ([, a]: [any, any]) => void ->([, a]) => { } : ([, a]: [any, any]) => void +>p3 : ([ , a]: [any, any]) => void +>([, a]) => { } : ([ , a]: [any, any]) => void > : undefined >a : any var p4 = ([, ...a]) => { }; ->p4 : ([, ...a]: Iterable) => void ->([, ...a]) => { } : ([, ...a]: Iterable) => void +>p4 : ([ , ...a]: Iterable) => void +>([, ...a]) => { } : ([ , ...a]: Iterable) => void > : undefined >a : any[] var p5 = ([a = 1]) => { }; ->p5 : ([a = 1]: [number]) => void ->([a = 1]) => { } : ([a = 1]: [number]) => void +>p5 : ([a]: [number]) => void +>([a = 1]) => { } : ([a]: [number]) => void >a : number >1 : number var p6 = ({ a }) => { }; ->p6 : ({ a }: { a: any; }) => void ->({ a }) => { } : ({ a }: { a: any; }) => void +>p6 : ({a}: { a: any; }) => void +>({ a }) => { } : ({a}: { a: any; }) => void >a : any var p7 = ({ a: { b } }) => { }; ->p7 : ({ a: { b } }: { a: { b: any; }; }) => void ->({ a: { b } }) => { } : ({ a: { b } }: { a: { b: any; }; }) => void +>p7 : ({a:{b}}: { a: { b: any; }; }) => void +>({ a: { b } }) => { } : ({a:{b}}: { a: { b: any; }; }) => void >a : any >b : any var p8 = ({ a = 1 }) => { }; ->p8 : ({ a = 1 }: { a?: number; }) => void ->({ a = 1 }) => { } : ({ a = 1 }: { a?: number; }) => void +>p8 : ({a}: { a?: number; }) => void +>({ a = 1 }) => { } : ({a}: { a?: number; }) => void >a : number >1 : number var p9 = ({ a: { b = 1 } = { b: 1 } }) => { }; ->p9 : ({ a: { b = 1 } = { b: 1 } }: { a?: { b?: number; }; }) => void ->({ a: { b = 1 } = { b: 1 } }) => { } : ({ a: { b = 1 } = { b: 1 } }: { a?: { b?: number; }; }) => void +>p9 : ({a:{b}}: { a?: { b?: number; }; }) => void +>({ a: { b = 1 } = { b: 1 } }) => { } : ({a:{b}}: { a?: { b?: number; }; }) => void >a : any >b : number >1 : number @@ -97,8 +97,8 @@ var p9 = ({ a: { b = 1 } = { b: 1 } }) => { }; >1 : number var p10 = ([{ value, done }]) => { }; ->p10 : ([{ value, done }]: [{ value: any; done: any; }]) => void ->([{ value, done }]) => { } : ([{ value, done }]: [{ value: any; done: any; }]) => void +>p10 : ([{value, done}]: [{ value: any; done: any; }]) => void +>([{ value, done }]) => { } : ([{value, done}]: [{ value: any; done: any; }]) => void >value : any >done : any diff --git a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5.types b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5.types index ed6b935db0f..a9a9366ae22 100644 --- a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5.types +++ b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5.types @@ -62,7 +62,7 @@ } function f({} = a, [] = a, { p: {} = a} = a) { ->f : ({}?: any, []?: any, { p: {} = a}?: any) => ({}?: any, []?: any, { p: {} = a }?: any) => any +>f : ({}?: any, []?: any, {p:{}}?: any) => ({}?: any, []?: any, {p:{}}?: any) => any >a : any >a : any >p : any @@ -70,7 +70,7 @@ >a : any return ({} = a, [] = a, { p: {} = a } = a) => a; ->({} = a, [] = a, { p: {} = a } = a) => a : ({}?: any, []?: any, { p: {} = a }?: any) => any +>({} = a, [] = a, { p: {} = a } = a) => a : ({}?: any, []?: any, {p:{}}?: any) => any >a : any >a : any >p : any diff --git a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES6.types b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES6.types index fcb48048148..09e1f0b853b 100644 --- a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES6.types +++ b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES6.types @@ -62,7 +62,7 @@ } function f({} = a, [] = a, { p: {} = a} = a) { ->f : ({}?: any, []?: any, { p: {} = a}?: any) => ({}?: any, []?: any, { p: {} = a }?: any) => any +>f : ({}?: any, []?: any, {p:{}}?: any) => ({}?: any, []?: any, {p:{}}?: any) => any >a : any >a : any >p : any @@ -70,7 +70,7 @@ >a : any return ({} = a, [] = a, { p: {} = a } = a) => a; ->({} = a, [] = a, { p: {} = a } = a) => a : ({}?: any, []?: any, { p: {} = a }?: any) => any +>({} = a, [] = a, { p: {} = a } = a) => a : ({}?: any, []?: any, {p:{}}?: any) => any >a : any >a : any >p : any diff --git a/tests/baselines/reference/sourceMapValidationDestructuringParameterNestedObjectBindingPattern.types b/tests/baselines/reference/sourceMapValidationDestructuringParameterNestedObjectBindingPattern.types index 029e47cd3a0..323612ffc94 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringParameterNestedObjectBindingPattern.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringParameterNestedObjectBindingPattern.types @@ -37,7 +37,7 @@ var robotA: Robot = { name: "mower", skills: { primary: "mowing", secondary: "no >"none" : string function foo1({ skills: { primary: primaryA, secondary: secondaryA } }: Robot) { ->foo1 : ({ skills: { primary: primaryA, secondary: secondaryA } }: Robot) => void +>foo1 : ({skills:{primary:primaryA, secondary:secondaryA}}: Robot) => void >skills : any >primary : any >primaryA : string @@ -53,7 +53,7 @@ function foo1({ skills: { primary: primaryA, secondary: secondaryA } }: Robot) { >primaryA : string } function foo2({ name: nameC, skills: { primary: primaryB, secondary: secondaryB } }: Robot) { ->foo2 : ({ name: nameC, skills: { primary: primaryB, secondary: secondaryB } }: Robot) => void +>foo2 : ({name:nameC, skills:{primary:primaryB, secondary:secondaryB}}: Robot) => void >name : any >nameC : string >skills : any @@ -71,7 +71,7 @@ function foo2({ name: nameC, skills: { primary: primaryB, secondary: secondaryB >secondaryB : string } function foo3({ skills }: Robot) { ->foo3 : ({ skills }: Robot) => void +>foo3 : ({skills}: Robot) => void >skills : { primary: string; secondary: string; } >Robot : Robot @@ -87,12 +87,12 @@ function foo3({ skills }: Robot) { foo1(robotA); >foo1(robotA) : void ->foo1 : ({ skills: { primary: primaryA, secondary: secondaryA } }: Robot) => void +>foo1 : ({skills:{primary:primaryA, secondary:secondaryA}}: Robot) => void >robotA : Robot foo1({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } }); >foo1({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } }) : void ->foo1 : ({ skills: { primary: primaryA, secondary: secondaryA } }: Robot) => void +>foo1 : ({skills:{primary:primaryA, secondary:secondaryA}}: Robot) => void >{ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string >"Edger" : string @@ -105,12 +105,12 @@ foo1({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" foo2(robotA); >foo2(robotA) : void ->foo2 : ({ name: nameC, skills: { primary: primaryB, secondary: secondaryB } }: Robot) => void +>foo2 : ({name:nameC, skills:{primary:primaryB, secondary:secondaryB}}: Robot) => void >robotA : Robot foo2({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } }); >foo2({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } }) : void ->foo2 : ({ name: nameC, skills: { primary: primaryB, secondary: secondaryB } }: Robot) => void +>foo2 : ({name:nameC, skills:{primary:primaryB, secondary:secondaryB}}: Robot) => void >{ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string >"Edger" : string @@ -123,12 +123,12 @@ foo2({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" foo3(robotA); >foo3(robotA) : void ->foo3 : ({ skills }: Robot) => void +>foo3 : ({skills}: Robot) => void >robotA : Robot foo3({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } }); >foo3({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } }) : void ->foo3 : ({ skills }: Robot) => void +>foo3 : ({skills}: Robot) => void >{ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string >"Edger" : string diff --git a/tests/baselines/reference/sourceMapValidationDestructuringParameterNestedObjectBindingPatternDefaultValues.types b/tests/baselines/reference/sourceMapValidationDestructuringParameterNestedObjectBindingPatternDefaultValues.types index a9e5c2d6ee6..5d8cbc311ae 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringParameterNestedObjectBindingPatternDefaultValues.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringParameterNestedObjectBindingPatternDefaultValues.types @@ -37,12 +37,7 @@ var robotA: Robot = { name: "mower", skills: { primary: "mowing", secondary: "no >"none" : string function foo1( ->foo1 : ({ - skills: { - primary: primaryA = "primary", - secondary: secondaryA = "secondary" - } = { primary: "SomeSkill", secondary: "someSkill" } - }?: Robot) => void +>foo1 : ({skills:{primary:primaryA, secondary:secondaryA}}?: Robot) => void { skills: { >skills : any @@ -76,13 +71,7 @@ function foo1( >primaryA : string } function foo2( ->foo2 : ({ - name: nameC = "name", - skills: { - primary: primaryB = "primary", - secondary: secondaryB = "secondary" - } = { primary: "SomeSkill", secondary: "someSkill" } - }?: Robot) => void +>foo2 : ({name:nameC, skills:{primary:primaryB, secondary:secondaryB}}?: Robot) => void { name: nameC = "name", >name : any @@ -121,7 +110,7 @@ function foo2( >secondaryB : string } function foo3({ skills = { primary: "SomeSkill", secondary: "someSkill" } }: Robot = robotA) { ->foo3 : ({ skills = { primary: "SomeSkill", secondary: "someSkill" } }?: Robot) => void +>foo3 : ({skills}?: Robot) => void >skills : { primary?: string; secondary?: string; } >{ primary: "SomeSkill", secondary: "someSkill" } : { primary: string; secondary: string; } >primary : string @@ -143,22 +132,12 @@ function foo3({ skills = { primary: "SomeSkill", secondary: "someSkill" } }: Ro foo1(robotA); >foo1(robotA) : void ->foo1 : ({ - skills: { - primary: primaryA = "primary", - secondary: secondaryA = "secondary" - } = { primary: "SomeSkill", secondary: "someSkill" } - }?: Robot) => void +>foo1 : ({skills:{primary:primaryA, secondary:secondaryA}}?: Robot) => void >robotA : Robot foo1({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } }); >foo1({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } }) : void ->foo1 : ({ - skills: { - primary: primaryA = "primary", - secondary: secondaryA = "secondary" - } = { primary: "SomeSkill", secondary: "someSkill" } - }?: Robot) => void +>foo1 : ({skills:{primary:primaryA, secondary:secondaryA}}?: Robot) => void >{ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string >"Edger" : string @@ -171,24 +150,12 @@ foo1({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" foo2(robotA); >foo2(robotA) : void ->foo2 : ({ - name: nameC = "name", - skills: { - primary: primaryB = "primary", - secondary: secondaryB = "secondary" - } = { primary: "SomeSkill", secondary: "someSkill" } - }?: Robot) => void +>foo2 : ({name:nameC, skills:{primary:primaryB, secondary:secondaryB}}?: Robot) => void >robotA : Robot foo2({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } }); >foo2({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } }) : void ->foo2 : ({ - name: nameC = "name", - skills: { - primary: primaryB = "primary", - secondary: secondaryB = "secondary" - } = { primary: "SomeSkill", secondary: "someSkill" } - }?: Robot) => void +>foo2 : ({name:nameC, skills:{primary:primaryB, secondary:secondaryB}}?: Robot) => void >{ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string >"Edger" : string @@ -201,12 +168,12 @@ foo2({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" foo3(robotA); >foo3(robotA) : void ->foo3 : ({ skills = { primary: "SomeSkill", secondary: "someSkill" } }?: Robot) => void +>foo3 : ({skills}?: Robot) => void >robotA : Robot foo3({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } }); >foo3({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } }) : void ->foo3 : ({ skills = { primary: "SomeSkill", secondary: "someSkill" } }?: Robot) => void +>foo3 : ({skills}?: Robot) => void >{ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string >"Edger" : string diff --git a/tests/baselines/reference/sourceMapValidationDestructuringParameterObjectBindingPattern.types b/tests/baselines/reference/sourceMapValidationDestructuringParameterObjectBindingPattern.types index 894cd714c73..9154ba582d8 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringParameterObjectBindingPattern.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringParameterObjectBindingPattern.types @@ -29,7 +29,7 @@ var robotA: Robot = { name: "mower", skill: "mowing" }; >"mowing" : string function foo1({ name: nameA }: Robot) { ->foo1 : ({ name: nameA }: Robot) => void +>foo1 : ({name:nameA}: Robot) => void >name : any >nameA : string >Robot : Robot @@ -42,7 +42,7 @@ function foo1({ name: nameA }: Robot) { >nameA : string } function foo2({ name: nameB, skill: skillB }: Robot) { ->foo2 : ({ name: nameB, skill: skillB }: Robot) => void +>foo2 : ({name:nameB, skill:skillB}: Robot) => void >name : any >nameB : string >skill : any @@ -57,7 +57,7 @@ function foo2({ name: nameB, skill: skillB }: Robot) { >nameB : string } function foo3({ name }: Robot) { ->foo3 : ({ name }: Robot) => void +>foo3 : ({name}: Robot) => void >name : string >Robot : Robot @@ -71,12 +71,12 @@ function foo3({ name }: Robot) { foo1(robotA); >foo1(robotA) : void ->foo1 : ({ name: nameA }: Robot) => void +>foo1 : ({name:nameA}: Robot) => void >robotA : Robot foo1({ name: "Edger", skill: "cutting edges" }); >foo1({ name: "Edger", skill: "cutting edges" }) : void ->foo1 : ({ name: nameA }: Robot) => void +>foo1 : ({name:nameA}: Robot) => void >{ name: "Edger", skill: "cutting edges" } : { name: string; skill: string; } >name : string >"Edger" : string @@ -85,12 +85,12 @@ foo1({ name: "Edger", skill: "cutting edges" }); foo2(robotA); >foo2(robotA) : void ->foo2 : ({ name: nameB, skill: skillB }: Robot) => void +>foo2 : ({name:nameB, skill:skillB}: Robot) => void >robotA : Robot foo2({ name: "Edger", skill: "cutting edges" }); >foo2({ name: "Edger", skill: "cutting edges" }) : void ->foo2 : ({ name: nameB, skill: skillB }: Robot) => void +>foo2 : ({name:nameB, skill:skillB}: Robot) => void >{ name: "Edger", skill: "cutting edges" } : { name: string; skill: string; } >name : string >"Edger" : string @@ -99,12 +99,12 @@ foo2({ name: "Edger", skill: "cutting edges" }); foo3(robotA); >foo3(robotA) : void ->foo3 : ({ name }: Robot) => void +>foo3 : ({name}: Robot) => void >robotA : Robot foo3({ name: "Edger", skill: "cutting edges" }); >foo3({ name: "Edger", skill: "cutting edges" }) : void ->foo3 : ({ name }: Robot) => void +>foo3 : ({name}: Robot) => void >{ name: "Edger", skill: "cutting edges" } : { name: string; skill: string; } >name : string >"Edger" : string diff --git a/tests/baselines/reference/sourceMapValidationDestructuringParameterObjectBindingPatternDefaultValues.types b/tests/baselines/reference/sourceMapValidationDestructuringParameterObjectBindingPatternDefaultValues.types index 669708f412f..ed7090d4fc8 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringParameterObjectBindingPatternDefaultValues.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringParameterObjectBindingPatternDefaultValues.types @@ -29,7 +29,7 @@ var robotA: Robot = { name: "mower", skill: "mowing" }; >"mowing" : string function foo1({ name: nameA = "" }: Robot = { }) { ->foo1 : ({ name: nameA = "" }?: Robot) => void +>foo1 : ({name:nameA}?: Robot) => void >name : any >nameA : string >"" : string @@ -44,7 +44,7 @@ function foo1({ name: nameA = "" }: Robot = { }) { >nameA : string } function foo2({ name: nameB = "", skill: skillB = "noSkill" }: Robot = {}) { ->foo2 : ({ name: nameB = "", skill: skillB = "noSkill" }?: Robot) => void +>foo2 : ({name:nameB, skill:skillB}?: Robot) => void >name : any >nameB : string >"" : string @@ -62,7 +62,7 @@ function foo2({ name: nameB = "", skill: skillB = "noSkill" }: Robot = { >nameB : string } function foo3({ name = "" }: Robot = {}) { ->foo3 : ({ name = "" }?: Robot) => void +>foo3 : ({name}?: Robot) => void >name : string >"" : string >Robot : Robot @@ -78,12 +78,12 @@ function foo3({ name = "" }: Robot = {}) { foo1(robotA); >foo1(robotA) : void ->foo1 : ({ name: nameA = "" }?: Robot) => void +>foo1 : ({name:nameA}?: Robot) => void >robotA : Robot foo1({ name: "Edger", skill: "cutting edges" }); >foo1({ name: "Edger", skill: "cutting edges" }) : void ->foo1 : ({ name: nameA = "" }?: Robot) => void +>foo1 : ({name:nameA}?: Robot) => void >{ name: "Edger", skill: "cutting edges" } : { name: string; skill: string; } >name : string >"Edger" : string @@ -92,12 +92,12 @@ foo1({ name: "Edger", skill: "cutting edges" }); foo2(robotA); >foo2(robotA) : void ->foo2 : ({ name: nameB = "", skill: skillB = "noSkill" }?: Robot) => void +>foo2 : ({name:nameB, skill:skillB}?: Robot) => void >robotA : Robot foo2({ name: "Edger", skill: "cutting edges" }); >foo2({ name: "Edger", skill: "cutting edges" }) : void ->foo2 : ({ name: nameB = "", skill: skillB = "noSkill" }?: Robot) => void +>foo2 : ({name:nameB, skill:skillB}?: Robot) => void >{ name: "Edger", skill: "cutting edges" } : { name: string; skill: string; } >name : string >"Edger" : string @@ -106,12 +106,12 @@ foo2({ name: "Edger", skill: "cutting edges" }); foo3(robotA); >foo3(robotA) : void ->foo3 : ({ name = "" }?: Robot) => void +>foo3 : ({name}?: Robot) => void >robotA : Robot foo3({ name: "Edger", skill: "cutting edges" }); >foo3({ name: "Edger", skill: "cutting edges" }) : void ->foo3 : ({ name = "" }?: Robot) => void +>foo3 : ({name}?: Robot) => void >{ name: "Edger", skill: "cutting edges" } : { name: string; skill: string; } >name : string >"Edger" : string diff --git a/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPattern.types b/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPattern.types index 9c695f1c0dd..fcdeba6becc 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPattern.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPattern.types @@ -18,7 +18,7 @@ var robotA: Robot = [1, "mower", "mowing"]; >"mowing" : string function foo1([, nameA]: Robot) { ->foo1 : ([, nameA]: [number, string, string]) => void +>foo1 : ([ , nameA]: [number, string, string]) => void > : undefined >nameA : string >Robot : [number, string, string] @@ -75,12 +75,12 @@ function foo4([numberA3, ...robotAInfo]: Robot) { foo1(robotA); >foo1(robotA) : void ->foo1 : ([, nameA]: [number, string, string]) => void +>foo1 : ([ , nameA]: [number, string, string]) => void >robotA : [number, string, string] foo1([2, "trimmer", "trimming"]); >foo1([2, "trimmer", "trimming"]) : void ->foo1 : ([, nameA]: [number, string, string]) => void +>foo1 : ([ , nameA]: [number, string, string]) => void >[2, "trimmer", "trimming"] : [number, string, string] >2 : number >"trimmer" : string diff --git a/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPattern2.types b/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPattern2.types index b3e09d962c3..14977147a7d 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPattern2.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPattern2.types @@ -19,7 +19,7 @@ var robotA: Robot = ["trimmer", ["trimming", "edging"]]; >"edging" : string function foo1([, skillA]: Robot) { ->foo1 : ([, skillA]: [string, [string, string]]) => void +>foo1 : ([ , skillA]: [string, [string, string]]) => void > : undefined >skillA : [string, string] >Robot : [string, [string, string]] @@ -75,12 +75,12 @@ function foo4([...multiRobotAInfo]: Robot) { foo1(robotA); >foo1(robotA) : void ->foo1 : ([, skillA]: [string, [string, string]]) => void +>foo1 : ([ , skillA]: [string, [string, string]]) => void >robotA : [string, [string, string]] foo1(["roomba", ["vaccum", "mopping"]]); >foo1(["roomba", ["vaccum", "mopping"]]) : void ->foo1 : ([, skillA]: [string, [string, string]]) => void +>foo1 : ([ , skillA]: [string, [string, string]]) => void >["roomba", ["vaccum", "mopping"]] : [string, [string, string]] >"roomba" : string >["vaccum", "mopping"] : [string, string] diff --git a/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues.types b/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues.types index 8e12e876b1d..328f003f7d1 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues.types @@ -18,7 +18,7 @@ var robotA: Robot = [1, "mower", "mowing"]; >"mowing" : string function foo1([, nameA = "noName"]: Robot = [-1, "name", "skill"]) { ->foo1 : ([, nameA = "noName"]?: [number, string, string]) => void +>foo1 : ([ , nameA]?: [number, string, string]) => void > : undefined >nameA : string >"noName" : string @@ -38,7 +38,7 @@ function foo1([, nameA = "noName"]: Robot = [-1, "name", "skill"]) { } function foo2([numberB = -1]: Robot = [-1, "name", "skill"]) { ->foo2 : ([numberB = -1]?: [number, string, string]) => void +>foo2 : ([numberB]?: [number, string, string]) => void >numberB : number >-1 : number >1 : number @@ -58,7 +58,7 @@ function foo2([numberB = -1]: Robot = [-1, "name", "skill"]) { } function foo3([numberA2 = -1, nameA2 = "name", skillA2 = "skill"]: Robot = [-1, "name", "skill"]) { ->foo3 : ([numberA2 = -1, nameA2 = "name", skillA2 = "skill"]?: [number, string, string]) => void +>foo3 : ([numberA2, nameA2, skillA2]?: [number, string, string]) => void >numberA2 : number >-1 : number >1 : number @@ -82,7 +82,7 @@ function foo3([numberA2 = -1, nameA2 = "name", skillA2 = "skill"]: Robot = [-1, } function foo4([numberA3 = -1, ...robotAInfo]: Robot = [-1, "name", "skill"]) { ->foo4 : ([numberA3 = -1, ...robotAInfo]?: [number, string, string]) => void +>foo4 : ([numberA3, ...robotAInfo]?: [number, string, string]) => void >numberA3 : number >-1 : number >1 : number @@ -104,12 +104,12 @@ function foo4([numberA3 = -1, ...robotAInfo]: Robot = [-1, "name", "skill"]) { foo1(robotA); >foo1(robotA) : void ->foo1 : ([, nameA = "noName"]?: [number, string, string]) => void +>foo1 : ([ , nameA]?: [number, string, string]) => void >robotA : [number, string, string] foo1([2, "trimmer", "trimming"]); >foo1([2, "trimmer", "trimming"]) : void ->foo1 : ([, nameA = "noName"]?: [number, string, string]) => void +>foo1 : ([ , nameA]?: [number, string, string]) => void >[2, "trimmer", "trimming"] : [number, string, string] >2 : number >"trimmer" : string @@ -117,12 +117,12 @@ foo1([2, "trimmer", "trimming"]); foo2(robotA); >foo2(robotA) : void ->foo2 : ([numberB = -1]?: [number, string, string]) => void +>foo2 : ([numberB]?: [number, string, string]) => void >robotA : [number, string, string] foo2([2, "trimmer", "trimming"]); >foo2([2, "trimmer", "trimming"]) : void ->foo2 : ([numberB = -1]?: [number, string, string]) => void +>foo2 : ([numberB]?: [number, string, string]) => void >[2, "trimmer", "trimming"] : [number, string, string] >2 : number >"trimmer" : string @@ -130,12 +130,12 @@ foo2([2, "trimmer", "trimming"]); foo3(robotA); >foo3(robotA) : void ->foo3 : ([numberA2 = -1, nameA2 = "name", skillA2 = "skill"]?: [number, string, string]) => void +>foo3 : ([numberA2, nameA2, skillA2]?: [number, string, string]) => void >robotA : [number, string, string] foo3([2, "trimmer", "trimming"]); >foo3([2, "trimmer", "trimming"]) : void ->foo3 : ([numberA2 = -1, nameA2 = "name", skillA2 = "skill"]?: [number, string, string]) => void +>foo3 : ([numberA2, nameA2, skillA2]?: [number, string, string]) => void >[2, "trimmer", "trimming"] : [number, string, string] >2 : number >"trimmer" : string @@ -143,12 +143,12 @@ foo3([2, "trimmer", "trimming"]); foo4(robotA); >foo4(robotA) : void ->foo4 : ([numberA3 = -1, ...robotAInfo]?: [number, string, string]) => void +>foo4 : ([numberA3, ...robotAInfo]?: [number, string, string]) => void >robotA : [number, string, string] foo4([2, "trimmer", "trimming"]); >foo4([2, "trimmer", "trimming"]) : void ->foo4 : ([numberA3 = -1, ...robotAInfo]?: [number, string, string]) => void +>foo4 : ([numberA3, ...robotAInfo]?: [number, string, string]) => void >[2, "trimmer", "trimming"] : [number, string, string] >2 : number >"trimmer" : string diff --git a/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues2.types b/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues2.types index 52423dfce21..d47aef363c9 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues2.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues2.types @@ -19,7 +19,7 @@ var robotA: Robot = ["trimmer", ["trimming", "edging"]]; >"edging" : string function foo1([, skillA = ["noSkill", "noSkill"]]: Robot= ["name", ["skill1", "skill2"]]) { ->foo1 : ([, skillA = ["noSkill", "noSkill"]]?: [string, string[]]) => void +>foo1 : ([ , skillA]?: [string, string[]]) => void > : undefined >skillA : string[] >["noSkill", "noSkill"] : string[] @@ -41,7 +41,7 @@ function foo1([, skillA = ["noSkill", "noSkill"]]: Robot= ["name", ["skill1", "s } function foo2([nameMB = "noName"]: Robot = ["name", ["skill1", "skill2"]]) { ->foo2 : ([nameMB = "noName"]?: [string, string[]]) => void +>foo2 : ([nameMB]?: [string, string[]]) => void >nameMB : string >"noName" : string >Robot : [string, string[]] @@ -60,10 +60,7 @@ function foo2([nameMB = "noName"]: Robot = ["name", ["skill1", "skill2"]]) { } function foo3([nameMA = "noName", [ ->foo3 : ([nameMA = "noName", [ - primarySkillA = "primary", - secondarySkillA = "secondary" -] = ["noSkill", "noSkill"]]: [string, string[]]) => void +>foo3 : ([nameMA, [primarySkillA, secondarySkillA]]: [string, string[]]) => void >nameMA : string >"noName" : string @@ -91,12 +88,12 @@ function foo3([nameMA = "noName", [ foo1(robotA); >foo1(robotA) : void ->foo1 : ([, skillA = ["noSkill", "noSkill"]]?: [string, string[]]) => void +>foo1 : ([ , skillA]?: [string, string[]]) => void >robotA : [string, string[]] foo1(["roomba", ["vaccum", "mopping"]]); >foo1(["roomba", ["vaccum", "mopping"]]) : void ->foo1 : ([, skillA = ["noSkill", "noSkill"]]?: [string, string[]]) => void +>foo1 : ([ , skillA]?: [string, string[]]) => void >["roomba", ["vaccum", "mopping"]] : [string, string[]] >"roomba" : string >["vaccum", "mopping"] : string[] @@ -105,12 +102,12 @@ foo1(["roomba", ["vaccum", "mopping"]]); foo2(robotA); >foo2(robotA) : void ->foo2 : ([nameMB = "noName"]?: [string, string[]]) => void +>foo2 : ([nameMB]?: [string, string[]]) => void >robotA : [string, string[]] foo2(["roomba", ["vaccum", "mopping"]]); >foo2(["roomba", ["vaccum", "mopping"]]) : void ->foo2 : ([nameMB = "noName"]?: [string, string[]]) => void +>foo2 : ([nameMB]?: [string, string[]]) => void >["roomba", ["vaccum", "mopping"]] : [string, string[]] >"roomba" : string >["vaccum", "mopping"] : string[] @@ -119,18 +116,12 @@ foo2(["roomba", ["vaccum", "mopping"]]); foo3(robotA); >foo3(robotA) : void ->foo3 : ([nameMA = "noName", [ - primarySkillA = "primary", - secondarySkillA = "secondary" -] = ["noSkill", "noSkill"]]: [string, string[]]) => void +>foo3 : ([nameMA, [primarySkillA, secondarySkillA]]: [string, string[]]) => void >robotA : [string, string[]] foo3(["roomba", ["vaccum", "mopping"]]); >foo3(["roomba", ["vaccum", "mopping"]]) : void ->foo3 : ([nameMA = "noName", [ - primarySkillA = "primary", - secondarySkillA = "secondary" -] = ["noSkill", "noSkill"]]: [string, string[]]) => void +>foo3 : ([nameMA, [primarySkillA, secondarySkillA]]: [string, string[]]) => void >["roomba", ["vaccum", "mopping"]] : [string, string[]] >"roomba" : string >["vaccum", "mopping"] : string[] From 8b9afce894fa6b3970c2021ab4be83f811679ea2 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 24 Feb 2016 13:02:30 -0800 Subject: [PATCH 2/6] Add test --- .../declarationEmit_bindingPatters.js | 26 +++++++++++++++++++ .../declarationEmit_bindingPatters.symbols | 17 ++++++++++++ .../declarationEmit_bindingPatters.types | 20 ++++++++++++++ .../declarationEmit_bindingPatters.ts | 7 +++++ 4 files changed, 70 insertions(+) create mode 100644 tests/baselines/reference/declarationEmit_bindingPatters.js create mode 100644 tests/baselines/reference/declarationEmit_bindingPatters.symbols create mode 100644 tests/baselines/reference/declarationEmit_bindingPatters.types create mode 100644 tests/cases/compiler/declarationEmit_bindingPatters.ts diff --git a/tests/baselines/reference/declarationEmit_bindingPatters.js b/tests/baselines/reference/declarationEmit_bindingPatters.js new file mode 100644 index 00000000000..e97d93dc634 --- /dev/null +++ b/tests/baselines/reference/declarationEmit_bindingPatters.js @@ -0,0 +1,26 @@ +//// [declarationEmit_bindingPatters.ts] + +const k = ({x: z = 'y'}) => { } + +var a; +function f({} = a, [] = a, { p: {} = a} = a) { +} + +//// [declarationEmit_bindingPatters.js] +var k = function (_a) { + var _b = _a.x, z = _b === void 0 ? 'y' : _b; +}; +var a; +function f(_a, _b, _c) { + var _a = a; + var _b = a; + var _d = (_c === void 0 ? a : _c).p, _e = _d === void 0 ? a : _d; +} + + +//// [declarationEmit_bindingPatters.d.ts] +declare const k: ({x:z}: { + x?: string; +}) => void; +declare var a: any; +declare function f({}?: any, []?: any, {p: {}}?: any): void; diff --git a/tests/baselines/reference/declarationEmit_bindingPatters.symbols b/tests/baselines/reference/declarationEmit_bindingPatters.symbols new file mode 100644 index 00000000000..522166ed511 --- /dev/null +++ b/tests/baselines/reference/declarationEmit_bindingPatters.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/declarationEmit_bindingPatters.ts === + +const k = ({x: z = 'y'}) => { } +>k : Symbol(k, Decl(declarationEmit_bindingPatters.ts, 1, 5)) +>x : Symbol(x) +>z : Symbol(z, Decl(declarationEmit_bindingPatters.ts, 1, 12)) + +var a; +>a : Symbol(a, Decl(declarationEmit_bindingPatters.ts, 3, 3)) + +function f({} = a, [] = a, { p: {} = a} = a) { +>f : Symbol(f, Decl(declarationEmit_bindingPatters.ts, 3, 6)) +>a : Symbol(a, Decl(declarationEmit_bindingPatters.ts, 3, 3)) +>a : Symbol(a, Decl(declarationEmit_bindingPatters.ts, 3, 3)) +>a : Symbol(a, Decl(declarationEmit_bindingPatters.ts, 3, 3)) +>a : Symbol(a, Decl(declarationEmit_bindingPatters.ts, 3, 3)) +} diff --git a/tests/baselines/reference/declarationEmit_bindingPatters.types b/tests/baselines/reference/declarationEmit_bindingPatters.types new file mode 100644 index 00000000000..44c5b3e9f43 --- /dev/null +++ b/tests/baselines/reference/declarationEmit_bindingPatters.types @@ -0,0 +1,20 @@ +=== tests/cases/compiler/declarationEmit_bindingPatters.ts === + +const k = ({x: z = 'y'}) => { } +>k : ({x:z}: { x?: string; }) => void +>({x: z = 'y'}) => { } : ({x:z}: { x?: string; }) => void +>x : any +>z : string +>'y' : string + +var a; +>a : any + +function f({} = a, [] = a, { p: {} = a} = a) { +>f : ({}?: any, []?: any, {p:{}}?: any) => void +>a : any +>a : any +>p : any +>a : any +>a : any +} diff --git a/tests/cases/compiler/declarationEmit_bindingPatters.ts b/tests/cases/compiler/declarationEmit_bindingPatters.ts new file mode 100644 index 00000000000..16d380307fd --- /dev/null +++ b/tests/cases/compiler/declarationEmit_bindingPatters.ts @@ -0,0 +1,7 @@ +// @declaration: true + +const k = ({x: z = 'y'}) => { } + +var a; +function f({} = a, [] = a, { p: {} = a} = a) { +} \ No newline at end of file From 4bf5f82e83a727ae1efffdf22a41081985343d37 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 24 Feb 2016 13:25:08 -0800 Subject: [PATCH 3/6] Do not add extra space for ommited expressions. --- src/compiler/checker.ts | 27 +++++++++---------- ...rrayBindingPatternOmittedExpressions.types | 2 +- .../reference/arrowFunctionExpressions.types | 8 +++--- .../declarationEmitDestructuring5.types | 10 +++---- .../reference/emitArrowFunctionES6.types | 8 +++--- ...cturingParametertArrayBindingPattern.types | 6 ++--- ...turingParametertArrayBindingPattern2.types | 6 ++--- ...tertArrayBindingPatternDefaultValues.types | 6 ++--- ...ertArrayBindingPatternDefaultValues2.types | 6 ++--- 9 files changed, 39 insertions(+), 40 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1503da355c7..ad4ec27e1ba 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2211,23 +2211,22 @@ namespace ts { function buildBindingElementDisplay(bindingElement: BindingElement, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) { if (bindingElement.kind === SyntaxKind.OmittedExpression) { - writeSpace(writer); + return; } - else if (bindingElement.kind === SyntaxKind.BindingElement) { - if (bindingElement.propertyName) { - writer.writeSymbol(getTextOfNode(bindingElement.propertyName), bindingElement.symbol); - writePunctuation(writer, SyntaxKind.ColonToken); + Debug.assert(bindingElement.kind === SyntaxKind.BindingElement); + if (bindingElement.propertyName) { + writer.writeSymbol(getTextOfNode(bindingElement.propertyName), bindingElement.symbol); + writePunctuation(writer, SyntaxKind.ColonToken); + } + if (bindingElement.name) { + if (isBindingPattern(bindingElement.name)) { + buildBindingPatternDisplay(bindingElement.name, writer, enclosingDeclaration, flags, symbolStack); } - if (bindingElement.name) { - if (isBindingPattern(bindingElement.name)) { - buildBindingPatternDisplay(bindingElement.name, writer, enclosingDeclaration, flags, symbolStack); - } - else { - if (bindingElement.dotDotDotToken) { - writePunctuation(writer, SyntaxKind.DotDotDotToken); - } - appendSymbolNameOnly(bindingElement.symbol, writer); + else { + if (bindingElement.dotDotDotToken) { + writePunctuation(writer, SyntaxKind.DotDotDotToken); } + appendSymbolNameOnly(bindingElement.symbol, writer); } } } diff --git a/tests/baselines/reference/arrayBindingPatternOmittedExpressions.types b/tests/baselines/reference/arrayBindingPatternOmittedExpressions.types index e529c7cdde5..77db8cc250d 100644 --- a/tests/baselines/reference/arrayBindingPatternOmittedExpressions.types +++ b/tests/baselines/reference/arrayBindingPatternOmittedExpressions.types @@ -25,7 +25,7 @@ var results: string[]; function f([, a, , b, , , , s, , , ] = results) { ->f : ([ , a, , b, , , , s, , ,]?: string[]) => void +>f : ([, a, , b, , , , s, , ,]?: string[]) => void > : undefined >a : string > : undefined diff --git a/tests/baselines/reference/arrowFunctionExpressions.types b/tests/baselines/reference/arrowFunctionExpressions.types index b2e6cf1e57b..9efc2db7a3b 100644 --- a/tests/baselines/reference/arrowFunctionExpressions.types +++ b/tests/baselines/reference/arrowFunctionExpressions.types @@ -65,14 +65,14 @@ var p2 = ([...a]) => { }; >a : any[] var p3 = ([, a]) => { }; ->p3 : ([ , a]: [any, any]) => void ->([, a]) => { } : ([ , a]: [any, any]) => void +>p3 : ([, a]: [any, any]) => void +>([, a]) => { } : ([, a]: [any, any]) => void > : undefined >a : any var p4 = ([, ...a]) => { }; ->p4 : ([ , ...a]: any[]) => void ->([, ...a]) => { } : ([ , ...a]: any[]) => void +>p4 : ([, ...a]: any[]) => void +>([, ...a]) => { } : ([, ...a]: any[]) => void > : undefined >a : any[] diff --git a/tests/baselines/reference/declarationEmitDestructuring5.types b/tests/baselines/reference/declarationEmitDestructuring5.types index 0b36373ebe2..961dea62bcb 100644 --- a/tests/baselines/reference/declarationEmitDestructuring5.types +++ b/tests/baselines/reference/declarationEmitDestructuring5.types @@ -1,23 +1,23 @@ === tests/cases/compiler/declarationEmitDestructuring5.ts === function baz([, z, , ]) { } ->baz : ([ , z, ,]: [any, any, any]) => void +>baz : ([, z, ,]: [any, any, any]) => void > : undefined >z : any > : undefined function foo([, b, ]: [any, any]): void { } ->foo : ([ , b,]: [any, any]) => void +>foo : ([, b,]: [any, any]) => void > : undefined >b : any function bar([z, , , ]) { } ->bar : ([z, , ,]: [any, any, any]) => void +>bar : ([z, , ,]: [any, any, any]) => void >z : any > : undefined > : undefined function bar1([z, , , ] = [1, 3, 4, 6, 7]) { } ->bar1 : ([z, , ,]?: [number, number, number, number, number]) => void +>bar1 : ([z, , ,]?: [number, number, number, number, number]) => void >z : number > : undefined > : undefined @@ -29,7 +29,7 @@ function bar1([z, , , ] = [1, 3, 4, 6, 7]) { } >7 : number function bar2([,,z, , , ]) { } ->bar2 : ([ , , z, , ,]: [any, any, any, any, any]) => void +>bar2 : ([, , z, , ,]: [any, any, any, any, any]) => void > : undefined > : undefined >z : any diff --git a/tests/baselines/reference/emitArrowFunctionES6.types b/tests/baselines/reference/emitArrowFunctionES6.types index 21340956c59..1730ef25534 100644 --- a/tests/baselines/reference/emitArrowFunctionES6.types +++ b/tests/baselines/reference/emitArrowFunctionES6.types @@ -52,14 +52,14 @@ var p2 = ([...a]) => { }; >a : any[] var p3 = ([, a]) => { }; ->p3 : ([ , a]: [any, any]) => void ->([, a]) => { } : ([ , a]: [any, any]) => void +>p3 : ([, a]: [any, any]) => void +>([, a]) => { } : ([, a]: [any, any]) => void > : undefined >a : any var p4 = ([, ...a]) => { }; ->p4 : ([ , ...a]: Iterable) => void ->([, ...a]) => { } : ([ , ...a]: Iterable) => void +>p4 : ([, ...a]: Iterable) => void +>([, ...a]) => { } : ([, ...a]: Iterable) => void > : undefined >a : any[] diff --git a/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPattern.types b/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPattern.types index fcdeba6becc..9c695f1c0dd 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPattern.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPattern.types @@ -18,7 +18,7 @@ var robotA: Robot = [1, "mower", "mowing"]; >"mowing" : string function foo1([, nameA]: Robot) { ->foo1 : ([ , nameA]: [number, string, string]) => void +>foo1 : ([, nameA]: [number, string, string]) => void > : undefined >nameA : string >Robot : [number, string, string] @@ -75,12 +75,12 @@ function foo4([numberA3, ...robotAInfo]: Robot) { foo1(robotA); >foo1(robotA) : void ->foo1 : ([ , nameA]: [number, string, string]) => void +>foo1 : ([, nameA]: [number, string, string]) => void >robotA : [number, string, string] foo1([2, "trimmer", "trimming"]); >foo1([2, "trimmer", "trimming"]) : void ->foo1 : ([ , nameA]: [number, string, string]) => void +>foo1 : ([, nameA]: [number, string, string]) => void >[2, "trimmer", "trimming"] : [number, string, string] >2 : number >"trimmer" : string diff --git a/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPattern2.types b/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPattern2.types index 14977147a7d..b3e09d962c3 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPattern2.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPattern2.types @@ -19,7 +19,7 @@ var robotA: Robot = ["trimmer", ["trimming", "edging"]]; >"edging" : string function foo1([, skillA]: Robot) { ->foo1 : ([ , skillA]: [string, [string, string]]) => void +>foo1 : ([, skillA]: [string, [string, string]]) => void > : undefined >skillA : [string, string] >Robot : [string, [string, string]] @@ -75,12 +75,12 @@ function foo4([...multiRobotAInfo]: Robot) { foo1(robotA); >foo1(robotA) : void ->foo1 : ([ , skillA]: [string, [string, string]]) => void +>foo1 : ([, skillA]: [string, [string, string]]) => void >robotA : [string, [string, string]] foo1(["roomba", ["vaccum", "mopping"]]); >foo1(["roomba", ["vaccum", "mopping"]]) : void ->foo1 : ([ , skillA]: [string, [string, string]]) => void +>foo1 : ([, skillA]: [string, [string, string]]) => void >["roomba", ["vaccum", "mopping"]] : [string, [string, string]] >"roomba" : string >["vaccum", "mopping"] : [string, string] diff --git a/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues.types b/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues.types index 328f003f7d1..366c538dda7 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues.types @@ -18,7 +18,7 @@ var robotA: Robot = [1, "mower", "mowing"]; >"mowing" : string function foo1([, nameA = "noName"]: Robot = [-1, "name", "skill"]) { ->foo1 : ([ , nameA]?: [number, string, string]) => void +>foo1 : ([, nameA]?: [number, string, string]) => void > : undefined >nameA : string >"noName" : string @@ -104,12 +104,12 @@ function foo4([numberA3 = -1, ...robotAInfo]: Robot = [-1, "name", "skill"]) { foo1(robotA); >foo1(robotA) : void ->foo1 : ([ , nameA]?: [number, string, string]) => void +>foo1 : ([, nameA]?: [number, string, string]) => void >robotA : [number, string, string] foo1([2, "trimmer", "trimming"]); >foo1([2, "trimmer", "trimming"]) : void ->foo1 : ([ , nameA]?: [number, string, string]) => void +>foo1 : ([, nameA]?: [number, string, string]) => void >[2, "trimmer", "trimming"] : [number, string, string] >2 : number >"trimmer" : string diff --git a/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues2.types b/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues2.types index d47aef363c9..bd140d6a232 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues2.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues2.types @@ -19,7 +19,7 @@ var robotA: Robot = ["trimmer", ["trimming", "edging"]]; >"edging" : string function foo1([, skillA = ["noSkill", "noSkill"]]: Robot= ["name", ["skill1", "skill2"]]) { ->foo1 : ([ , skillA]?: [string, string[]]) => void +>foo1 : ([, skillA]?: [string, string[]]) => void > : undefined >skillA : string[] >["noSkill", "noSkill"] : string[] @@ -88,12 +88,12 @@ function foo3([nameMA = "noName", [ foo1(robotA); >foo1(robotA) : void ->foo1 : ([ , skillA]?: [string, string[]]) => void +>foo1 : ([, skillA]?: [string, string[]]) => void >robotA : [string, string[]] foo1(["roomba", ["vaccum", "mopping"]]); >foo1(["roomba", ["vaccum", "mopping"]]) : void ->foo1 : ([ , skillA]?: [string, string[]]) => void +>foo1 : ([, skillA]?: [string, string[]]) => void >["roomba", ["vaccum", "mopping"]] : [string, string[]] >"roomba" : string >["vaccum", "mopping"] : string[] From 7680cdfaeeac7cd2c8be2115f3f0944568f41464 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 24 Feb 2016 13:46:22 -0800 Subject: [PATCH 4/6] Code review comments --- src/compiler/checker.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ad4ec27e1ba..b855103d9bf 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2195,13 +2195,13 @@ namespace ts { // We have to explicitly emit square bracket and bracket because these tokens are not store inside the node. if (bindingPattern.kind === SyntaxKind.ObjectBindingPattern) { writePunctuation(writer, SyntaxKind.OpenBraceToken); - buildDisplatForCommaSeparatedList(bindingPattern.elements, writer, enclosingDeclaration, flags, symbolStack, buildBindingElementDisplay); + buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, enclosingDeclaration, flags, symbolStack, buildBindingElementDisplay); writePunctuation(writer, SyntaxKind.CloseBraceToken); } else if (bindingPattern.kind === SyntaxKind.ArrayBindingPattern) { writePunctuation(writer, SyntaxKind.OpenBracketToken); const elements = bindingPattern.elements; - buildDisplatForCommaSeparatedList(bindingPattern.elements, writer, enclosingDeclaration, flags, symbolStack, buildBindingElementDisplay); + buildDisplayForCommaSeparatedList(elements, writer, enclosingDeclaration, flags, symbolStack, buildBindingElementDisplay); if (elements && elements.hasTrailingComma) { writePunctuation(writer, SyntaxKind.CommaToken); } @@ -2234,12 +2234,12 @@ namespace ts { function buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) { if (typeParameters && typeParameters.length) { writePunctuation(writer, SyntaxKind.LessThanToken); - buildDisplatForCommaSeparatedList(typeParameters, writer, enclosingDeclaration, flags, symbolStack, buildTypeParameterDisplay); + buildDisplayForCommaSeparatedList(typeParameters, writer, enclosingDeclaration, flags, symbolStack, buildTypeParameterDisplay); writePunctuation(writer, SyntaxKind.GreaterThanToken); } } - function buildDisplatForCommaSeparatedList(list: T[], writer: SymbolWriter, enclosingDeclaration: Node, flags: TypeFormatFlags, symbolStack: Symbol[], action: (item: T, writer: SymbolWriter, enclosingDeclaration: Node, flags: TypeFormatFlags, symbolStack: Symbol[]) => void) { + function buildDisplayForCommaSeparatedList(list: T[], writer: SymbolWriter, enclosingDeclaration: Node, flags: TypeFormatFlags, symbolStack: Symbol[], action: (item: T, writer: SymbolWriter, enclosingDeclaration: Node, flags: TypeFormatFlags, symbolStack: Symbol[]) => void) { for (let i = 0; i < list.length; i++) { if (i > 0) { writePunctuation(writer, SyntaxKind.CommaToken); From c3cfebfda8d3939f8d7594cd313ad365f6ac3c23 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 25 Feb 2016 13:14:34 -0800 Subject: [PATCH 5/6] Code review comments --- src/compiler/checker.ts | 29 +++++++++---------- .../reference/arrowFunctionExpressions.types | 8 ++--- .../declarationEmitDestructuring1.types | 2 +- ....js => declarationEmit_bindingPatterns.js} | 8 ++--- .../declarationEmit_bindingPatterns.symbols | 17 +++++++++++ .../declarationEmit_bindingPatterns.types | 20 +++++++++++++ .../declarationEmit_bindingPatters.symbols | 17 ----------- .../declarationEmit_bindingPatters.types | 20 ------------- .../destructuringInFunctionType.types | 6 ++-- ...destructuringWithLiteralInitializers.types | 12 ++++---- .../reference/emitArrowFunctionES6.types | 8 ++--- ...ableDeclarationBindingPatterns01_ES5.types | 4 +-- ...ableDeclarationBindingPatterns01_ES6.types | 4 +-- ...gParameterNestedObjectBindingPattern.types | 12 ++++---- ...tedObjectBindingPatternDefaultValues.types | 12 ++++---- ...cturingParameterObjectBindingPattern.types | 12 ++++---- ...terObjectBindingPatternDefaultValues.types | 12 ++++---- ....ts => declarationEmit_bindingPatterns.ts} | 0 18 files changed, 101 insertions(+), 102 deletions(-) rename tests/baselines/reference/{declarationEmit_bindingPatters.js => declarationEmit_bindingPatterns.js} (70%) create mode 100644 tests/baselines/reference/declarationEmit_bindingPatterns.symbols create mode 100644 tests/baselines/reference/declarationEmit_bindingPatterns.types delete mode 100644 tests/baselines/reference/declarationEmit_bindingPatters.symbols delete mode 100644 tests/baselines/reference/declarationEmit_bindingPatters.types rename tests/cases/compiler/{declarationEmit_bindingPatters.ts => declarationEmit_bindingPatterns.ts} (100%) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b855103d9bf..7e692dc78b8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2192,16 +2192,16 @@ namespace ts { } function buildBindingPatternDisplay(bindingPattern: BindingPattern, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) { - // We have to explicitly emit square bracket and bracket because these tokens are not store inside the node. + // We have to explicitly emit square bracket and bracket because these tokens are not stored inside the node. if (bindingPattern.kind === SyntaxKind.ObjectBindingPattern) { writePunctuation(writer, SyntaxKind.OpenBraceToken); - buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, enclosingDeclaration, flags, symbolStack, buildBindingElementDisplay); + buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, e => buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack)); writePunctuation(writer, SyntaxKind.CloseBraceToken); } else if (bindingPattern.kind === SyntaxKind.ArrayBindingPattern) { writePunctuation(writer, SyntaxKind.OpenBracketToken); const elements = bindingPattern.elements; - buildDisplayForCommaSeparatedList(elements, writer, enclosingDeclaration, flags, symbolStack, buildBindingElementDisplay); + buildDisplayForCommaSeparatedList(elements, writer, e => buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack)); if (elements && elements.hasTrailingComma) { writePunctuation(writer, SyntaxKind.CommaToken); } @@ -2217,35 +2217,34 @@ namespace ts { if (bindingElement.propertyName) { writer.writeSymbol(getTextOfNode(bindingElement.propertyName), bindingElement.symbol); writePunctuation(writer, SyntaxKind.ColonToken); + writeSpace(writer); } - if (bindingElement.name) { - if (isBindingPattern(bindingElement.name)) { - buildBindingPatternDisplay(bindingElement.name, writer, enclosingDeclaration, flags, symbolStack); - } - else { - if (bindingElement.dotDotDotToken) { - writePunctuation(writer, SyntaxKind.DotDotDotToken); - } - appendSymbolNameOnly(bindingElement.symbol, writer); + if (isBindingPattern(bindingElement.name)) { + buildBindingPatternDisplay(bindingElement.name, writer, enclosingDeclaration, flags, symbolStack); + } + else { + if (bindingElement.dotDotDotToken) { + writePunctuation(writer, SyntaxKind.DotDotDotToken); } + appendSymbolNameOnly(bindingElement.symbol, writer); } } function buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) { if (typeParameters && typeParameters.length) { writePunctuation(writer, SyntaxKind.LessThanToken); - buildDisplayForCommaSeparatedList(typeParameters, writer, enclosingDeclaration, flags, symbolStack, buildTypeParameterDisplay); + buildDisplayForCommaSeparatedList(typeParameters, writer, p => buildTypeParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack)); writePunctuation(writer, SyntaxKind.GreaterThanToken); } } - function buildDisplayForCommaSeparatedList(list: T[], writer: SymbolWriter, enclosingDeclaration: Node, flags: TypeFormatFlags, symbolStack: Symbol[], action: (item: T, writer: SymbolWriter, enclosingDeclaration: Node, flags: TypeFormatFlags, symbolStack: Symbol[]) => void) { + function buildDisplayForCommaSeparatedList(list: T[], writer: SymbolWriter, action: (item: T) => void) { for (let i = 0; i < list.length; i++) { if (i > 0) { writePunctuation(writer, SyntaxKind.CommaToken); writeSpace(writer); } - action(list[i], writer, enclosingDeclaration, flags, symbolStack); + action(list[i]); } } diff --git a/tests/baselines/reference/arrowFunctionExpressions.types b/tests/baselines/reference/arrowFunctionExpressions.types index 9efc2db7a3b..41344c61cc4 100644 --- a/tests/baselines/reference/arrowFunctionExpressions.types +++ b/tests/baselines/reference/arrowFunctionExpressions.types @@ -88,8 +88,8 @@ var p6 = ({ a }) => { }; >a : any var p7 = ({ a: { b } }) => { }; ->p7 : ({a:{b}}: { a: { b: any; }; }) => void ->({ a: { b } }) => { } : ({a:{b}}: { a: { b: any; }; }) => void +>p7 : ({a: {b}}: { a: { b: any; }; }) => void +>({ a: { b } }) => { } : ({a: {b}}: { a: { b: any; }; }) => void >a : any >b : any @@ -100,8 +100,8 @@ var p8 = ({ a = 1 }) => { }; >1 : number var p9 = ({ a: { b = 1 } = { b: 1 } }) => { }; ->p9 : ({a:{b}}: { a?: { b?: number; }; }) => void ->({ a: { b = 1 } = { b: 1 } }) => { } : ({a:{b}}: { a?: { b?: number; }; }) => void +>p9 : ({a: {b}}: { a?: { b?: number; }; }) => void +>({ a: { b = 1 } = { b: 1 } }) => { } : ({a: {b}}: { a?: { b?: number; }; }) => void >a : any >b : number >1 : number diff --git a/tests/baselines/reference/declarationEmitDestructuring1.types b/tests/baselines/reference/declarationEmitDestructuring1.types index a1c7acad853..abba67981d8 100644 --- a/tests/baselines/reference/declarationEmitDestructuring1.types +++ b/tests/baselines/reference/declarationEmitDestructuring1.types @@ -21,7 +21,7 @@ function bar({a1, b1, c1}: { a1: number, b1: boolean, c1: string }): void { } >c1 : string function baz({a2, b2: {b1, c1}}: { a2: number, b2: { b1: boolean, c1: string } }): void { } ->baz : ({a2, b2:{b1, c1}}: { a2: number; b2: { b1: boolean; c1: string; }; }) => void +>baz : ({a2, b2: {b1, c1}}: { a2: number; b2: { b1: boolean; c1: string; }; }) => void >a2 : number >b2 : any >b1 : boolean diff --git a/tests/baselines/reference/declarationEmit_bindingPatters.js b/tests/baselines/reference/declarationEmit_bindingPatterns.js similarity index 70% rename from tests/baselines/reference/declarationEmit_bindingPatters.js rename to tests/baselines/reference/declarationEmit_bindingPatterns.js index e97d93dc634..c2063ead215 100644 --- a/tests/baselines/reference/declarationEmit_bindingPatters.js +++ b/tests/baselines/reference/declarationEmit_bindingPatterns.js @@ -1,4 +1,4 @@ -//// [declarationEmit_bindingPatters.ts] +//// [declarationEmit_bindingPatterns.ts] const k = ({x: z = 'y'}) => { } @@ -6,7 +6,7 @@ var a; function f({} = a, [] = a, { p: {} = a} = a) { } -//// [declarationEmit_bindingPatters.js] +//// [declarationEmit_bindingPatterns.js] var k = function (_a) { var _b = _a.x, z = _b === void 0 ? 'y' : _b; }; @@ -18,8 +18,8 @@ function f(_a, _b, _c) { } -//// [declarationEmit_bindingPatters.d.ts] -declare const k: ({x:z}: { +//// [declarationEmit_bindingPatterns.d.ts] +declare const k: ({x: z}: { x?: string; }) => void; declare var a: any; diff --git a/tests/baselines/reference/declarationEmit_bindingPatterns.symbols b/tests/baselines/reference/declarationEmit_bindingPatterns.symbols new file mode 100644 index 00000000000..b39aca17ea3 --- /dev/null +++ b/tests/baselines/reference/declarationEmit_bindingPatterns.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/declarationEmit_bindingPatterns.ts === + +const k = ({x: z = 'y'}) => { } +>k : Symbol(k, Decl(declarationEmit_bindingPatterns.ts, 1, 5)) +>x : Symbol(x) +>z : Symbol(z, Decl(declarationEmit_bindingPatterns.ts, 1, 12)) + +var a; +>a : Symbol(a, Decl(declarationEmit_bindingPatterns.ts, 3, 3)) + +function f({} = a, [] = a, { p: {} = a} = a) { +>f : Symbol(f, Decl(declarationEmit_bindingPatterns.ts, 3, 6)) +>a : Symbol(a, Decl(declarationEmit_bindingPatterns.ts, 3, 3)) +>a : Symbol(a, Decl(declarationEmit_bindingPatterns.ts, 3, 3)) +>a : Symbol(a, Decl(declarationEmit_bindingPatterns.ts, 3, 3)) +>a : Symbol(a, Decl(declarationEmit_bindingPatterns.ts, 3, 3)) +} diff --git a/tests/baselines/reference/declarationEmit_bindingPatterns.types b/tests/baselines/reference/declarationEmit_bindingPatterns.types new file mode 100644 index 00000000000..eff2d4bd4a3 --- /dev/null +++ b/tests/baselines/reference/declarationEmit_bindingPatterns.types @@ -0,0 +1,20 @@ +=== tests/cases/compiler/declarationEmit_bindingPatterns.ts === + +const k = ({x: z = 'y'}) => { } +>k : ({x: z}: { x?: string; }) => void +>({x: z = 'y'}) => { } : ({x: z}: { x?: string; }) => void +>x : any +>z : string +>'y' : string + +var a; +>a : any + +function f({} = a, [] = a, { p: {} = a} = a) { +>f : ({}?: any, []?: any, {p: {}}?: any) => void +>a : any +>a : any +>p : any +>a : any +>a : any +} diff --git a/tests/baselines/reference/declarationEmit_bindingPatters.symbols b/tests/baselines/reference/declarationEmit_bindingPatters.symbols deleted file mode 100644 index 522166ed511..00000000000 --- a/tests/baselines/reference/declarationEmit_bindingPatters.symbols +++ /dev/null @@ -1,17 +0,0 @@ -=== tests/cases/compiler/declarationEmit_bindingPatters.ts === - -const k = ({x: z = 'y'}) => { } ->k : Symbol(k, Decl(declarationEmit_bindingPatters.ts, 1, 5)) ->x : Symbol(x) ->z : Symbol(z, Decl(declarationEmit_bindingPatters.ts, 1, 12)) - -var a; ->a : Symbol(a, Decl(declarationEmit_bindingPatters.ts, 3, 3)) - -function f({} = a, [] = a, { p: {} = a} = a) { ->f : Symbol(f, Decl(declarationEmit_bindingPatters.ts, 3, 6)) ->a : Symbol(a, Decl(declarationEmit_bindingPatters.ts, 3, 3)) ->a : Symbol(a, Decl(declarationEmit_bindingPatters.ts, 3, 3)) ->a : Symbol(a, Decl(declarationEmit_bindingPatters.ts, 3, 3)) ->a : Symbol(a, Decl(declarationEmit_bindingPatters.ts, 3, 3)) -} diff --git a/tests/baselines/reference/declarationEmit_bindingPatters.types b/tests/baselines/reference/declarationEmit_bindingPatters.types deleted file mode 100644 index 44c5b3e9f43..00000000000 --- a/tests/baselines/reference/declarationEmit_bindingPatters.types +++ /dev/null @@ -1,20 +0,0 @@ -=== tests/cases/compiler/declarationEmit_bindingPatters.ts === - -const k = ({x: z = 'y'}) => { } ->k : ({x:z}: { x?: string; }) => void ->({x: z = 'y'}) => { } : ({x:z}: { x?: string; }) => void ->x : any ->z : string ->'y' : string - -var a; ->a : any - -function f({} = a, [] = a, { p: {} = a} = a) { ->f : ({}?: any, []?: any, {p:{}}?: any) => void ->a : any ->a : any ->p : any ->a : any ->a : any -} diff --git a/tests/baselines/reference/destructuringInFunctionType.types b/tests/baselines/reference/destructuringInFunctionType.types index 93e702225b5..0cf057e06a3 100644 --- a/tests/baselines/reference/destructuringInFunctionType.types +++ b/tests/baselines/reference/destructuringInFunctionType.types @@ -40,7 +40,7 @@ type T3 = ([{ a: b }, { b: a }]); >a : a type F3 = ([{ a: b }, { b: a }]) => void; ->F3 : ([{a:b}, {b:a}]: [{ a: any; }, { b: any; }]) => void +>F3 : ([{a: b}, {b: a}]: [{ a: any; }, { b: any; }]) => void >a : any >b : any >b : any @@ -53,13 +53,13 @@ type T4 = ([{ a: [b, c] }]); >c : c type F4 = ([{ a: [b, c] }]) => void; ->F4 : ([{a:[b, c]}]: [{ a: [any, any]; }]) => void +>F4 : ([{a: [b, c]}]: [{ a: [any, any]; }]) => void >a : any >b : any >c : any type C1 = new ([{ a: [b, c] }]) => void; ->C1 : new ([{a:[b, c]}]: [{ a: [any, any]; }]) => void +>C1 : new ([{a: [b, c]}]: [{ a: [any, any]; }]) => void >a : any >b : any >c : any diff --git a/tests/baselines/reference/destructuringWithLiteralInitializers.types b/tests/baselines/reference/destructuringWithLiteralInitializers.types index 97e9b8d095a..9b970679f74 100644 --- a/tests/baselines/reference/destructuringWithLiteralInitializers.types +++ b/tests/baselines/reference/destructuringWithLiteralInitializers.types @@ -170,7 +170,7 @@ f6({ x: 1, y: 1 }); // (arg?: { a: { x?: number, y?: number } }) => void function f7({ a: { x = 0, y = 0 } } = { a: {} }) { } ->f7 : ({a:{x, y}}?: { a: { x?: number; y?: number; }; }) => void +>f7 : ({a: {x, y}}?: { a: { x?: number; y?: number; }; }) => void >a : any >x : number >0 : number @@ -182,18 +182,18 @@ function f7({ a: { x = 0, y = 0 } } = { a: {} }) { } f7(); >f7() : void ->f7 : ({a:{x, y}}?: { a: { x?: number; y?: number; }; }) => void +>f7 : ({a: {x, y}}?: { a: { x?: number; y?: number; }; }) => void f7({ a: {} }); >f7({ a: {} }) : void ->f7 : ({a:{x, y}}?: { a: { x?: number; y?: number; }; }) => void +>f7 : ({a: {x, y}}?: { a: { x?: number; y?: number; }; }) => void >{ a: {} } : { a: {}; } >a : {} >{} : {} f7({ a: { x: 1 } }); >f7({ a: { x: 1 } }) : void ->f7 : ({a:{x, y}}?: { a: { x?: number; y?: number; }; }) => void +>f7 : ({a: {x, y}}?: { a: { x?: number; y?: number; }; }) => void >{ a: { x: 1 } } : { a: { x: number; }; } >a : { x: number; } >{ x: 1 } : { x: number; } @@ -202,7 +202,7 @@ f7({ a: { x: 1 } }); f7({ a: { y: 1 } }); >f7({ a: { y: 1 } }) : void ->f7 : ({a:{x, y}}?: { a: { x?: number; y?: number; }; }) => void +>f7 : ({a: {x, y}}?: { a: { x?: number; y?: number; }; }) => void >{ a: { y: 1 } } : { a: { y: number; }; } >a : { y: number; } >{ y: 1 } : { y: number; } @@ -211,7 +211,7 @@ f7({ a: { y: 1 } }); f7({ a: { x: 1, y: 1 } }); >f7({ a: { x: 1, y: 1 } }) : void ->f7 : ({a:{x, y}}?: { a: { x?: number; y?: number; }; }) => void +>f7 : ({a: {x, y}}?: { a: { x?: number; y?: number; }; }) => void >{ a: { x: 1, y: 1 } } : { a: { x: number; y: number; }; } >a : { x: number; y: number; } >{ x: 1, y: 1 } : { x: number; y: number; } diff --git a/tests/baselines/reference/emitArrowFunctionES6.types b/tests/baselines/reference/emitArrowFunctionES6.types index 1730ef25534..d37c08f855c 100644 --- a/tests/baselines/reference/emitArrowFunctionES6.types +++ b/tests/baselines/reference/emitArrowFunctionES6.types @@ -75,8 +75,8 @@ var p6 = ({ a }) => { }; >a : any var p7 = ({ a: { b } }) => { }; ->p7 : ({a:{b}}: { a: { b: any; }; }) => void ->({ a: { b } }) => { } : ({a:{b}}: { a: { b: any; }; }) => void +>p7 : ({a: {b}}: { a: { b: any; }; }) => void +>({ a: { b } }) => { } : ({a: {b}}: { a: { b: any; }; }) => void >a : any >b : any @@ -87,8 +87,8 @@ var p8 = ({ a = 1 }) => { }; >1 : number var p9 = ({ a: { b = 1 } = { b: 1 } }) => { }; ->p9 : ({a:{b}}: { a?: { b?: number; }; }) => void ->({ a: { b = 1 } = { b: 1 } }) => { } : ({a:{b}}: { a?: { b?: number; }; }) => void +>p9 : ({a: {b}}: { a?: { b?: number; }; }) => void +>({ a: { b = 1 } = { b: 1 } }) => { } : ({a: {b}}: { a?: { b?: number; }; }) => void >a : any >b : number >1 : number diff --git a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5.types b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5.types index a9a9366ae22..3640d468a59 100644 --- a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5.types +++ b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5.types @@ -62,7 +62,7 @@ } function f({} = a, [] = a, { p: {} = a} = a) { ->f : ({}?: any, []?: any, {p:{}}?: any) => ({}?: any, []?: any, {p:{}}?: any) => any +>f : ({}?: any, []?: any, {p: {}}?: any) => ({}?: any, []?: any, {p: {}}?: any) => any >a : any >a : any >p : any @@ -70,7 +70,7 @@ >a : any return ({} = a, [] = a, { p: {} = a } = a) => a; ->({} = a, [] = a, { p: {} = a } = a) => a : ({}?: any, []?: any, {p:{}}?: any) => any +>({} = a, [] = a, { p: {} = a } = a) => a : ({}?: any, []?: any, {p: {}}?: any) => any >a : any >a : any >p : any diff --git a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES6.types b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES6.types index 09e1f0b853b..20b7d5ec2b6 100644 --- a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES6.types +++ b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES6.types @@ -62,7 +62,7 @@ } function f({} = a, [] = a, { p: {} = a} = a) { ->f : ({}?: any, []?: any, {p:{}}?: any) => ({}?: any, []?: any, {p:{}}?: any) => any +>f : ({}?: any, []?: any, {p: {}}?: any) => ({}?: any, []?: any, {p: {}}?: any) => any >a : any >a : any >p : any @@ -70,7 +70,7 @@ >a : any return ({} = a, [] = a, { p: {} = a } = a) => a; ->({} = a, [] = a, { p: {} = a } = a) => a : ({}?: any, []?: any, {p:{}}?: any) => any +>({} = a, [] = a, { p: {} = a } = a) => a : ({}?: any, []?: any, {p: {}}?: any) => any >a : any >a : any >p : any diff --git a/tests/baselines/reference/sourceMapValidationDestructuringParameterNestedObjectBindingPattern.types b/tests/baselines/reference/sourceMapValidationDestructuringParameterNestedObjectBindingPattern.types index 323612ffc94..af27c32d15b 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringParameterNestedObjectBindingPattern.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringParameterNestedObjectBindingPattern.types @@ -37,7 +37,7 @@ var robotA: Robot = { name: "mower", skills: { primary: "mowing", secondary: "no >"none" : string function foo1({ skills: { primary: primaryA, secondary: secondaryA } }: Robot) { ->foo1 : ({skills:{primary:primaryA, secondary:secondaryA}}: Robot) => void +>foo1 : ({skills: {primary: primaryA, secondary: secondaryA}}: Robot) => void >skills : any >primary : any >primaryA : string @@ -53,7 +53,7 @@ function foo1({ skills: { primary: primaryA, secondary: secondaryA } }: Robot) { >primaryA : string } function foo2({ name: nameC, skills: { primary: primaryB, secondary: secondaryB } }: Robot) { ->foo2 : ({name:nameC, skills:{primary:primaryB, secondary:secondaryB}}: Robot) => void +>foo2 : ({name: nameC, skills: {primary: primaryB, secondary: secondaryB}}: Robot) => void >name : any >nameC : string >skills : any @@ -87,12 +87,12 @@ function foo3({ skills }: Robot) { foo1(robotA); >foo1(robotA) : void ->foo1 : ({skills:{primary:primaryA, secondary:secondaryA}}: Robot) => void +>foo1 : ({skills: {primary: primaryA, secondary: secondaryA}}: Robot) => void >robotA : Robot foo1({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } }); >foo1({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } }) : void ->foo1 : ({skills:{primary:primaryA, secondary:secondaryA}}: Robot) => void +>foo1 : ({skills: {primary: primaryA, secondary: secondaryA}}: Robot) => void >{ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string >"Edger" : string @@ -105,12 +105,12 @@ foo1({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" foo2(robotA); >foo2(robotA) : void ->foo2 : ({name:nameC, skills:{primary:primaryB, secondary:secondaryB}}: Robot) => void +>foo2 : ({name: nameC, skills: {primary: primaryB, secondary: secondaryB}}: Robot) => void >robotA : Robot foo2({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } }); >foo2({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } }) : void ->foo2 : ({name:nameC, skills:{primary:primaryB, secondary:secondaryB}}: Robot) => void +>foo2 : ({name: nameC, skills: {primary: primaryB, secondary: secondaryB}}: Robot) => void >{ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string >"Edger" : string diff --git a/tests/baselines/reference/sourceMapValidationDestructuringParameterNestedObjectBindingPatternDefaultValues.types b/tests/baselines/reference/sourceMapValidationDestructuringParameterNestedObjectBindingPatternDefaultValues.types index 5d8cbc311ae..1115931feef 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringParameterNestedObjectBindingPatternDefaultValues.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringParameterNestedObjectBindingPatternDefaultValues.types @@ -37,7 +37,7 @@ var robotA: Robot = { name: "mower", skills: { primary: "mowing", secondary: "no >"none" : string function foo1( ->foo1 : ({skills:{primary:primaryA, secondary:secondaryA}}?: Robot) => void +>foo1 : ({skills: {primary: primaryA, secondary: secondaryA}}?: Robot) => void { skills: { >skills : any @@ -71,7 +71,7 @@ function foo1( >primaryA : string } function foo2( ->foo2 : ({name:nameC, skills:{primary:primaryB, secondary:secondaryB}}?: Robot) => void +>foo2 : ({name: nameC, skills: {primary: primaryB, secondary: secondaryB}}?: Robot) => void { name: nameC = "name", >name : any @@ -132,12 +132,12 @@ function foo3({ skills = { primary: "SomeSkill", secondary: "someSkill" } }: Ro foo1(robotA); >foo1(robotA) : void ->foo1 : ({skills:{primary:primaryA, secondary:secondaryA}}?: Robot) => void +>foo1 : ({skills: {primary: primaryA, secondary: secondaryA}}?: Robot) => void >robotA : Robot foo1({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } }); >foo1({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } }) : void ->foo1 : ({skills:{primary:primaryA, secondary:secondaryA}}?: Robot) => void +>foo1 : ({skills: {primary: primaryA, secondary: secondaryA}}?: Robot) => void >{ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string >"Edger" : string @@ -150,12 +150,12 @@ foo1({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" foo2(robotA); >foo2(robotA) : void ->foo2 : ({name:nameC, skills:{primary:primaryB, secondary:secondaryB}}?: Robot) => void +>foo2 : ({name: nameC, skills: {primary: primaryB, secondary: secondaryB}}?: Robot) => void >robotA : Robot foo2({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } }); >foo2({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } }) : void ->foo2 : ({name:nameC, skills:{primary:primaryB, secondary:secondaryB}}?: Robot) => void +>foo2 : ({name: nameC, skills: {primary: primaryB, secondary: secondaryB}}?: Robot) => void >{ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string >"Edger" : string diff --git a/tests/baselines/reference/sourceMapValidationDestructuringParameterObjectBindingPattern.types b/tests/baselines/reference/sourceMapValidationDestructuringParameterObjectBindingPattern.types index 9154ba582d8..6b8f26acf43 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringParameterObjectBindingPattern.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringParameterObjectBindingPattern.types @@ -29,7 +29,7 @@ var robotA: Robot = { name: "mower", skill: "mowing" }; >"mowing" : string function foo1({ name: nameA }: Robot) { ->foo1 : ({name:nameA}: Robot) => void +>foo1 : ({name: nameA}: Robot) => void >name : any >nameA : string >Robot : Robot @@ -42,7 +42,7 @@ function foo1({ name: nameA }: Robot) { >nameA : string } function foo2({ name: nameB, skill: skillB }: Robot) { ->foo2 : ({name:nameB, skill:skillB}: Robot) => void +>foo2 : ({name: nameB, skill: skillB}: Robot) => void >name : any >nameB : string >skill : any @@ -71,12 +71,12 @@ function foo3({ name }: Robot) { foo1(robotA); >foo1(robotA) : void ->foo1 : ({name:nameA}: Robot) => void +>foo1 : ({name: nameA}: Robot) => void >robotA : Robot foo1({ name: "Edger", skill: "cutting edges" }); >foo1({ name: "Edger", skill: "cutting edges" }) : void ->foo1 : ({name:nameA}: Robot) => void +>foo1 : ({name: nameA}: Robot) => void >{ name: "Edger", skill: "cutting edges" } : { name: string; skill: string; } >name : string >"Edger" : string @@ -85,12 +85,12 @@ foo1({ name: "Edger", skill: "cutting edges" }); foo2(robotA); >foo2(robotA) : void ->foo2 : ({name:nameB, skill:skillB}: Robot) => void +>foo2 : ({name: nameB, skill: skillB}: Robot) => void >robotA : Robot foo2({ name: "Edger", skill: "cutting edges" }); >foo2({ name: "Edger", skill: "cutting edges" }) : void ->foo2 : ({name:nameB, skill:skillB}: Robot) => void +>foo2 : ({name: nameB, skill: skillB}: Robot) => void >{ name: "Edger", skill: "cutting edges" } : { name: string; skill: string; } >name : string >"Edger" : string diff --git a/tests/baselines/reference/sourceMapValidationDestructuringParameterObjectBindingPatternDefaultValues.types b/tests/baselines/reference/sourceMapValidationDestructuringParameterObjectBindingPatternDefaultValues.types index ed7090d4fc8..253c5feae8f 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringParameterObjectBindingPatternDefaultValues.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringParameterObjectBindingPatternDefaultValues.types @@ -29,7 +29,7 @@ var robotA: Robot = { name: "mower", skill: "mowing" }; >"mowing" : string function foo1({ name: nameA = "" }: Robot = { }) { ->foo1 : ({name:nameA}?: Robot) => void +>foo1 : ({name: nameA}?: Robot) => void >name : any >nameA : string >"" : string @@ -44,7 +44,7 @@ function foo1({ name: nameA = "" }: Robot = { }) { >nameA : string } function foo2({ name: nameB = "", skill: skillB = "noSkill" }: Robot = {}) { ->foo2 : ({name:nameB, skill:skillB}?: Robot) => void +>foo2 : ({name: nameB, skill: skillB}?: Robot) => void >name : any >nameB : string >"" : string @@ -78,12 +78,12 @@ function foo3({ name = "" }: Robot = {}) { foo1(robotA); >foo1(robotA) : void ->foo1 : ({name:nameA}?: Robot) => void +>foo1 : ({name: nameA}?: Robot) => void >robotA : Robot foo1({ name: "Edger", skill: "cutting edges" }); >foo1({ name: "Edger", skill: "cutting edges" }) : void ->foo1 : ({name:nameA}?: Robot) => void +>foo1 : ({name: nameA}?: Robot) => void >{ name: "Edger", skill: "cutting edges" } : { name: string; skill: string; } >name : string >"Edger" : string @@ -92,12 +92,12 @@ foo1({ name: "Edger", skill: "cutting edges" }); foo2(robotA); >foo2(robotA) : void ->foo2 : ({name:nameB, skill:skillB}?: Robot) => void +>foo2 : ({name: nameB, skill: skillB}?: Robot) => void >robotA : Robot foo2({ name: "Edger", skill: "cutting edges" }); >foo2({ name: "Edger", skill: "cutting edges" }) : void ->foo2 : ({name:nameB, skill:skillB}?: Robot) => void +>foo2 : ({name: nameB, skill: skillB}?: Robot) => void >{ name: "Edger", skill: "cutting edges" } : { name: string; skill: string; } >name : string >"Edger" : string diff --git a/tests/cases/compiler/declarationEmit_bindingPatters.ts b/tests/cases/compiler/declarationEmit_bindingPatterns.ts similarity index 100% rename from tests/cases/compiler/declarationEmit_bindingPatters.ts rename to tests/cases/compiler/declarationEmit_bindingPatterns.ts From 87a00c30f6701aef173dfd602dcc28f2e73cde33 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 25 Feb 2016 13:18:29 -0800 Subject: [PATCH 6/6] Fix linter comments --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7e692dc78b8..1da7dbe9e82 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2221,7 +2221,7 @@ namespace ts { } if (isBindingPattern(bindingElement.name)) { buildBindingPatternDisplay(bindingElement.name, writer, enclosingDeclaration, flags, symbolStack); - } + } else { if (bindingElement.dotDotDotToken) { writePunctuation(writer, SyntaxKind.DotDotDotToken);