|
| 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 | +// multiple arguments |
| 11 | +((a, b, c) => { })("foo", 101, false); |
| 12 | +>a : Symbol(a, Decl(contextuallyTypedIife.ts, 5, 2)) |
| 13 | +>b : Symbol(b, Decl(contextuallyTypedIife.ts, 5, 4)) |
| 14 | +>c : Symbol(c, Decl(contextuallyTypedIife.ts, 5, 7)) |
| 15 | + |
| 16 | +// contextually typed parameters. |
| 17 | +(f => f(1))(i => i + 1); |
| 18 | +>f : Symbol(f, Decl(contextuallyTypedIife.ts, 7, 1)) |
| 19 | +>f : Symbol(f, Decl(contextuallyTypedIife.ts, 7, 1)) |
| 20 | +>i : Symbol(i, Decl(contextuallyTypedIife.ts, 7, 12)) |
| 21 | +>i : Symbol(i, Decl(contextuallyTypedIife.ts, 7, 12)) |
| 22 | + |
| 23 | +// default parameters |
| 24 | +((m = 10) => m + 1)(12); |
| 25 | +>m : Symbol(m, Decl(contextuallyTypedIife.ts, 9, 2)) |
| 26 | +>m : Symbol(m, Decl(contextuallyTypedIife.ts, 9, 2)) |
| 27 | + |
| 28 | +((n = 10) => n + 1)(); |
| 29 | +>n : Symbol(n, Decl(contextuallyTypedIife.ts, 10, 2)) |
| 30 | +>n : Symbol(n, Decl(contextuallyTypedIife.ts, 10, 2)) |
| 31 | + |
| 32 | +// optional parameters |
| 33 | +((j?) => j + 1)(12); |
| 34 | +>j : Symbol(j, Decl(contextuallyTypedIife.ts, 12, 2)) |
| 35 | +>j : Symbol(j, Decl(contextuallyTypedIife.ts, 12, 2)) |
| 36 | + |
| 37 | +((k?) => k + 1)(); |
| 38 | +>k : Symbol(k, Decl(contextuallyTypedIife.ts, 13, 2)) |
| 39 | +>k : Symbol(k, Decl(contextuallyTypedIife.ts, 13, 2)) |
| 40 | + |
| 41 | +((l, o?) => l + o)(12); // o should be any |
| 42 | +>l : Symbol(l, Decl(contextuallyTypedIife.ts, 14, 2)) |
| 43 | +>o : Symbol(o, Decl(contextuallyTypedIife.ts, 14, 4)) |
| 44 | +>l : Symbol(l, Decl(contextuallyTypedIife.ts, 14, 2)) |
| 45 | +>o : Symbol(o, Decl(contextuallyTypedIife.ts, 14, 4)) |
| 46 | + |
| 47 | +// rest parameters |
| 48 | +((...numbers) => numbers.every(n => n > 0))(5,6,7); |
| 49 | +>numbers : Symbol(numbers, Decl(contextuallyTypedIife.ts, 16, 2)) |
| 50 | +>numbers.every : Symbol(Array.every, Decl(lib.d.ts, --, --)) |
| 51 | +>numbers : Symbol(numbers, Decl(contextuallyTypedIife.ts, 16, 2)) |
| 52 | +>every : Symbol(Array.every, Decl(lib.d.ts, --, --)) |
| 53 | +>n : Symbol(n, Decl(contextuallyTypedIife.ts, 16, 31)) |
| 54 | +>n : Symbol(n, Decl(contextuallyTypedIife.ts, 16, 31)) |
| 55 | + |
| 56 | +((...noNumbers) => noNumbers.some(n => n > 0))(); |
| 57 | +>noNumbers : Symbol(noNumbers, Decl(contextuallyTypedIife.ts, 17, 2)) |
| 58 | +>noNumbers.some : Symbol(Array.some, Decl(lib.d.ts, --, --)) |
| 59 | +>noNumbers : Symbol(noNumbers, Decl(contextuallyTypedIife.ts, 17, 2)) |
| 60 | +>some : Symbol(Array.some, Decl(lib.d.ts, --, --)) |
| 61 | +>n : Symbol(n, Decl(contextuallyTypedIife.ts, 17, 34)) |
| 62 | +>n : Symbol(n, Decl(contextuallyTypedIife.ts, 17, 34)) |
| 63 | + |
| 64 | +((first, ...rest) => first ? [] : rest.map(n => n > 0))(8,9,10); |
| 65 | +>first : Symbol(first, Decl(contextuallyTypedIife.ts, 18, 2)) |
| 66 | +>rest : Symbol(rest, Decl(contextuallyTypedIife.ts, 18, 8)) |
| 67 | +>first : Symbol(first, Decl(contextuallyTypedIife.ts, 18, 2)) |
| 68 | +>rest.map : Symbol(Array.map, Decl(lib.d.ts, --, --)) |
| 69 | +>rest : Symbol(rest, Decl(contextuallyTypedIife.ts, 18, 8)) |
| 70 | +>map : Symbol(Array.map, Decl(lib.d.ts, --, --)) |
| 71 | +>n : Symbol(n, Decl(contextuallyTypedIife.ts, 18, 43)) |
| 72 | +>n : Symbol(n, Decl(contextuallyTypedIife.ts, 18, 43)) |
| 73 | + |
| 74 | +// destructuring parameters (with defaults too!) |
| 75 | +(({ q }) => q)({ q : 13 }); |
| 76 | +>q : Symbol(q, Decl(contextuallyTypedIife.ts, 20, 3)) |
| 77 | +>q : Symbol(q, Decl(contextuallyTypedIife.ts, 20, 3)) |
| 78 | +>q : Symbol(q, Decl(contextuallyTypedIife.ts, 20, 16)) |
| 79 | + |
| 80 | +(({ p = 14 }) => p)({ p : 15 }); |
| 81 | +>p : Symbol(p, Decl(contextuallyTypedIife.ts, 21, 3)) |
| 82 | +>p : Symbol(p, Decl(contextuallyTypedIife.ts, 21, 3)) |
| 83 | +>p : Symbol(p, Decl(contextuallyTypedIife.ts, 21, 21)) |
| 84 | + |
| 85 | +(({ r = 17 } = { r: 18 }) => r)({r : 19}); |
| 86 | +>r : Symbol(r, Decl(contextuallyTypedIife.ts, 22, 3)) |
| 87 | +>r : Symbol(r, Decl(contextuallyTypedIife.ts, 22, 16)) |
| 88 | +>r : Symbol(r, Decl(contextuallyTypedIife.ts, 22, 3)) |
| 89 | +>r : Symbol(r, Decl(contextuallyTypedIife.ts, 22, 33)) |
| 90 | + |
| 91 | +(({ u = 22 } = { u: 23 }) => u)(); |
| 92 | +>u : Symbol(u, Decl(contextuallyTypedIife.ts, 23, 3)) |
| 93 | +>u : Symbol(u, Decl(contextuallyTypedIife.ts, 23, 16)) |
| 94 | +>u : Symbol(u, Decl(contextuallyTypedIife.ts, 23, 3)) |
| 95 | + |
| 96 | + |
| 97 | + |
0 commit comments