Merge branch 'master' of https://github.com/Microsoft/TypeScript into generators

This commit is contained in:
Jason Freeman 2015-05-11 13:34:31 -07:00
commit 670ad05eec
20 changed files with 439 additions and 866 deletions

View File

@ -440,6 +440,18 @@ module ts {
else if (isBlockOrCatchScoped(<Declaration>node)) {
bindBlockScopedVariableDeclaration(<Declaration>node);
}
else if (isParameterDeclaration(<VariableLikeDeclaration>node)) {
// It is safe to walk up parent chain to find whether the node is a destructing parameter declaration
// because its parent chain has already been set up, since parents are set before descending into children.
//
// If node is a binding element in parameter declaration, we need to use ParameterExcludes.
// Using ParameterExcludes flag allows the compiler to report an error on duplicate identifiers in Parameter Declaration
// For example:
// function foo([a,a]) {} // Duplicate Identifier error
// function bar(a,a) {} // Duplicate Identifier error, parameter declaration in this case is handled in bindParameter
// // which correctly set excluded symbols
bindDeclaration(<Declaration>node, SymbolFlags.FunctionScopedVariable, SymbolFlags.ParameterExcludes, /*isBlockScopeContainer*/ false);
}
else {
bindDeclaration(<Declaration>node, SymbolFlags.FunctionScopedVariable, SymbolFlags.FunctionScopedVariableExcludes, /*isBlockScopeContainer*/ false);
}

View File

@ -2055,13 +2055,6 @@ module ts {
return resolutionResults.pop();
}
function getRootDeclaration(node: Node): Node {
while (node.kind === SyntaxKind.BindingElement) {
node = node.parent.parent;
}
return node;
}
function getDeclarationContainer(node: Node): Node {
node = getRootDeclaration(node);
@ -9348,13 +9341,6 @@ module ts {
}
}
function isParameterDeclaration(node: VariableLikeDeclaration) {
while (node.kind === SyntaxKind.BindingElement) {
node = <VariableLikeDeclaration>node.parent.parent;
}
return node.kind === SyntaxKind.Parameter;
}
// Check that a parameter initializer contains no references to parameters declared to the right of itself
function checkParameterInitializer(node: VariableLikeDeclaration): void {
if (getRootDeclaration(node).kind !== SyntaxKind.Parameter) {

View File

@ -1280,6 +1280,18 @@ module ts {
}
return false;
}
export function isParameterDeclaration(node: VariableLikeDeclaration) {
let root = getRootDeclaration(node);
return root.kind === SyntaxKind.Parameter;
}
export function getRootDeclaration(node: Node): Node {
while (node.kind === SyntaxKind.BindingElement) {
node = node.parent.parent;
}
return node;
}
export function nodeStartsNewLexicalEnvironment(n: Node): boolean {
return isFunctionLike(n) || n.kind === SyntaxKind.ModuleDeclaration || n.kind === SyntaxKind.SourceFile;

View File

@ -0,0 +1,25 @@
tests/cases/compiler/declarationEmitDestructuring2.ts(3,13): error TS2300: Duplicate identifier 'a'.
tests/cases/compiler/declarationEmitDestructuring2.ts(3,17): error TS2300: Duplicate identifier 'b'.
tests/cases/compiler/declarationEmitDestructuring2.ts(3,23): error TS2300: Duplicate identifier 'c'.
tests/cases/compiler/declarationEmitDestructuring2.ts(3,41): error TS2300: Duplicate identifier 'a'.
tests/cases/compiler/declarationEmitDestructuring2.ts(3,44): error TS2300: Duplicate identifier 'b'.
tests/cases/compiler/declarationEmitDestructuring2.ts(3,47): error TS2300: Duplicate identifier 'c'.
==== tests/cases/compiler/declarationEmitDestructuring2.ts (6 errors) ====
function f({x = 10, y: [a, b, c, d] = [1, 2, 3, 4]} = { x: 10, y: [2, 4, 6, 8] }) { }
function g([a, b, c, d] = [1, 2, 3, 4]) { }
function h([a, [b], [[c]], {x = 10, y: [a, b, c], z: {a1, b1}}]){ }
~
!!! error TS2300: Duplicate identifier 'a'.
~
!!! error TS2300: Duplicate identifier 'b'.
~
!!! error TS2300: Duplicate identifier 'c'.
~
!!! error TS2300: Duplicate identifier 'a'.
~
!!! error TS2300: Duplicate identifier 'b'.
~
!!! error TS2300: Duplicate identifier 'c'.
function h1([a, [b], [[c]], {x = 10, y = [1, 2, 3], z: {a1, b1}}]){ }

View File

@ -1,40 +0,0 @@
=== tests/cases/compiler/declarationEmitDestructuring2.ts ===
function f({x = 10, y: [a, b, c, d] = [1, 2, 3, 4]} = { x: 10, y: [2, 4, 6, 8] }) { }
>f : Symbol(f, Decl(declarationEmitDestructuring2.ts, 0, 0))
>x : Symbol(x, Decl(declarationEmitDestructuring2.ts, 0, 12))
>a : Symbol(a, Decl(declarationEmitDestructuring2.ts, 0, 24))
>b : Symbol(b, Decl(declarationEmitDestructuring2.ts, 0, 26))
>c : Symbol(c, Decl(declarationEmitDestructuring2.ts, 0, 29))
>d : Symbol(d, Decl(declarationEmitDestructuring2.ts, 0, 32))
>x : Symbol(x, Decl(declarationEmitDestructuring2.ts, 0, 55))
>y : Symbol(y, Decl(declarationEmitDestructuring2.ts, 0, 62))
function g([a, b, c, d] = [1, 2, 3, 4]) { }
>g : Symbol(g, Decl(declarationEmitDestructuring2.ts, 0, 85))
>a : Symbol(a, Decl(declarationEmitDestructuring2.ts, 1, 12))
>b : Symbol(b, Decl(declarationEmitDestructuring2.ts, 1, 14))
>c : Symbol(c, Decl(declarationEmitDestructuring2.ts, 1, 17))
>d : Symbol(d, Decl(declarationEmitDestructuring2.ts, 1, 20))
function h([a, [b], [[c]], {x = 10, y: [a, b, c], z: {a1, b1}}]){ }
>h : Symbol(h, Decl(declarationEmitDestructuring2.ts, 1, 43))
>a : Symbol(a, Decl(declarationEmitDestructuring2.ts, 2, 12), Decl(declarationEmitDestructuring2.ts, 2, 40))
>b : Symbol(b, Decl(declarationEmitDestructuring2.ts, 2, 16), Decl(declarationEmitDestructuring2.ts, 2, 42))
>c : Symbol(c, Decl(declarationEmitDestructuring2.ts, 2, 22), Decl(declarationEmitDestructuring2.ts, 2, 45))
>x : Symbol(x, Decl(declarationEmitDestructuring2.ts, 2, 28))
>a : Symbol(a, Decl(declarationEmitDestructuring2.ts, 2, 12), Decl(declarationEmitDestructuring2.ts, 2, 40))
>b : Symbol(b, Decl(declarationEmitDestructuring2.ts, 2, 16), Decl(declarationEmitDestructuring2.ts, 2, 42))
>c : Symbol(c, Decl(declarationEmitDestructuring2.ts, 2, 22), Decl(declarationEmitDestructuring2.ts, 2, 45))
>a1 : Symbol(a1, Decl(declarationEmitDestructuring2.ts, 2, 54))
>b1 : Symbol(b1, Decl(declarationEmitDestructuring2.ts, 2, 57))
function h1([a, [b], [[c]], {x = 10, y = [1, 2, 3], z: {a1, b1}}]){ }
>h1 : Symbol(h1, Decl(declarationEmitDestructuring2.ts, 2, 67))
>a : Symbol(a, Decl(declarationEmitDestructuring2.ts, 3, 13))
>b : Symbol(b, Decl(declarationEmitDestructuring2.ts, 3, 17))
>c : Symbol(c, Decl(declarationEmitDestructuring2.ts, 3, 23))
>x : Symbol(x, Decl(declarationEmitDestructuring2.ts, 3, 29))
>y : Symbol(y, Decl(declarationEmitDestructuring2.ts, 3, 36))
>a1 : Symbol(a1, Decl(declarationEmitDestructuring2.ts, 3, 56))
>b1 : Symbol(b1, Decl(declarationEmitDestructuring2.ts, 3, 59))

View File

@ -1,68 +0,0 @@
=== tests/cases/compiler/declarationEmitDestructuring2.ts ===
function f({x = 10, y: [a, b, c, d] = [1, 2, 3, 4]} = { x: 10, y: [2, 4, 6, 8] }) { }
>f : ({x = 10, y: [a, b, c, d] = [1, 2, 3, 4]}?: { x: number; y: [number, number, number, number]; }) => void
>x : number
>10 : number
>y : any
>a : number
>b : number
>c : number
>d : number
>[1, 2, 3, 4] : [number, number, number, number]
>1 : number
>2 : number
>3 : number
>4 : number
>{ x: 10, y: [2, 4, 6, 8] } : { x: number; y: [number, number, number, number]; }
>x : number
>10 : number
>y : [number, number, number, number]
>[2, 4, 6, 8] : [number, number, number, number]
>2 : number
>4 : number
>6 : number
>8 : number
function g([a, b, c, d] = [1, 2, 3, 4]) { }
>g : ([a, b, c, d]?: [number, number, number, number]) => void
>a : number
>b : number
>c : number
>d : number
>[1, 2, 3, 4] : [number, number, number, number]
>1 : number
>2 : number
>3 : number
>4 : number
function h([a, [b], [[c]], {x = 10, y: [a, b, c], z: {a1, b1}}]){ }
>h : ([a, [b], [[c]], {x = 10, y: [a, b, c], z: {a1, b1}}]: [any, [any], [[any]], { x?: number; y: [any, any, any]; z: { a1: any; b1: any; }; }]) => void
>a : any
>b : any
>c : any
>x : number
>10 : number
>y : any
>a : any
>b : any
>c : any
>z : any
>a1 : any
>b1 : any
function h1([a, [b], [[c]], {x = 10, y = [1, 2, 3], z: {a1, b1}}]){ }
>h1 : ([a, [b], [[c]], {x = 10, y = [1, 2, 3], z: {a1, b1}}]: [any, [any], [[any]], { x?: number; y?: number[]; z: { a1: any; b1: any; }; }]) => void
>a : any
>b : any
>c : any
>x : number
>10 : number
>y : number[]
>[1, 2, 3] : number[]
>1 : number
>2 : number
>3 : number
>z : any
>a1 : any
>b1 : any

View File

@ -0,0 +1,111 @@
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES6.ts(96,18): error TS2300: Duplicate identifier 'number'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES6.ts(96,26): error TS2300: Duplicate identifier 'number'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES6.ts(96,34): error TS2300: Duplicate identifier 'number'.
==== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES6.ts (3 errors) ====
// Conformance for emitting ES6
// A parameter declaration may specify either an identifier or a binding pattern.
// The identifiers specified in parameter declarations and binding patterns
// in a parameter list must be unique within that parameter list.
// If the declaration includes a type annotation, the parameter is of that type
function a1([a, b, [[c]]]: [number, number, string[][]]) { }
function a2(o: { x: number, a: number }) { }
function a3({j, k, l: {m, n}, q: [a, b, c]}: { j: number, k: string, l: { m: boolean, n: number }, q: (number|string)[] }) { };
function a4({x, a}: { x: number, a: number }) { }
a1([1, 2, [["world"]]]);
a1([1, 2, [["world"]], 3]);
// If the declaration includes an initializer expression (which is permitted only
// when the parameter list occurs in conjunction with a function body),
// the parameter type is the widened form (section 3.11) of the type of the initializer expression.
function b1(z = [undefined, null]) { };
function b2(z = null, o = { x: 0, y: undefined }) { }
function b3({z: {x, y: {j}}} = { z: { x: "hi", y: { j: 1 } } }) { }
interface F1 {
b5(z, y, [, a, b], {p, m: { q, r}});
}
function b6([a, z, y] = [undefined, null, undefined]) { }
function b7([[a], b, [[c, d]]] = [[undefined], undefined, [[undefined, undefined]]]) { }
b1([1, 2, 3]); // z is widen to the type any[]
b2("string", { x: 200, y: "string" });
b2("string", { x: 200, y: true });
// If the declaration specifies a binding pattern, the parameter type is the implied type of that binding pattern (section 5.1.3)
enum Foo { a }
function c0({z: {x, y: {j}}}) { }
function c1({z} = { z: 10 }) { }
function c2({z = 10}) { }
function c3({b}: { b: number|string} = { b: "hello" }) { }
function c5([a, b, [[c]]]) { }
function c6([a, b, [[c=1]]]) { }
c0({z : { x: 1, y: { j: "world" } }}); // Implied type is { z: {x: any, y: {j: any}} }
c0({z : { x: "string", y: { j: true } }}); // Implied type is { z: {x: any, y: {j: any}} }
c1(); // Implied type is {z:number}?
c1({ z: 1 }) // Implied type is {z:number}?
c2({}); // Implied type is {z?: number}
c2({z:1}); // Implied type is {z?: number}
c3({ b: 1 }); // Implied type is { b: number|string }.
c5([1, 2, [["string"]]]); // Implied type is is [any, any, [[any]]]
c5([1, 2, [["string"]], false, true]); // Implied type is is [any, any, [[any]]]
// A parameter can be marked optional by following its name or binding pattern with a question mark (?)
// or by including an initializer.
interface F2 {
d3([a, b, c]?);
d4({x, y, z}?);
e0([a, b, c]);
}
class C2 implements F2 {
constructor() { }
d3() { }
d4() { }
e0([a, b, c]) { }
}
class C3 implements F2 {
d3([a, b, c]) { }
d4({x, y, z}) { }
e0([a, b, c]) { }
}
function d5({x, y} = { x: 1, y: 2 }) { }
d5(); // Parameter is optional as its declaration included an initializer
// Destructuring parameter declarations do not permit type annotations on the individual binding patterns,
// as such annotations would conflict with the already established meaning of colons in object literals.
// Type annotations must instead be written on the top- level parameter declaration
function e1({x: number}) { } // x has type any NOT number
function e2({x}: { x: number }) { } // x is type number
function e3({x}: { x?: number }) { } // x is an optional with type number
function e4({x: [number,string,any] }) { } // x has type [any, any, any]
function e5({x: [a, b, c]}: { x: [number, number, number] }) { } // x has type [any, any, any]
function e6({x: [number, number, number]}) { } // error, duplicate identifier;
~~~~~~
!!! error TS2300: Duplicate identifier 'number'.
~~~~~~
!!! error TS2300: Duplicate identifier 'number'.
~~~~~~
!!! error TS2300: Duplicate identifier 'number'.

View File

@ -94,7 +94,7 @@ function e3({x}: { x?: number }) { } // x is an optional with type number
function e4({x: [number,string,any] }) { } // x has type [any, any, any]
function e5({x: [a, b, c]}: { x: [number, number, number] }) { } // x has type [any, any, any]
function e6({x: [number, number, number]}) { } // should be an error, duplicate identifier;
function e6({x: [number, number, number]}) { } // error, duplicate identifier;
@ -166,4 +166,4 @@ function e2({ x }) { } // x is type number
function e3({ x }) { } // x is an optional with type number
function e4({ x: [number, string, any] }) { } // x has type [any, any, any]
function e5({ x: [a, b, c] }) { } // x has type [any, any, any]
function e6({ x: [number, number, number] }) { } // should be an error, duplicate identifier;
function e6({ x: [number, number, number] }) { } // error, duplicate identifier;

View File

@ -1,314 +0,0 @@
=== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES6.ts ===
// Conformance for emitting ES6
// A parameter declaration may specify either an identifier or a binding pattern.
// The identifiers specified in parameter declarations and binding patterns
// in a parameter list must be unique within that parameter list.
// If the declaration includes a type annotation, the parameter is of that type
function a1([a, b, [[c]]]: [number, number, string[][]]) { }
>a1 : Symbol(a1, Decl(destructuringParameterDeclaration1ES6.ts, 0, 0))
>a : Symbol(a, Decl(destructuringParameterDeclaration1ES6.ts, 7, 13))
>b : Symbol(b, Decl(destructuringParameterDeclaration1ES6.ts, 7, 15))
>c : Symbol(c, Decl(destructuringParameterDeclaration1ES6.ts, 7, 21))
function a2(o: { x: number, a: number }) { }
>a2 : Symbol(a2, Decl(destructuringParameterDeclaration1ES6.ts, 7, 60))
>o : Symbol(o, Decl(destructuringParameterDeclaration1ES6.ts, 8, 12))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES6.ts, 8, 16))
>a : Symbol(a, Decl(destructuringParameterDeclaration1ES6.ts, 8, 27))
function a3({j, k, l: {m, n}, q: [a, b, c]}: { j: number, k: string, l: { m: boolean, n: number }, q: (number|string)[] }) { };
>a3 : Symbol(a3, Decl(destructuringParameterDeclaration1ES6.ts, 8, 44))
>j : Symbol(j, Decl(destructuringParameterDeclaration1ES6.ts, 9, 13))
>k : Symbol(k, Decl(destructuringParameterDeclaration1ES6.ts, 9, 15))
>m : Symbol(m, Decl(destructuringParameterDeclaration1ES6.ts, 9, 23))
>n : Symbol(n, Decl(destructuringParameterDeclaration1ES6.ts, 9, 25))
>a : Symbol(a, Decl(destructuringParameterDeclaration1ES6.ts, 9, 34))
>b : Symbol(b, Decl(destructuringParameterDeclaration1ES6.ts, 9, 36))
>c : Symbol(c, Decl(destructuringParameterDeclaration1ES6.ts, 9, 39))
>j : Symbol(j, Decl(destructuringParameterDeclaration1ES6.ts, 9, 46))
>k : Symbol(k, Decl(destructuringParameterDeclaration1ES6.ts, 9, 57))
>l : Symbol(l, Decl(destructuringParameterDeclaration1ES6.ts, 9, 68))
>m : Symbol(m, Decl(destructuringParameterDeclaration1ES6.ts, 9, 73))
>n : Symbol(n, Decl(destructuringParameterDeclaration1ES6.ts, 9, 85))
>q : Symbol(q, Decl(destructuringParameterDeclaration1ES6.ts, 9, 98))
function a4({x, a}: { x: number, a: number }) { }
>a4 : Symbol(a4, Decl(destructuringParameterDeclaration1ES6.ts, 9, 127))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES6.ts, 10, 13))
>a : Symbol(a, Decl(destructuringParameterDeclaration1ES6.ts, 10, 15))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES6.ts, 10, 21))
>a : Symbol(a, Decl(destructuringParameterDeclaration1ES6.ts, 10, 32))
a1([1, 2, [["world"]]]);
>a1 : Symbol(a1, Decl(destructuringParameterDeclaration1ES6.ts, 0, 0))
a1([1, 2, [["world"]], 3]);
>a1 : Symbol(a1, Decl(destructuringParameterDeclaration1ES6.ts, 0, 0))
// If the declaration includes an initializer expression (which is permitted only
// when the parameter list occurs in conjunction with a function body),
// the parameter type is the widened form (section 3.11) of the type of the initializer expression.
function b1(z = [undefined, null]) { };
>b1 : Symbol(b1, Decl(destructuringParameterDeclaration1ES6.ts, 13, 27))
>z : Symbol(z, Decl(destructuringParameterDeclaration1ES6.ts, 20, 12))
>undefined : Symbol(undefined)
function b2(z = null, o = { x: 0, y: undefined }) { }
>b2 : Symbol(b2, Decl(destructuringParameterDeclaration1ES6.ts, 20, 39))
>z : Symbol(z, Decl(destructuringParameterDeclaration1ES6.ts, 21, 12))
>o : Symbol(o, Decl(destructuringParameterDeclaration1ES6.ts, 21, 21))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES6.ts, 21, 27))
>y : Symbol(y, Decl(destructuringParameterDeclaration1ES6.ts, 21, 33))
>undefined : Symbol(undefined)
function b3({z: {x, y: {j}}} = { z: { x: "hi", y: { j: 1 } } }) { }
>b3 : Symbol(b3, Decl(destructuringParameterDeclaration1ES6.ts, 21, 53))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES6.ts, 22, 17))
>j : Symbol(j, Decl(destructuringParameterDeclaration1ES6.ts, 22, 24))
>z : Symbol(z, Decl(destructuringParameterDeclaration1ES6.ts, 22, 32))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES6.ts, 22, 37))
>y : Symbol(y, Decl(destructuringParameterDeclaration1ES6.ts, 22, 46))
>j : Symbol(j, Decl(destructuringParameterDeclaration1ES6.ts, 22, 51))
interface F1 {
>F1 : Symbol(F1, Decl(destructuringParameterDeclaration1ES6.ts, 22, 67))
b5(z, y, [, a, b], {p, m: { q, r}});
>b5 : Symbol(b5, Decl(destructuringParameterDeclaration1ES6.ts, 24, 14))
>z : Symbol(z, Decl(destructuringParameterDeclaration1ES6.ts, 25, 7))
>y : Symbol(y, Decl(destructuringParameterDeclaration1ES6.ts, 25, 9))
>a : Symbol(a, Decl(destructuringParameterDeclaration1ES6.ts, 25, 15))
>b : Symbol(b, Decl(destructuringParameterDeclaration1ES6.ts, 25, 18))
>p : Symbol(p, Decl(destructuringParameterDeclaration1ES6.ts, 25, 24))
>q : Symbol(q, Decl(destructuringParameterDeclaration1ES6.ts, 25, 31))
>r : Symbol(r, Decl(destructuringParameterDeclaration1ES6.ts, 25, 34))
}
function b6([a, z, y] = [undefined, null, undefined]) { }
>b6 : Symbol(b6, Decl(destructuringParameterDeclaration1ES6.ts, 26, 1))
>a : Symbol(a, Decl(destructuringParameterDeclaration1ES6.ts, 28, 13))
>z : Symbol(z, Decl(destructuringParameterDeclaration1ES6.ts, 28, 15))
>y : Symbol(y, Decl(destructuringParameterDeclaration1ES6.ts, 28, 18))
>undefined : Symbol(undefined)
>undefined : Symbol(undefined)
function b7([[a], b, [[c, d]]] = [[undefined], undefined, [[undefined, undefined]]]) { }
>b7 : Symbol(b7, Decl(destructuringParameterDeclaration1ES6.ts, 28, 57))
>a : Symbol(a, Decl(destructuringParameterDeclaration1ES6.ts, 29, 14))
>b : Symbol(b, Decl(destructuringParameterDeclaration1ES6.ts, 29, 17))
>c : Symbol(c, Decl(destructuringParameterDeclaration1ES6.ts, 29, 23))
>d : Symbol(d, Decl(destructuringParameterDeclaration1ES6.ts, 29, 25))
>undefined : Symbol(undefined)
>undefined : Symbol(undefined)
>undefined : Symbol(undefined)
>undefined : Symbol(undefined)
b1([1, 2, 3]); // z is widen to the type any[]
>b1 : Symbol(b1, Decl(destructuringParameterDeclaration1ES6.ts, 13, 27))
b2("string", { x: 200, y: "string" });
>b2 : Symbol(b2, Decl(destructuringParameterDeclaration1ES6.ts, 20, 39))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES6.ts, 32, 14))
>y : Symbol(y, Decl(destructuringParameterDeclaration1ES6.ts, 32, 22))
b2("string", { x: 200, y: true });
>b2 : Symbol(b2, Decl(destructuringParameterDeclaration1ES6.ts, 20, 39))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES6.ts, 33, 14))
>y : Symbol(y, Decl(destructuringParameterDeclaration1ES6.ts, 33, 22))
// If the declaration specifies a binding pattern, the parameter type is the implied type of that binding pattern (section 5.1.3)
enum Foo { a }
>Foo : Symbol(Foo, Decl(destructuringParameterDeclaration1ES6.ts, 33, 34))
>a : Symbol(Foo.a, Decl(destructuringParameterDeclaration1ES6.ts, 37, 10))
function c0({z: {x, y: {j}}}) { }
>c0 : Symbol(c0, Decl(destructuringParameterDeclaration1ES6.ts, 37, 14))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES6.ts, 38, 17))
>j : Symbol(j, Decl(destructuringParameterDeclaration1ES6.ts, 38, 24))
function c1({z} = { z: 10 }) { }
>c1 : Symbol(c1, Decl(destructuringParameterDeclaration1ES6.ts, 38, 33))
>z : Symbol(z, Decl(destructuringParameterDeclaration1ES6.ts, 39, 13))
>z : Symbol(z, Decl(destructuringParameterDeclaration1ES6.ts, 39, 19))
function c2({z = 10}) { }
>c2 : Symbol(c2, Decl(destructuringParameterDeclaration1ES6.ts, 39, 32))
>z : Symbol(z, Decl(destructuringParameterDeclaration1ES6.ts, 40, 13))
function c3({b}: { b: number|string} = { b: "hello" }) { }
>c3 : Symbol(c3, Decl(destructuringParameterDeclaration1ES6.ts, 40, 25))
>b : Symbol(b, Decl(destructuringParameterDeclaration1ES6.ts, 41, 13))
>b : Symbol(b, Decl(destructuringParameterDeclaration1ES6.ts, 41, 18))
>b : Symbol(b, Decl(destructuringParameterDeclaration1ES6.ts, 41, 40))
function c5([a, b, [[c]]]) { }
>c5 : Symbol(c5, Decl(destructuringParameterDeclaration1ES6.ts, 41, 58))
>a : Symbol(a, Decl(destructuringParameterDeclaration1ES6.ts, 42, 13))
>b : Symbol(b, Decl(destructuringParameterDeclaration1ES6.ts, 42, 15))
>c : Symbol(c, Decl(destructuringParameterDeclaration1ES6.ts, 42, 21))
function c6([a, b, [[c=1]]]) { }
>c6 : Symbol(c6, Decl(destructuringParameterDeclaration1ES6.ts, 42, 30))
>a : Symbol(a, Decl(destructuringParameterDeclaration1ES6.ts, 43, 13))
>b : Symbol(b, Decl(destructuringParameterDeclaration1ES6.ts, 43, 15))
>c : Symbol(c, Decl(destructuringParameterDeclaration1ES6.ts, 43, 21))
c0({z : { x: 1, y: { j: "world" } }}); // Implied type is { z: {x: any, y: {j: any}} }
>c0 : Symbol(c0, Decl(destructuringParameterDeclaration1ES6.ts, 37, 14))
>z : Symbol(z, Decl(destructuringParameterDeclaration1ES6.ts, 45, 4))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES6.ts, 45, 9))
>y : Symbol(y, Decl(destructuringParameterDeclaration1ES6.ts, 45, 15))
>j : Symbol(j, Decl(destructuringParameterDeclaration1ES6.ts, 45, 20))
c0({z : { x: "string", y: { j: true } }}); // Implied type is { z: {x: any, y: {j: any}} }
>c0 : Symbol(c0, Decl(destructuringParameterDeclaration1ES6.ts, 37, 14))
>z : Symbol(z, Decl(destructuringParameterDeclaration1ES6.ts, 46, 4))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES6.ts, 46, 9))
>y : Symbol(y, Decl(destructuringParameterDeclaration1ES6.ts, 46, 22))
>j : Symbol(j, Decl(destructuringParameterDeclaration1ES6.ts, 46, 27))
c1(); // Implied type is {z:number}?
>c1 : Symbol(c1, Decl(destructuringParameterDeclaration1ES6.ts, 38, 33))
c1({ z: 1 }) // Implied type is {z:number}?
>c1 : Symbol(c1, Decl(destructuringParameterDeclaration1ES6.ts, 38, 33))
>z : Symbol(z, Decl(destructuringParameterDeclaration1ES6.ts, 49, 4))
c2({}); // Implied type is {z?: number}
>c2 : Symbol(c2, Decl(destructuringParameterDeclaration1ES6.ts, 39, 32))
c2({z:1}); // Implied type is {z?: number}
>c2 : Symbol(c2, Decl(destructuringParameterDeclaration1ES6.ts, 39, 32))
>z : Symbol(z, Decl(destructuringParameterDeclaration1ES6.ts, 52, 4))
c3({ b: 1 }); // Implied type is { b: number|string }.
>c3 : Symbol(c3, Decl(destructuringParameterDeclaration1ES6.ts, 40, 25))
>b : Symbol(b, Decl(destructuringParameterDeclaration1ES6.ts, 54, 4))
c5([1, 2, [["string"]]]); // Implied type is is [any, any, [[any]]]
>c5 : Symbol(c5, Decl(destructuringParameterDeclaration1ES6.ts, 41, 58))
c5([1, 2, [["string"]], false, true]); // Implied type is is [any, any, [[any]]]
>c5 : Symbol(c5, Decl(destructuringParameterDeclaration1ES6.ts, 41, 58))
// A parameter can be marked optional by following its name or binding pattern with a question mark (?)
// or by including an initializer.
interface F2 {
>F2 : Symbol(F2, Decl(destructuringParameterDeclaration1ES6.ts, 57, 38))
d3([a, b, c]?);
>d3 : Symbol(d3, Decl(destructuringParameterDeclaration1ES6.ts, 63, 14))
>a : Symbol(a, Decl(destructuringParameterDeclaration1ES6.ts, 64, 8))
>b : Symbol(b, Decl(destructuringParameterDeclaration1ES6.ts, 64, 10))
>c : Symbol(c, Decl(destructuringParameterDeclaration1ES6.ts, 64, 13))
d4({x, y, z}?);
>d4 : Symbol(d4, Decl(destructuringParameterDeclaration1ES6.ts, 64, 19))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES6.ts, 65, 8))
>y : Symbol(y, Decl(destructuringParameterDeclaration1ES6.ts, 65, 10))
>z : Symbol(z, Decl(destructuringParameterDeclaration1ES6.ts, 65, 13))
e0([a, b, c]);
>e0 : Symbol(e0, Decl(destructuringParameterDeclaration1ES6.ts, 65, 19))
>a : Symbol(a, Decl(destructuringParameterDeclaration1ES6.ts, 66, 8))
>b : Symbol(b, Decl(destructuringParameterDeclaration1ES6.ts, 66, 10))
>c : Symbol(c, Decl(destructuringParameterDeclaration1ES6.ts, 66, 13))
}
class C2 implements F2 {
>C2 : Symbol(C2, Decl(destructuringParameterDeclaration1ES6.ts, 67, 1))
>F2 : Symbol(F2, Decl(destructuringParameterDeclaration1ES6.ts, 57, 38))
constructor() { }
d3() { }
>d3 : Symbol(d3, Decl(destructuringParameterDeclaration1ES6.ts, 70, 21))
d4() { }
>d4 : Symbol(d4, Decl(destructuringParameterDeclaration1ES6.ts, 71, 12))
e0([a, b, c]) { }
>e0 : Symbol(e0, Decl(destructuringParameterDeclaration1ES6.ts, 72, 12))
>a : Symbol(a, Decl(destructuringParameterDeclaration1ES6.ts, 73, 8))
>b : Symbol(b, Decl(destructuringParameterDeclaration1ES6.ts, 73, 10))
>c : Symbol(c, Decl(destructuringParameterDeclaration1ES6.ts, 73, 13))
}
class C3 implements F2 {
>C3 : Symbol(C3, Decl(destructuringParameterDeclaration1ES6.ts, 74, 1))
>F2 : Symbol(F2, Decl(destructuringParameterDeclaration1ES6.ts, 57, 38))
d3([a, b, c]) { }
>d3 : Symbol(d3, Decl(destructuringParameterDeclaration1ES6.ts, 76, 24))
>a : Symbol(a, Decl(destructuringParameterDeclaration1ES6.ts, 77, 8))
>b : Symbol(b, Decl(destructuringParameterDeclaration1ES6.ts, 77, 10))
>c : Symbol(c, Decl(destructuringParameterDeclaration1ES6.ts, 77, 13))
d4({x, y, z}) { }
>d4 : Symbol(d4, Decl(destructuringParameterDeclaration1ES6.ts, 77, 21))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES6.ts, 78, 8))
>y : Symbol(y, Decl(destructuringParameterDeclaration1ES6.ts, 78, 10))
>z : Symbol(z, Decl(destructuringParameterDeclaration1ES6.ts, 78, 13))
e0([a, b, c]) { }
>e0 : Symbol(e0, Decl(destructuringParameterDeclaration1ES6.ts, 78, 21))
>a : Symbol(a, Decl(destructuringParameterDeclaration1ES6.ts, 79, 8))
>b : Symbol(b, Decl(destructuringParameterDeclaration1ES6.ts, 79, 10))
>c : Symbol(c, Decl(destructuringParameterDeclaration1ES6.ts, 79, 13))
}
function d5({x, y} = { x: 1, y: 2 }) { }
>d5 : Symbol(d5, Decl(destructuringParameterDeclaration1ES6.ts, 80, 1))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES6.ts, 82, 13))
>y : Symbol(y, Decl(destructuringParameterDeclaration1ES6.ts, 82, 15))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES6.ts, 82, 22))
>y : Symbol(y, Decl(destructuringParameterDeclaration1ES6.ts, 82, 28))
d5(); // Parameter is optional as its declaration included an initializer
>d5 : Symbol(d5, Decl(destructuringParameterDeclaration1ES6.ts, 80, 1))
// Destructuring parameter declarations do not permit type annotations on the individual binding patterns,
// as such annotations would conflict with the already established meaning of colons in object literals.
// Type annotations must instead be written on the top- level parameter declaration
function e1({x: number}) { } // x has type any NOT number
>e1 : Symbol(e1, Decl(destructuringParameterDeclaration1ES6.ts, 83, 5))
>number : Symbol(number, Decl(destructuringParameterDeclaration1ES6.ts, 89, 13))
function e2({x}: { x: number }) { } // x is type number
>e2 : Symbol(e2, Decl(destructuringParameterDeclaration1ES6.ts, 89, 28))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES6.ts, 90, 13))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES6.ts, 90, 18))
function e3({x}: { x?: number }) { } // x is an optional with type number
>e3 : Symbol(e3, Decl(destructuringParameterDeclaration1ES6.ts, 90, 35))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES6.ts, 91, 13))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES6.ts, 91, 18))
function e4({x: [number,string,any] }) { } // x has type [any, any, any]
>e4 : Symbol(e4, Decl(destructuringParameterDeclaration1ES6.ts, 91, 36))
>number : Symbol(number, Decl(destructuringParameterDeclaration1ES6.ts, 92, 17))
>string : Symbol(string, Decl(destructuringParameterDeclaration1ES6.ts, 92, 24))
>any : Symbol(any, Decl(destructuringParameterDeclaration1ES6.ts, 92, 31))
function e5({x: [a, b, c]}: { x: [number, number, number] }) { } // x has type [any, any, any]
>e5 : Symbol(e5, Decl(destructuringParameterDeclaration1ES6.ts, 92, 42))
>a : Symbol(a, Decl(destructuringParameterDeclaration1ES6.ts, 93, 17))
>b : Symbol(b, Decl(destructuringParameterDeclaration1ES6.ts, 93, 19))
>c : Symbol(c, Decl(destructuringParameterDeclaration1ES6.ts, 93, 22))
>x : Symbol(x, Decl(destructuringParameterDeclaration1ES6.ts, 93, 29))
function e6({x: [number, number, number]}) { } // should be an error, duplicate identifier;
>e6 : Symbol(e6, Decl(destructuringParameterDeclaration1ES6.ts, 93, 64))
>number : Symbol(number, Decl(destructuringParameterDeclaration1ES6.ts, 95, 17), Decl(destructuringParameterDeclaration1ES6.ts, 95, 24), Decl(destructuringParameterDeclaration1ES6.ts, 95, 32))
>number : Symbol(number, Decl(destructuringParameterDeclaration1ES6.ts, 95, 17), Decl(destructuringParameterDeclaration1ES6.ts, 95, 24), Decl(destructuringParameterDeclaration1ES6.ts, 95, 32))
>number : Symbol(number, Decl(destructuringParameterDeclaration1ES6.ts, 95, 17), Decl(destructuringParameterDeclaration1ES6.ts, 95, 24), Decl(destructuringParameterDeclaration1ES6.ts, 95, 32))

