]> git.proxmox.com Git - pve-eslint.git/blob - eslint/tests/fixtures/parsers/function-paren-newline/arrow-function-return-type.js
import 8.23.1 source
[pve-eslint.git] / eslint / tests / fixtures / parsers / function-paren-newline / arrow-function-return-type.js
1 "use strict";
2
3 /**
4 * Parser: @typescript-eslint/parser@5.10.1
5 * Source code:
6 * const method6 = (
7 * abc: number,
8 * def: () => void,
9 * ): [
10 * string,
11 * () => void
12 * ] => [`a${abc}`, def];
13 * method6(3, () => {});
14 */
15
16 exports.parse = () => ({
17 type: "Program",
18 body: [
19 {
20 type: "VariableDeclaration",
21 declarations: [
22 {
23 type: "VariableDeclarator",
24 id: {
25 type: "Identifier",
26 name: "method6",
27 range: [6, 13],
28 loc: {
29 start: { line: 1, column: 6 },
30 end: { line: 1, column: 13 },
31 },
32 },
33 init: {
34 type: "ArrowFunctionExpression",
35 generator: false,
36 id: null,
37 params: [
38 {
39 type: "Identifier",
40 name: "abc",
41 range: [20, 31],
42 loc: {
43 start: { line: 2, column: 2 },
44 end: { line: 2, column: 13 },
45 },
46 typeAnnotation: {
47 type: "TSTypeAnnotation",
48 loc: {
49 start: { line: 2, column: 5 },
50 end: { line: 2, column: 13 },
51 },
52 range: [23, 31],
53 typeAnnotation: {
54 type: "TSNumberKeyword",
55 range: [25, 31],
56 loc: {
57 start: { line: 2, column: 7 },
58 end: { line: 2, column: 13 },
59 },
60 },
61 },
62 },
63 {
64 type: "Identifier",
65 name: "def",
66 range: [35, 50],
67 loc: {
68 start: { line: 3, column: 2 },
69 end: { line: 3, column: 17 },
70 },
71 typeAnnotation: {
72 type: "TSTypeAnnotation",
73 loc: {
74 start: { line: 3, column: 5 },
75 end: { line: 3, column: 17 },
76 },
77 range: [38, 50],
78 typeAnnotation: {
79 type: "TSFunctionType",
80 params: [],
81 range: [40, 50],
82 loc: {
83 start: { line: 3, column: 7 },
84 end: { line: 3, column: 17 },
85 },
86 returnType: {
87 type: "TSTypeAnnotation",
88 loc: {
89 start: { line: 3, column: 10 },
90 end: { line: 3, column: 17 },
91 },
92 range: [43, 50],
93 typeAnnotation: {
94 type: "TSVoidKeyword",
95 range: [46, 50],
96 loc: {
97 start: {
98 line: 3,
99 column: 13,
100 },
101 end: {
102 line: 3,
103 column: 17,
104 },
105 },
106 },
107 },
108 },
109 },
110 },
111 ],
112 body: {
113 type: "ArrayExpression",
114 elements: [
115 {
116 type: "TemplateLiteral",
117 quasis: [
118 {
119 type: "TemplateElement",
120 value: { raw: "a", cooked: "a" },
121 tail: false,
122 range: [86, 90],
123 loc: {
124 start: { line: 7, column: 6 },
125 end: { line: 7, column: 10 },
126 },
127 },
128 {
129 type: "TemplateElement",
130 value: { raw: "", cooked: "" },
131 tail: true,
132 range: [93, 95],
133 loc: {
134 start: { line: 7, column: 13 },
135 end: { line: 7, column: 15 },
136 },
137 },
138 ],
139 expressions: [
140 {
141 type: "Identifier",
142 name: "abc",
143 range: [90, 93],
144 loc: {
145 start: { line: 7, column: 10 },
146 end: { line: 7, column: 13 },
147 },
148 },
149 ],
150 range: [86, 95],
151 loc: {
152 start: { line: 7, column: 6 },
153 end: { line: 7, column: 15 },
154 },
155 },
156 {
157 type: "Identifier",
158 name: "def",
159 range: [97, 100],
160 loc: {
161 start: { line: 7, column: 17 },
162 end: { line: 7, column: 20 },
163 },
164 },
165 ],
166 range: [85, 101],
167 loc: {
168 start: { line: 7, column: 5 },
169 end: { line: 7, column: 21 },
170 },
171 },
172 async: false,
173 expression: true,
174 range: [16, 101],
175 loc: {
176 start: { line: 1, column: 16 },
177 end: { line: 7, column: 21 },
178 },
179 returnType: {
180 type: "TSTypeAnnotation",
181 loc: {
182 start: { line: 4, column: 1 },
183 end: { line: 7, column: 1 },
184 },
185 range: [53, 81],
186 typeAnnotation: {
187 type: "TSTupleType",
188 elementTypes: [
189 {
190 type: "TSStringKeyword",
191 range: [59, 65],
192 loc: {
193 start: { line: 5, column: 2 },
194 end: { line: 5, column: 8 },
195 },
196 },
197 {
198 type: "TSFunctionType",
199 params: [],
200 range: [69, 79],
201 loc: {
202 start: { line: 6, column: 2 },
203 end: { line: 6, column: 12 },
204 },
205 returnType: {
206 type: "TSTypeAnnotation",
207 loc: {
208 start: { line: 6, column: 5 },
209 end: { line: 6, column: 12 },
210 },
211 range: [72, 79],
212 typeAnnotation: {
213 type: "TSVoidKeyword",
214 range: [75, 79],
215 loc: {
216 start: {
217 line: 6,
218 column: 8,
219 },
220 end: {
221 line: 6,
222 column: 12,
223 },
224 },
225 },
226 },
227 },
228 ],
229 range: [55, 81],
230 loc: {
231 start: { line: 4, column: 3 },
232 end: { line: 7, column: 1 },
233 },
234 },
235 },
236 },
237 range: [6, 101],
238 loc: {
239 start: { line: 1, column: 6 },
240 end: { line: 7, column: 21 },
241 },
242 },
243 ],
244 kind: "const",
245 range: [0, 102],
246 loc: {
247 start: { line: 1, column: 0 },
248 end: { line: 7, column: 22 },
249 },
250 },
251 {
252 type: "ExpressionStatement",
253 expression: {
254 type: "CallExpression",
255 callee: {
256 type: "Identifier",
257 name: "method6",
258 range: [103, 110],
259 loc: {
260 start: { line: 8, column: 0 },
261 end: { line: 8, column: 7 },
262 },
263 },
264 arguments: [
265 {
266 type: "Literal",
267 value: 3,
268 raw: "3",
269 range: [111, 112],
270 loc: {
271 start: { line: 8, column: 8 },
272 end: { line: 8, column: 9 },
273 },
274 },
275 {
276 type: "ArrowFunctionExpression",
277 generator: false,
278 id: null,
279 params: [],
280 body: {
281 type: "BlockStatement",
282 body: [],
283 range: [120, 122],
284 loc: {
285 start: { line: 8, column: 17 },
286 end: { line: 8, column: 19 },
287 },
288 },
289 async: false,
290 expression: false,
291 range: [114, 122],
292 loc: {
293 start: { line: 8, column: 11 },
294 end: { line: 8, column: 19 },
295 },
296 },
297 ],
298 optional: false,
299 range: [103, 123],
300 loc: {
301 start: { line: 8, column: 0 },
302 end: { line: 8, column: 20 },
303 },
304 },
305 range: [103, 124],
306 loc: {
307 start: { line: 8, column: 0 },
308 end: { line: 8, column: 21 },
309 },
310 },
311 ],
312 sourceType: "script",
313 range: [0, 125],
314 loc: { start: { line: 1, column: 0 }, end: { line: 9, column: 0 } },
315 tokens: [
316 {
317 type: "Keyword",
318 value: "const",
319 range: [0, 5],
320 loc: { start: { line: 1, column: 0 }, end: { line: 1, column: 5 } },
321 },
322 {
323 type: "Identifier",
324 value: "method6",
325 range: [6, 13],
326 loc: {
327 start: { line: 1, column: 6 },
328 end: { line: 1, column: 13 },
329 },
330 },
331 {
332 type: "Punctuator",
333 value: "=",
334 range: [14, 15],
335 loc: {
336 start: { line: 1, column: 14 },
337 end: { line: 1, column: 15 },
338 },
339 },
340 {
341 type: "Punctuator",
342 value: "(",
343 range: [16, 17],
344 loc: {
345 start: { line: 1, column: 16 },
346 end: { line: 1, column: 17 },
347 },
348 },
349 {
350 type: "Identifier",
351 value: "abc",
352 range: [20, 23],
353 loc: { start: { line: 2, column: 2 }, end: { line: 2, column: 5 } },
354 },
355 {
356 type: "Punctuator",
357 value: ":",
358 range: [23, 24],
359 loc: { start: { line: 2, column: 5 }, end: { line: 2, column: 6 } },
360 },
361 {
362 type: "Identifier",
363 value: "number",
364 range: [25, 31],
365 loc: {
366 start: { line: 2, column: 7 },
367 end: { line: 2, column: 13 },
368 },
369 },
370 {
371 type: "Punctuator",
372 value: ",",
373 range: [31, 32],
374 loc: {
375 start: { line: 2, column: 13 },
376 end: { line: 2, column: 14 },
377 },
378 },
379 {
380 type: "Identifier",
381 value: "def",
382 range: [35, 38],
383 loc: { start: { line: 3, column: 2 }, end: { line: 3, column: 5 } },
384 },
385 {
386 type: "Punctuator",
387 value: ":",
388 range: [38, 39],
389 loc: { start: { line: 3, column: 5 }, end: { line: 3, column: 6 } },
390 },
391 {
392 type: "Punctuator",
393 value: "(",
394 range: [40, 41],
395 loc: { start: { line: 3, column: 7 }, end: { line: 3, column: 8 } },
396 },
397 {
398 type: "Punctuator",
399 value: ")",
400 range: [41, 42],
401 loc: { start: { line: 3, column: 8 }, end: { line: 3, column: 9 } },
402 },
403 {
404 type: "Punctuator",
405 value: "=>",
406 range: [43, 45],
407 loc: {
408 start: { line: 3, column: 10 },
409 end: { line: 3, column: 12 },
410 },
411 },
412 {
413 type: "Keyword",
414 value: "void",
415 range: [46, 50],
416 loc: {
417 start: { line: 3, column: 13 },
418 end: { line: 3, column: 17 },
419 },
420 },
421 {
422 type: "Punctuator",
423 value: ",",
424 range: [50, 51],
425 loc: {
426 start: { line: 3, column: 17 },
427 end: { line: 3, column: 18 },
428 },
429 },
430 {
431 type: "Punctuator",
432 value: ")",
433 range: [52, 53],
434 loc: { start: { line: 4, column: 0 }, end: { line: 4, column: 1 } },
435 },
436 {
437 type: "Punctuator",
438 value: ":",
439 range: [53, 54],
440 loc: { start: { line: 4, column: 1 }, end: { line: 4, column: 2 } },
441 },
442 {
443 type: "Punctuator",
444 value: "[",
445 range: [55, 56],
446 loc: { start: { line: 4, column: 3 }, end: { line: 4, column: 4 } },
447 },
448 {
449 type: "Identifier",
450 value: "string",
451 range: [59, 65],
452 loc: { start: { line: 5, column: 2 }, end: { line: 5, column: 8 } },
453 },
454 {
455 type: "Punctuator",
456 value: ",",
457 range: [65, 66],
458 loc: { start: { line: 5, column: 8 }, end: { line: 5, column: 9 } },
459 },
460 {
461 type: "Punctuator",
462 value: "(",
463 range: [69, 70],
464 loc: { start: { line: 6, column: 2 }, end: { line: 6, column: 3 } },
465 },
466 {
467 type: "Punctuator",
468 value: ")",
469 range: [70, 71],
470 loc: { start: { line: 6, column: 3 }, end: { line: 6, column: 4 } },
471 },
472 {
473 type: "Punctuator",
474 value: "=>",
475 range: [72, 74],
476 loc: { start: { line: 6, column: 5 }, end: { line: 6, column: 7 } },
477 },
478 {
479 type: "Keyword",
480 value: "void",
481 range: [75, 79],
482 loc: {
483 start: { line: 6, column: 8 },
484 end: { line: 6, column: 12 },
485 },
486 },
487 {
488 type: "Punctuator",
489 value: "]",
490 range: [80, 81],
491 loc: { start: { line: 7, column: 0 }, end: { line: 7, column: 1 } },
492 },
493 {
494 type: "Punctuator",
495 value: "=>",
496 range: [82, 84],
497 loc: { start: { line: 7, column: 2 }, end: { line: 7, column: 4 } },
498 },
499 {
500 type: "Punctuator",
501 value: "[",
502 range: [85, 86],
503 loc: { start: { line: 7, column: 5 }, end: { line: 7, column: 6 } },
504 },
505 {
506 type: "Template",
507 value: "`a${",
508 range: [86, 90],
509 loc: {
510 start: { line: 7, column: 6 },
511 end: { line: 7, column: 10 },
512 },
513 },
514 {
515 type: "Identifier",
516 value: "abc",
517 range: [90, 93],
518 loc: {
519 start: { line: 7, column: 10 },
520 end: { line: 7, column: 13 },
521 },
522 },
523 {
524 type: "Template",
525 value: "}`",
526 range: [93, 95],
527 loc: {
528 start: { line: 7, column: 13 },
529 end: { line: 7, column: 15 },
530 },
531 },
532 {
533 type: "Punctuator",
534 value: ",",
535 range: [95, 96],
536 loc: {
537 start: { line: 7, column: 15 },
538 end: { line: 7, column: 16 },
539 },
540 },
541 {
542 type: "Identifier",
543 value: "def",
544 range: [97, 100],
545 loc: {
546 start: { line: 7, column: 17 },
547 end: { line: 7, column: 20 },
548 },
549 },
550 {
551 type: "Punctuator",
552 value: "]",
553 range: [100, 101],
554 loc: {
555 start: { line: 7, column: 20 },
556 end: { line: 7, column: 21 },
557 },
558 },
559 {
560 type: "Punctuator",
561 value: ";",
562 range: [101, 102],
563 loc: {
564 start: { line: 7, column: 21 },
565 end: { line: 7, column: 22 },
566 },
567 },
568 {
569 type: "Identifier",
570 value: "method6",
571 range: [103, 110],
572 loc: { start: { line: 8, column: 0 }, end: { line: 8, column: 7 } },
573 },
574 {
575 type: "Punctuator",
576 value: "(",
577 range: [110, 111],
578 loc: { start: { line: 8, column: 7 }, end: { line: 8, column: 8 } },
579 },
580 {
581 type: "Numeric",
582 value: "3",
583 range: [111, 112],
584 loc: { start: { line: 8, column: 8 }, end: { line: 8, column: 9 } },
585 },
586 {
587 type: "Punctuator",
588 value: ",",
589 range: [112, 113],
590 loc: {
591 start: { line: 8, column: 9 },
592 end: { line: 8, column: 10 },
593 },
594 },
595 {
596 type: "Punctuator",
597 value: "(",
598 range: [114, 115],
599 loc: {
600 start: { line: 8, column: 11 },
601 end: { line: 8, column: 12 },
602 },
603 },
604 {
605 type: "Punctuator",
606 value: ")",
607 range: [115, 116],
608 loc: {
609 start: { line: 8, column: 12 },
610 end: { line: 8, column: 13 },
611 },
612 },
613 {
614 type: "Punctuator",
615 value: "=>",
616 range: [117, 119],
617 loc: {
618 start: { line: 8, column: 14 },
619 end: { line: 8, column: 16 },
620 },
621 },
622 {
623 type: "Punctuator",
624 value: "{",
625 range: [120, 121],
626 loc: {
627 start: { line: 8, column: 17 },
628 end: { line: 8, column: 18 },
629 },
630 },
631 {
632 type: "Punctuator",
633 value: "}",
634 range: [121, 122],
635 loc: {
636 start: { line: 8, column: 18 },
637 end: { line: 8, column: 19 },
638 },
639 },
640 {
641 type: "Punctuator",
642 value: ")",
643 range: [122, 123],
644 loc: {
645 start: { line: 8, column: 19 },
646 end: { line: 8, column: 20 },
647 },
648 },
649 {
650 type: "Punctuator",
651 value: ";",
652 range: [123, 124],
653 loc: {
654 start: { line: 8, column: 20 },
655 end: { line: 8, column: 21 },
656 },
657 },
658 ],
659 comments: [],
660 });