//// [tests/cases/conformance/expressions/contextualTyping/argumentExpressionContextualTyping.ts] ////

=== argumentExpressionContextualTyping.ts ===
// In a typed function call, argument expressions are contextually typed by their corresponding parameter types.
function foo({x: [a, b], y: {c, d, e}}) { }
>foo : Symbol(foo, Decl(argumentExpressionContextualTyping.ts, 0, 0))
>x : Symbol(x)
>a : Symbol(a, Decl(argumentExpressionContextualTyping.ts, 1, 18))
>b : Symbol(b, Decl(argumentExpressionContextualTyping.ts, 1, 20))
>y : Symbol(y)
>c : Symbol(c, Decl(argumentExpressionContextualTyping.ts, 1, 29))
>d : Symbol(d, Decl(argumentExpressionContextualTyping.ts, 1, 31))
>e : Symbol(e, Decl(argumentExpressionContextualTyping.ts, 1, 34))

function bar({x: [a, b = 10], y: {c, d, e = { f:1 }}}) { }
>bar : Symbol(bar, Decl(argumentExpressionContextualTyping.ts, 1, 43))
>x : Symbol(x)
>a : Symbol(a, Decl(argumentExpressionContextualTyping.ts, 2, 18))
>b : Symbol(b, Decl(argumentExpressionContextualTyping.ts, 2, 20))
>y : Symbol(y)
>c : Symbol(c, Decl(argumentExpressionContextualTyping.ts, 2, 34))
>d : Symbol(d, Decl(argumentExpressionContextualTyping.ts, 2, 36))
>e : Symbol(e, Decl(argumentExpressionContextualTyping.ts, 2, 39))
>f : Symbol(f, Decl(argumentExpressionContextualTyping.ts, 2, 45))

function baz(x: [string, number, boolean]) { }
>baz : Symbol(baz, Decl(argumentExpressionContextualTyping.ts, 2, 58))
>x : Symbol(x, Decl(argumentExpressionContextualTyping.ts, 3, 13))

var o = { x: ["string", 1], y: { c: true, d: "world", e: 3 } };
>o : Symbol(o, Decl(argumentExpressionContextualTyping.ts, 5, 3))
>x : Symbol(x, Decl(argumentExpressionContextualTyping.ts, 5, 9))
>y : Symbol(y, Decl(argumentExpressionContextualTyping.ts, 5, 27))
>c : Symbol(c, Decl(argumentExpressionContextualTyping.ts, 5, 32))
>d : Symbol(d, Decl(argumentExpressionContextualTyping.ts, 5, 41))
>e : Symbol(e, Decl(argumentExpressionContextualTyping.ts, 5, 53))

var o1: { x: [string, number], y: { c: boolean, d: string, e: number } } = { x: ["string", 1], y: { c: true, d: "world", e: 3 } };
>o1 : Symbol(o1, Decl(argumentExpressionContextualTyping.ts, 6, 3))
>x : Symbol(x, Decl(argumentExpressionContextualTyping.ts, 6, 9))
>y : Symbol(y, Decl(argumentExpressionContextualTyping.ts, 6, 30))
>c : Symbol(c, Decl(argumentExpressionContextualTyping.ts, 6, 35))
>d : Symbol(d, Decl(argumentExpressionContextualTyping.ts, 6, 47))
>e : Symbol(e, Decl(argumentExpressionContextualTyping.ts, 6, 58))
>x : Symbol(x, Decl(argumentExpressionContextualTyping.ts, 6, 76))
>y : Symbol(y, Decl(argumentExpressionContextualTyping.ts, 6, 94))
>c : Symbol(c, Decl(argumentExpressionContextualTyping.ts, 6, 99))
>d : Symbol(d, Decl(argumentExpressionContextualTyping.ts, 6, 108))
>e : Symbol(e, Decl(argumentExpressionContextualTyping.ts, 6, 120))

foo(o1); // Not error since x has contextual type of tuple namely [string, number]
>foo : Symbol(foo, Decl(argumentExpressionContextualTyping.ts, 0, 0))
>o1 : Symbol(o1, Decl(argumentExpressionContextualTyping.ts, 6, 3))

foo({ x: ["string", 1], y: { c: true, d: "world", e: 3 } }); // Not error
>foo : Symbol(foo, Decl(argumentExpressionContextualTyping.ts, 0, 0))
>x : Symbol(x, Decl(argumentExpressionContextualTyping.ts, 8, 5))
>y : Symbol(y, Decl(argumentExpressionContextualTyping.ts, 8, 23))
>c : Symbol(c, Decl(argumentExpressionContextualTyping.ts, 8, 28))
>d : Symbol(d, Decl(argumentExpressionContextualTyping.ts, 8, 37))
>e : Symbol(e, Decl(argumentExpressionContextualTyping.ts, 8, 49))

var array = ["string", 1, true];
>array : Symbol(array, Decl(argumentExpressionContextualTyping.ts, 10, 3))

var tuple: [string, number, boolean] = ["string", 1, true];
>tuple : Symbol(tuple, Decl(argumentExpressionContextualTyping.ts, 11, 3))

baz(tuple);
>baz : Symbol(baz, Decl(argumentExpressionContextualTyping.ts, 2, 58))
>tuple : Symbol(tuple, Decl(argumentExpressionContextualTyping.ts, 11, 3))

baz(["string", 1, true]);
>baz : Symbol(baz, Decl(argumentExpressionContextualTyping.ts, 2, 58))

baz(array);                          // Error
>baz : Symbol(baz, Decl(argumentExpressionContextualTyping.ts, 2, 58))
>array : Symbol(array, Decl(argumentExpressionContextualTyping.ts, 10, 3))

baz(["string", 1, true, ...array]);  // Error
>baz : Symbol(baz, Decl(argumentExpressionContextualTyping.ts, 2, 58))
>array : Symbol(array, Decl(argumentExpressionContextualTyping.ts, 10, 3))

foo(o);                              // Error because x has an array type namely (string|number)[]
>foo : Symbol(foo, Decl(argumentExpressionContextualTyping.ts, 0, 0))
>o : Symbol(o, Decl(argumentExpressionContextualTyping.ts, 5, 3))