View File

@ -1,422 +0,0 @@
=== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES6.ts ===
// Conformance for emitting ES6
// A parameter declaration may specify either an identifier or a binding pattern.
// The identifiers specified in parameter declarations and binding patterns
// in a parameter list must be unique within that parameter list.
// If the declaration includes a type annotation, the parameter is of that type
function a1([a, b, [[c]]]: [number, number, string[][]]) { }
>a1 : ([a, b, [[c]]]: [number, number, string[][]]) => void
>a : number
>b : number
>c : string
function a2(o: { x: number, a: number }) { }
>a2 : (o: { x: number; a: number; }) => void
>o : { x: number; a: number; }
>x : number
>a : number
function a3({j, k, l: {m, n}, q: [a, b, c]}: { j: number, k: string, l: { m: boolean, n: number }, q: (number|string)[] }) { };
>a3 : ({j, k, l: {m, n}, q: [a, b, c]}: { j: number; k: string; l: { m: boolean; n: number; }; q: (string | number)[]; }) => void
>j : number
>k : string
>l : any
>m : boolean
>n : number
>q : any
>a : string | number
>b : string | number
>c : string | number
>j : number
>k : string
>l : { m: boolean; n: number; }
>m : boolean
>n : number
>q : (string | number)[]
function a4({x, a}: { x: number, a: number }) { }
>a4 : ({x, a}: { x: number; a: number; }) => void
>x : number
>a : number
>x : number
>a : number
a1([1, 2, [["world"]]]);
>a1([1, 2, [["world"]]]) : void
>a1 : ([a, b, [[c]]]: [number, number, string[][]]) => void
>[1, 2, [["world"]]] : [number, number, string[][]]
>1 : number
>2 : number
>[["world"]] : string[][]
>["world"] : string[]
>"world" : string
a1([1, 2, [["world"]], 3]);
>a1([1, 2, [["world"]], 3]) : void
>a1 : ([a, b, [[c]]]: [number, number, string[][]]) => void
>[1, 2, [["world"]], 3] : [number, number, string[][], number]
>1 : number
>2 : number
>[["world"]] : string[][]
>["world"] : string[]
>"world" : string
>3 : number
// If the declaration includes an initializer expression (which is permitted only
// when the parameter list occurs in conjunction with a function body),
// the parameter type is the widened form (section 3.11) of the type of the initializer expression.
function b1(z = [undefined, null]) { };
>b1 : (z?: any[]) => void
>z : any[]
>[undefined, null] : null[]
>undefined : undefined
>null : null
function b2(z = null, o = { x: 0, y: undefined }) { }
>b2 : (z?: any, o?: { x: number; y: any; }) => void
>z : any
>null : null
>o : { x: number; y: any; }
>{ x: 0, y: undefined } : { x: number; y: undefined; }
>x : number
>0 : number
>y : undefined
>undefined : undefined
function b3({z: {x, y: {j}}} = { z: { x: "hi", y: { j: 1 } } }) { }
>b3 : ({z: {x, y: {j}}}?: { z: { x: string; y: { j: number; }; }; }) => void
>z : any
>x : string
>y : any
>j : number
>{ z: { x: "hi", y: { j: 1 } } } : { z: { x: string; y: { j: number; }; }; }
>z : { x: string; y: { j: number; }; }
>{ x: "hi", y: { j: 1 } } : { x: string; y: { j: number; }; }
>x : string
>"hi" : string
>y : { j: number; }
>{ j: 1 } : { j: number; }
>j : number
>1 : number
interface F1 {
>F1 : F1
b5(z, y, [, a, b], {p, m: { q, r}});
>b5 : (z: any, y: any, [, a, b]: [any, any, any], {p, m: { q, r}}: { p: any; m: { q: any; r: any; }; }) => any
>z : any
>y : any
> : undefined
>a : any
>b : any
>p : any
>m : any
>q : any
>r : any
}
function b6([a, z, y] = [undefined, null, undefined]) { }
>b6 : ([a, z, y]?: [undefined, null, undefined]) => void
>a : any
>z : any
>y : any
>[undefined, null, undefined] : [undefined, null, undefined]
>undefined : undefined
>null : null
>undefined : undefined
function b7([[a], b, [[c, d]]] = [[undefined], undefined, [[undefined, undefined]]]) { }
>b7 : ([[a], b, [[c, d]]]?: [[undefined], undefined, [[undefined, undefined]]]) => void
>a : any
>b : any
>c : any
>d : any
>[[undefined], undefined, [[undefined, undefined]]] : [[undefined], undefined, [[undefined, undefined]]]
>[undefined] : [undefined]
>undefined : undefined
>undefined : undefined
>[[undefined, undefined]] : [[undefined, undefined]]
>[undefined, undefined] : [undefined, undefined]
>undefined : undefined
>undefined : undefined
b1([1, 2, 3]); // z is widen to the type any[]
>b1([1, 2, 3]) : void
>b1 : (z?: any[]) => void
>[1, 2, 3] : number[]
>1 : number
>2 : number
>3 : number
b2("string", { x: 200, y: "string" });
>b2("string", { x: 200, y: "string" }) : void
>b2 : (z?: any, o?: { x: number; y: any; }) => void
>"string" : string
>{ x: 200, y: "string" } : { x: number; y: string; }
>x : number
>200 : number
>y : string
>"string" : string
b2("string", { x: 200, y: true });
>b2("string", { x: 200, y: true }) : void
>b2 : (z?: any, o?: { x: number; y: any; }) => void
>"string" : string
>{ x: 200, y: true } : { x: number; y: boolean; }
>x : number
>200 : number
>y : boolean
>true : boolean
// If the declaration specifies a binding pattern, the parameter type is the implied type of that binding pattern (section 5.1.3)
enum Foo { a }
>Foo : Foo
>a : Foo
function c0({z: {x, y: {j}}}) { }
>c0 : ({z: {x, y: {j}}}: { z: { x: any; y: { j: any; }; }; }) => void
>z : any
>x : any
>y : any
>j : any
function c1({z} = { z: 10 }) { }
>c1 : ({z}?: { z: number; }) => void
>z : number
>{ z: 10 } : { z: number; }
>z : number
>10 : number
function c2({z = 10}) { }
>c2 : ({z = 10}: { z?: number; }) => void
>z : number
>10 : number
function c3({b}: { b: number|string} = { b: "hello" }) { }
>c3 : ({b}?: { b: string | number; }) => void
>b : string | number
>b : string | number
>{ b: "hello" } : { b: string; }
>b : string
>"hello" : string
function c5([a, b, [[c]]]) { }
>c5 : ([a, b, [[c]]]: [any, any, [[any]]]) => void
>a : any
>b : any
>c : any
function c6([a, b, [[c=1]]]) { }
>c6 : ([a, b, [[c=1]]]: [any, any, [[number]]]) => void
>a : any
>b : any
>c : number
>1 : number
c0({z : { x: 1, y: { j: "world" } }}); // Implied type is { z: {x: any, y: {j: any}} }
>c0({z : { x: 1, y: { j: "world" } }}) : void
>c0 : ({z: {x, y: {j}}}: { z: { x: any; y: { j: any; }; }; }) => void
>{z : { x: 1, y: { j: "world" } }} : { z: { x: number; y: { j: string; }; }; }
>z : { x: number; y: { j: string; }; }
>{ x: 1, y: { j: "world" } } : { x: number; y: { j: string; }; }
>x : number
>1 : number
>y : { j: string; }
>{ j: "world" } : { j: string; }
>j : string
>"world" : string
c0({z : { x: "string", y: { j: true } }}); // Implied type is { z: {x: any, y: {j: any}} }
>c0({z : { x: "string", y: { j: true } }}) : void
>c0 : ({z: {x, y: {j}}}: { z: { x: any; y: { j: any; }; }; }) => void
>{z : { x: "string", y: { j: true } }} : { z: { x: string; y: { j: boolean; }; }; }
>z : { x: string; y: { j: boolean; }; }
>{ x: "string", y: { j: true } } : { x: string; y: { j: boolean; }; }
>x : string
>"string" : string
>y : { j: boolean; }
>{ j: true } : { j: boolean; }
>j : boolean
>true : boolean
c1(); // Implied type is {z:number}?
>c1() : void
>c1 : ({z}?: { z: number; }) => void
c1({ z: 1 }) // Implied type is {z:number}?
>c1({ z: 1 }) : void
>c1 : ({z}?: { z: number; }) => void
>{ z: 1 } : { z: number; }
>z : number
>1 : number
c2({}); // Implied type is {z?: number}
>c2({}) : void
>c2 : ({z = 10}: { z?: number; }) => void
>{} : {}
c2({z:1}); // Implied type is {z?: number}
>c2({z:1}) : void
>c2 : ({z = 10}: { z?: number; }) => void
>{z:1} : { z: number; }
>z : number
>1 : number
c3({ b: 1 }); // Implied type is { b: number|string }.
>c3({ b: 1 }) : void
>c3 : ({b}?: { b: string | number; }) => void
>{ b: 1 } : { b: number; }
>b : number
>1 : number
c5([1, 2, [["string"]]]); // Implied type is is [any, any, [[any]]]
>c5([1, 2, [["string"]]]) : void
>c5 : ([a, b, [[c]]]: [any, any, [[any]]]) => void
>[1, 2, [["string"]]] : [number, number, [[string]]]
>1 : number
>2 : number
>[["string"]] : [[string]]
>["string"] : [string]
>"string" : string
c5([1, 2, [["string"]], false, true]); // Implied type is is [any, any, [[any]]]
>c5([1, 2, [["string"]], false, true]) : void
>c5 : ([a, b, [[c]]]: [any, any, [[any]]]) => void
>[1, 2, [["string"]], false, true] : [number, number, [[string]], boolean, boolean]
>1 : number
>2 : number
>[["string"]] : [[string]]
>["string"] : [string]
>"string" : string
>false : boolean
>true : boolean
// A parameter can be marked optional by following its name or binding pattern with a question mark (?)
// or by including an initializer.
interface F2 {
>F2 : F2
d3([a, b, c]?);
>d3 : ([a, b, c]?: [any, any, any]) => any
>a : any
>b : any
>c : any
d4({x, y, z}?);
>d4 : ({x, y, z}?: { x: any; y: any; z: any; }) => any
>x : any
>y : any
>z : any
e0([a, b, c]);
>e0 : ([a, b, c]: [any, any, any]) => any
>a : any
>b : any
>c : any
}
class C2 implements F2 {
>C2 : C2
>F2 : F2
constructor() { }
d3() { }
>d3 : () => void
d4() { }
>d4 : () => void
e0([a, b, c]) { }
>e0 : ([a, b, c]: [any, any, any]) => void
>a : any
>b : any
>c : any
}
class C3 implements F2 {
>C3 : C3
>F2 : F2
d3([a, b, c]) { }
>d3 : ([a, b, c]: [any, any, any]) => void
>a : any
>b : any
>c : any
d4({x, y, z}) { }
>d4 : ({x, y, z}: { x: any; y: any; z: any; }) => void
>x : any
>y : any
>z : any
e0([a, b, c]) { }
>e0 : ([a, b, c]: [any, any, any]) => void
>a : any
>b : any
>c : any
}
function d5({x, y} = { x: 1, y: 2 }) { }
>d5 : ({x, y}?: { x: number; y: number; }) => void
>x : number
>y : number
>{ x: 1, y: 2 } : { x: number; y: number; }
>x : number
>1 : number
>y : number
>2 : number
d5(); // Parameter is optional as its declaration included an initializer
>d5() : void
>d5 : ({x, y}?: { x: number; y: number; }) => void
// Destructuring parameter declarations do not permit type annotations on the individual binding patterns,
// as such annotations would conflict with the already established meaning of colons in object literals.
// Type annotations must instead be written on the top- level parameter declaration
function e1({x: number}) { } // x has type any NOT number
>e1 : ({x: number}: { x: any; }) => void
>x : any
>number : any
function e2({x}: { x: number }) { } // x is type number
>e2 : ({x}: { x: number; }) => void
>x : number
>x : number
function e3({x}: { x?: number }) { } // x is an optional with type number
>e3 : ({x}: { x?: number; }) => void
>x : number
>x : number
function e4({x: [number,string,any] }) { } // x has type [any, any, any]
>e4 : ({x: [number,string,any] }: { x: [any, any, any]; }) => void
>x : any
>number : any
>string : any
>any : any
function e5({x: [a, b, c]}: { x: [number, number, number] }) { } // x has type [any, any, any]
>e5 : ({x: [a, b, c]}: { x: [number, number, number]; }) => void
>x : any
>a : number
>b : number
>c : number
>x : [number, number, number]
function e6({x: [number, number, number]}) { } // should be an error, duplicate identifier;
>e6 : ({x: [number, number, number]}: { x: [any, any, any]; }) => void
>x : any
>number : any
>number : any
>number : any

