|
| 1 | +=== tests/cases/conformance/expressions/functions/contextuallyTypedIife.ts === |
| 2 | +// arrow |
| 3 | +(jake => { })("build"); |
| 4 | +>jake : Symbol(jake, Decl(contextuallyTypedIife.ts, 1, 1)) |
| 5 | + |
| 6 | +// function expression |
| 7 | +(function (cats) { })("lol"); |
| 8 | +>cats : Symbol(cats, Decl(contextuallyTypedIife.ts, 3, 11)) |
| 9 | + |
| 10 | +// Lots of Irritating Superfluous Parentheses |
| 11 | +(function (x) { } ("!")); |
| 12 | +>x : Symbol(x, Decl(contextuallyTypedIife.ts, 5, 11)) |
| 13 | + |
| 14 | +((((function (y) { }))))("-"); |
| 15 | +>y : Symbol(y, Decl(contextuallyTypedIife.ts, 6, 14)) |
| 16 | + |
| 17 | +// multiple arguments |
| 18 | +((a, b, c) => { })("foo", 101, false); |
| 19 | +>a : Symbol(a, Decl(contextuallyTypedIife.ts, 8, 2)) |
| 20 | +>b : Symbol(b, Decl(contextuallyTypedIife.ts, 8, 4)) |
| 21 | +>c : Symbol(c, Decl(contextuallyTypedIife.ts, 8, 7)) |
| 22 | + |
| 23 | +// default parameters |
| 24 | +((m = 10) => m + 1)(12); |
| 25 | +>m : Symbol(m, Decl(contextuallyTypedIife.ts, 10, 2)) |
| 26 | +>m : Symbol(m, Decl(contextuallyTypedIife.ts, 10, 2)) |
| 27 | + |
| 28 | +((n = 10) => n + 1)(); |
| 29 | +>n : Symbol(n, Decl(contextuallyTypedIife.ts, 11, 2)) |
| 30 | +>n : Symbol(n, Decl(contextuallyTypedIife.ts, 11, 2)) |
| 31 | + |
| 32 | +// optional parameters |
| 33 | +((j?) => j + 1)(12); |
| 34 | +>j : Symbol(j, Decl(contextuallyTypedIife.ts, 13, 2)) |
| 35 | +>j : Symbol(j, Decl(contextuallyTypedIife.ts, 13, 2)) |
| 36 | + |
| 37 | +((k?) => k + 1)(); |
| 38 | +>k : Symbol(k, Decl(contextuallyTypedIife.ts, 14, 2)) |
| 39 | +>k : Symbol(k, Decl(contextuallyTypedIife.ts, 14, 2)) |
| 40 | + |
| 41 | +((l, o?) => l + o)(12); // o should be any |
| 42 | +>l : Symbol(l, Decl(contextuallyTypedIife.ts, 15, 2)) |
| 43 | +>o : Symbol(o, Decl(contextuallyTypedIife.ts, 15, 4)) |
| 44 | +>l : Symbol(l, Decl(contextuallyTypedIife.ts, 15, 2)) |
| 45 | +>o : Symbol(o, Decl(contextuallyTypedIife.ts, 15, 4)) |
| 46 | + |
| 47 | +// rest parameters |
| 48 | +((...numbers) => numbers.every(n => n > 0))(5,6,7); |
| 49 | +>numbers : Symbol(numbers, Decl(contextuallyTypedIife.ts, 17, 2)) |
| 50 | +>numbers.every : Symbol(Array.every, Decl(lib.d.ts, --, --)) |
| 51 | +>numbers : Symbol(numbers, Decl(contextuallyTypedIife.ts, 17, 2)) |
| 52 | +>every : Symbol(Array.every, Decl(lib.d.ts, --, --)) |
| 53 | +>n : Symbol(n, Decl(contextuallyTypedIife.ts, 17, 31)) |
| 54 | +>n : Symbol(n, Decl(contextuallyTypedIife.ts, 17, 31)) |
| 55 | + |
| 56 | +((...mixed) => mixed.every(n => !!n))(5,'oops','oh no'); |
| 57 | +>mixed : Symbol(mixed, Decl(contextuallyTypedIife.ts, 18, 2)) |
| 58 | +>mixed.every : Symbol(Array.every, Decl(lib.d.ts, --, --)) |
| 59 | +>mixed : Symbol(mixed, Decl(contextuallyTypedIife.ts, 18, 2)) |
| 60 | +>every : Symbol(Array.every, Decl(lib.d.ts, --, --)) |
| 61 | +>n : Symbol(n, Decl(contextuallyTypedIife.ts, 18, 27)) |
| 62 | +>n : Symbol(n, Decl(contextuallyTypedIife.ts, 18, 27)) |
| 63 | + |
| 64 | +((...noNumbers) => noNumbers.some(n => n > 0))(); |
| 65 | +>noNumbers : Symbol(noNumbers, Decl(contextuallyTypedIife.ts, 19, 2)) |
| 66 | +>noNumbers.some : Symbol(Array.some, Decl(lib.d.ts, --, --)) |
| 67 | +>noNumbers : Symbol(noNumbers, Decl(contextuallyTypedIife.ts, 19, 2)) |
| 68 | +>some : Symbol(Array.some, Decl(lib.d.ts, --, --)) |
| 69 | +>n : Symbol(n, Decl(contextuallyTypedIife.ts, 19, 34)) |
| 70 | +>n : Symbol(n, Decl(contextuallyTypedIife.ts, 19, 34)) |
| 71 | + |
| 72 | +((first, ...rest) => first ? [] : rest.map(n => n > 0))(8,9,10); |
| 73 | +>first : Symbol(first, Decl(contextuallyTypedIife.ts, 20, 2)) |
| 74 | +>rest : Symbol(rest, Decl(contextuallyTypedIife.ts, 20, 8)) |
| 75 | +>first : Symbol(first, Decl(contextuallyTypedIife.ts, 20, 2)) |
| 76 | +>rest.map : Symbol(Array.map, Decl(lib.d.ts, --, --)) |
| 77 | +>rest : Symbol(rest, Decl(contextuallyTypedIife.ts, 20, 8)) |
| 78 | +>map : Symbol(Array.map, Decl(lib.d.ts, --, --)) |
| 79 | +>n : Symbol(n, Decl(contextuallyTypedIife.ts, 20, 43)) |
| 80 | +>n : Symbol(n, Decl(contextuallyTypedIife.ts, 20, 43)) |
| 81 | + |
| 82 | +// destructuring parameters (with defaults too!) |
| 83 | +(({ q }) => q)({ q : 13 }); |
| 84 | +>q : Symbol(q, Decl(contextuallyTypedIife.ts, 22, 3)) |
| 85 | +>q : Symbol(q, Decl(contextuallyTypedIife.ts, 22, 3)) |
| 86 | +>q : Symbol(q, Decl(contextuallyTypedIife.ts, 22, 16)) |
| 87 | + |
| 88 | +(({ p = 14 }) => p)({ p : 15 }); |
| 89 | +>p : Symbol(p, Decl(contextuallyTypedIife.ts, 23, 3)) |
| 90 | +>p : Symbol(p, Decl(contextuallyTypedIife.ts, 23, 3)) |
| 91 | +>p : Symbol(p, Decl(contextuallyTypedIife.ts, 23, 21)) |
| 92 | + |
| 93 | +(({ r = 17 } = { r: 18 }) => r)({r : 19}); |
| 94 | +>r : Symbol(r, Decl(contextuallyTypedIife.ts, 24, 3)) |
| 95 | +>r : Symbol(r, Decl(contextuallyTypedIife.ts, 24, 16)) |
| 96 | +>r : Symbol(r, Decl(contextuallyTypedIife.ts, 24, 3)) |
| 97 | +>r : Symbol(r, Decl(contextuallyTypedIife.ts, 24, 33)) |
| 98 | + |
| 99 | +(({ u = 22 } = { u: 23 }) => u)(); |
| 100 | +>u : Symbol(u, Decl(contextuallyTypedIife.ts, 25, 3)) |
| 101 | +>u : Symbol(u, Decl(contextuallyTypedIife.ts, 25, 16)) |
| 102 | +>u : Symbol(u, Decl(contextuallyTypedIife.ts, 25, 3)) |
| 103 | + |
| 104 | +// contextually typed parameters. |
| 105 | +let twelve = (f => f(12))(i => i); |
| 106 | +>twelve : Symbol(twelve, Decl(contextuallyTypedIife.ts, 27, 3)) |
| 107 | +>f : Symbol(f, Decl(contextuallyTypedIife.ts, 27, 14)) |
| 108 | +>f : Symbol(f, Decl(contextuallyTypedIife.ts, 27, 14)) |
| 109 | +>i : Symbol(i, Decl(contextuallyTypedIife.ts, 27, 26)) |
| 110 | +>i : Symbol(i, Decl(contextuallyTypedIife.ts, 27, 26)) |
| 111 | + |
| 112 | +let eleven = (o => o.a(11))({ a: function(n) { return n; } }); |
| 113 | +>eleven : Symbol(eleven, Decl(contextuallyTypedIife.ts, 28, 3)) |
| 114 | +>o : Symbol(o, Decl(contextuallyTypedIife.ts, 28, 14)) |
| 115 | +>o.a : Symbol(a, Decl(contextuallyTypedIife.ts, 28, 29)) |
| 116 | +>o : Symbol(o, Decl(contextuallyTypedIife.ts, 28, 14)) |
| 117 | +>a : Symbol(a, Decl(contextuallyTypedIife.ts, 28, 29)) |
| 118 | +>a : Symbol(a, Decl(contextuallyTypedIife.ts, 28, 29)) |
| 119 | +>n : Symbol(n, Decl(contextuallyTypedIife.ts, 28, 42)) |
| 120 | +>n : Symbol(n, Decl(contextuallyTypedIife.ts, 28, 42)) |
| 121 | + |
0 commit comments