View File

@ -50,9 +50,12 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(
Type '{ x: any; y: any; c: any; }' is not assignable to type '{ x: any; y: any; z: any; }'.
Property 'z' is missing in type '{ x: any; y: any; c: any; }'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(56,8): error TS2463: A binding pattern parameter cannot be optional in an implementation signature.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(65,18): error TS2300: Duplicate identifier 'number'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(65,26): error TS2300: Duplicate identifier 'number'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(65,34): error TS2300: Duplicate identifier 'number'.
==== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts (19 errors) ====
==== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts (22 errors) ====
// A parameter declaration may specify either an identifier or a binding pattern.
// The identifiers specified in parameter declarations and binding patterns
// in a parameter list must be unique within that parameter list.
@ -188,7 +191,13 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(
// as such annotations would conflict with the already established meaning of colons in object literals.
// Type annotations must instead be written on the top- level parameter declaration
function e0({x: [number, number, number]}) { } // should be an error, duplicate identifier;
function e0({x: [number, number, number]}) { } // error, duplicate identifier;
~~~~~~
!!! error TS2300: Duplicate identifier 'number'.
~~~~~~
!!! error TS2300: Duplicate identifier 'number'.
~~~~~~
!!! error TS2300: Duplicate identifier 'number'.

View File

@ -63,7 +63,7 @@ class C4 implements F2 {
// as such annotations would conflict with the already established meaning of colons in object literals.
// Type annotations must instead be written on the top- level parameter declaration
function e0({x: [number, number, number]}) { } // should be an error, duplicate identifier;
function e0({x: [number, number, number]}) { } // error, duplicate identifier;
@ -146,4 +146,4 @@ var C4 = (function () {
// Type annotations must instead be written on the top- level parameter declaration
function e0(_a) {
var _b = _a.x, number = _b[0], number = _b[1], number = _b[2];
} // should be an error, duplicate identifier;
} // error, duplicate identifier;

View File

@ -0,0 +1,75 @@
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(2,13): error TS2300: Duplicate identifier 'a'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(2,17): error TS2300: Duplicate identifier 'a'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(2,21): error TS2300: Duplicate identifier 'b'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(2,27): error TS2300: Duplicate identifier 'b'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(3,14): error TS2300: Duplicate identifier 'a'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(3,17): error TS2300: Duplicate identifier 'a'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(4,14): error TS2300: Duplicate identifier 'b'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(4,19): error TS2300: Duplicate identifier 'b'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(5,14): error TS2300: Duplicate identifier 'c'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(5,17): error TS2300: Duplicate identifier 'c'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(5,22): error TS2300: Duplicate identifier 'c'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(6,14): error TS2300: Duplicate identifier 'd'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(6,20): error TS2300: Duplicate identifier 'd'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(7,14): error TS2300: Duplicate identifier 'e'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(7,21): error TS2300: Duplicate identifier 'e'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(7,27): error TS2300: Duplicate identifier 'e'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(7,34): error TS2300: Duplicate identifier 'e'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(7,39): error TS2300: Duplicate identifier 'e'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(7,48): error TS2300: Duplicate identifier 'e'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(8,14): error TS2300: Duplicate identifier 'f'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts(8,20): error TS2300: Duplicate identifier 'f'.
==== tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts (21 errors) ====
function f0(a, [a, [b]], {b}) { }
~
!!! error TS2300: Duplicate identifier 'a'.
~
!!! error TS2300: Duplicate identifier 'a'.
~
!!! error TS2300: Duplicate identifier 'b'.
~
!!! error TS2300: Duplicate identifier 'b'.
function f1([a, a]) { }
~
!!! error TS2300: Duplicate identifier 'a'.
~
!!! error TS2300: Duplicate identifier 'a'.
function f2({b}, {b}) { }
~
!!! error TS2300: Duplicate identifier 'b'.
~
!!! error TS2300: Duplicate identifier 'b'.
function f3([c,[c],[[c]]]) { }
~
!!! error TS2300: Duplicate identifier 'c'.
~
!!! error TS2300: Duplicate identifier 'c'.
~
!!! error TS2300: Duplicate identifier 'c'.
function f4({d, d:{d}}) { }
~
!!! error TS2300: Duplicate identifier 'd'.
~
!!! error TS2300: Duplicate identifier 'd'.
function f5({e, e: {e}}, {e}, [d,e, [[e]]], ...e) { }
~
!!! error TS2300: Duplicate identifier 'e'.
~
!!! error TS2300: Duplicate identifier 'e'.
~
!!! error TS2300: Duplicate identifier 'e'.
~
!!! error TS2300: Duplicate identifier 'e'.
~
!!! error TS2300: Duplicate identifier 'e'.
~
!!! error TS2300: Duplicate identifier 'e'.
function f6([f, ...f]) { }
~
!!! error TS2300: Duplicate identifier 'f'.
~
!!! error TS2300: Duplicate identifier 'f'.
function f7(a, func = (a) => { return 1 }) { } // not error

View File

@ -0,0 +1,44 @@
//// [duplicateIdentifierBindingElementInParameterDeclaration1.ts]
function f0(a, [a, [b]], {b}) { }
function f1([a, a]) { }
function f2({b}, {b}) { }
function f3([c,[c],[[c]]]) { }
function f4({d, d:{d}}) { }
function f5({e, e: {e}}, {e}, [d,e, [[e]]], ...e) { }
function f6([f, ...f]) { }
function f7(a, func = (a) => { return 1 }) { } // not error
//// [duplicateIdentifierBindingElementInParameterDeclaration1.js]
function f0(a, _a, _b) {
var a = _a[0], b = _a[1][0];
var b = _b.b;
}
function f1(_a) {
var a = _a[0], a = _a[1];
}
function f2(_a, _b) {
var b = _a.b;
var b = _b.b;
}
function f3(_a) {
var c = _a[0], c = _a[1][0], c = _a[2][0][0];
}
function f4(_a) {
var d = _a.d, d = _a.d.d;
}
function f5(_a, _b, _c) {
var e = _a.e, e = _a.e.e;
var e = _b.e;
var d = _c[0], e = _c[1], e = _c[2][0][0];
var e = [];
for (var _i = 3; _i < arguments.length; _i++) {
e[_i - 3] = arguments[_i];
}
}
function f6(_a) {
var f = _a[0], f = _a.slice(1);
}
function f7(a, func) {
if (func === void 0) { func = function (a) { return 1; }; }
} // not error

View File

@ -0,0 +1,76 @@
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(3,13): error TS2300: Duplicate identifier 'a'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(3,17): error TS2300: Duplicate identifier 'a'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(3,21): error TS2300: Duplicate identifier 'b'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(3,27): error TS2300: Duplicate identifier 'b'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(4,14): error TS2300: Duplicate identifier 'a'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(4,17): error TS2300: Duplicate identifier 'a'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(5,14): error TS2300: Duplicate identifier 'b'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(5,19): error TS2300: Duplicate identifier 'b'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(6,14): error TS2300: Duplicate identifier 'c'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(6,18): error TS2300: Duplicate identifier 'c'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(6,24): error TS2300: Duplicate identifier 'c'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(7,14): error TS2300: Duplicate identifier 'd'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(7,21): error TS2300: Duplicate identifier 'd'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(8,14): error TS2300: Duplicate identifier 'e'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(8,21): error TS2300: Duplicate identifier 'e'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(8,27): error TS2300: Duplicate identifier 'e'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(8,35): error TS2300: Duplicate identifier 'e'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(8,40): error TS2300: Duplicate identifier 'e'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(8,49): error TS2300: Duplicate identifier 'e'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(9,14): error TS2300: Duplicate identifier 'f'.
tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts(9,20): error TS2300: Duplicate identifier 'f'.
==== tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts (21 errors) ====
"use strict"
function f0(a, [a, [b]], {b}) { }
~
!!! error TS2300: Duplicate identifier 'a'.
~
!!! error TS2300: Duplicate identifier 'a'.
~
!!! error TS2300: Duplicate identifier 'b'.
~
!!! error TS2300: Duplicate identifier 'b'.
function f1([a, a]) { }
~
!!! error TS2300: Duplicate identifier 'a'.
~
!!! error TS2300: Duplicate identifier 'a'.
function f2({b}, {b}) { }
~
!!! error TS2300: Duplicate identifier 'b'.
~
!!! error TS2300: Duplicate identifier 'b'.
function f3([c, [c], [[c]]]) { }
~
!!! error TS2300: Duplicate identifier 'c'.
~
!!! error TS2300: Duplicate identifier 'c'.
~
!!! error TS2300: Duplicate identifier 'c'.
function f4({d, d: {d}}) { }
~
!!! error TS2300: Duplicate identifier 'd'.
~
!!! error TS2300: Duplicate identifier 'd'.
function f5({e, e: {e}}, {e}, [d, e, [[e]]], ...e) { }
~
!!! error TS2300: Duplicate identifier 'e'.
~
!!! error TS2300: Duplicate identifier 'e'.
~
!!! error TS2300: Duplicate identifier 'e'.
~
!!! error TS2300: Duplicate identifier 'e'.
~
!!! error TS2300: Duplicate identifier 'e'.
~
!!! error TS2300: Duplicate identifier 'e'.
function f6([f, ...f]) { }
~
!!! error TS2300: Duplicate identifier 'f'.
~
!!! error TS2300: Duplicate identifier 'f'.
function f7(a, func = (a) => { return 1 }){ } // not error

View File

@ -0,0 +1,46 @@
//// [duplicateIdentifierBindingElementInParameterDeclaration2.ts]
"use strict"
function f0(a, [a, [b]], {b}) { }
function f1([a, a]) { }
function f2({b}, {b}) { }
function f3([c, [c], [[c]]]) { }
function f4({d, d: {d}}) { }
function f5({e, e: {e}}, {e}, [d, e, [[e]]], ...e) { }
function f6([f, ...f]) { }
function f7(a, func = (a) => { return 1 }){ } // not error
//// [duplicateIdentifierBindingElementInParameterDeclaration2.js]
"use strict";
function f0(a, _a, _b) {
var a = _a[0], b = _a[1][0];
var b = _b.b;
}
function f1(_a) {
var a = _a[0], a = _a[1];
}
function f2(_a, _b) {
var b = _a.b;
var b = _b.b;
}
function f3(_a) {
var c = _a[0], c = _a[1][0], c = _a[2][0][0];
}
function f4(_a) {
var d = _a.d, d = _a.d.d;
}
function f5(_a, _b, _c) {
var e = _a.e, e = _a.e.e;
var e = _b.e;
var d = _c[0], e = _c[1], e = _c[2][0][0];
var e = [];
for (var _i = 3; _i < arguments.length; _i++) {
e[_i - 3] = arguments[_i];
}
}
function f6(_a) {
var f = _a[0], f = _a.slice(1);
}
function f7(a, func) {
if (func === void 0) { func = function (a) { return 1; }; }
} // not error

View File

@ -0,0 +1,10 @@
// @target: es5
function f0(a, [a, [b]], {b}) { }
function f1([a, a]) { }
function f2({b}, {b}) { }
function f3([c,[c],[[c]]]) { }
function f4({d, d:{d}}) { }
function f5({e, e: {e}}, {e}, [d,e, [[e]]], ...e) { }
function f6([f, ...f]) { }
function f7(a, func = (a) => { return 1 }) { } // not error

View File

@ -0,0 +1,11 @@
// @target: es5
"use strict"
function f0(a, [a, [b]], {b}) { }
function f1([a, a]) { }
function f2({b}, {b}) { }
function f3([c, [c], [[c]]]) { }
function f4({d, d: {d}}) { }
function f5({e, e: {e}}, {e}, [d, e, [[e]]], ...e) { }
function f6([f, ...f]) { }
function f7(a, func = (a) => { return 1 }){ } // not error

View File

@ -94,6 +94,6 @@ function e3({x}: { x?: number }) { } // x is an optional with type number
function e4({x: [number,string,any] }) { } // x has type [any, any, any]
function e5({x: [a, b, c]}: { x: [number, number, number] }) { } // x has type [any, any, any]
function e6({x: [number, number, number]}) { } // should be an error, duplicate identifier;
function e6({x: [number, number, number]}) { } // error, duplicate identifier;

View File

@ -62,6 +62,6 @@ class C4 implements F2 {
// as such annotations would conflict with the already established meaning of colons in object literals.
// Type annotations must instead be written on the top- level parameter declaration
function e0({x: [number, number, number]}) { } // should be an error, duplicate identifier;
function e0({x: [number, number, number]}) { } // error, duplicate identifier;