@@ -273,6 +273,32 @@ new Accumulator().accumulate(() => 1);
273
273
} ,
274
274
] ,
275
275
} ,
276
+ {
277
+ filename : 'test.ts' ,
278
+ code : `
279
+ declare function foo(arg: { meth: () => number }): void
280
+ foo({
281
+ meth() {
282
+ return 1;
283
+ },
284
+ })
285
+ foo({
286
+ meth: function () {
287
+ return 1;
288
+ },
289
+ })
290
+ foo({
291
+ meth: () => {
292
+ return 1;
293
+ },
294
+ })
295
+ ` ,
296
+ options : [
297
+ {
298
+ allowTypedFunctionExpressions : true ,
299
+ } ,
300
+ ] ,
301
+ } ,
276
302
] ,
277
303
invalid : [
278
304
{
@@ -281,7 +307,7 @@ new Accumulator().accumulate(() => 1);
281
307
function test() {
282
308
return;
283
309
}
284
- ` ,
310
+ ` ,
285
311
errors : [
286
312
{
287
313
messageId : 'missingReturnType' ,
@@ -296,7 +322,7 @@ function test() {
296
322
var fn = function() {
297
323
return 1;
298
324
};
299
- ` ,
325
+ ` ,
300
326
errors : [
301
327
{
302
328
messageId : 'missingReturnType' ,
@@ -309,7 +335,7 @@ var fn = function() {
309
335
filename : 'test.ts' ,
310
336
code : `
311
337
var arrowFn = () => 'test';
312
- ` ,
338
+ ` ,
313
339
errors : [
314
340
{
315
341
messageId : 'missingReturnType' ,
@@ -332,7 +358,7 @@ class Test {
332
358
}
333
359
arrow = () => 'arrow';
334
360
}
335
- ` ,
361
+ ` ,
336
362
errors : [
337
363
{
338
364
messageId : 'missingReturnType' ,
@@ -353,21 +379,23 @@ class Test {
353
379
} ,
354
380
{
355
381
filename : 'test.ts' ,
356
- code : `function test() {
357
- return;
358
- }` ,
382
+ code : `
383
+ function test() {
384
+ return;
385
+ }
386
+ ` ,
359
387
options : [ { allowExpressions : true } ] ,
360
388
errors : [
361
389
{
362
390
messageId : 'missingReturnType' ,
363
- line : 1 ,
391
+ line : 2 ,
364
392
column : 1 ,
365
393
} ,
366
394
] ,
367
395
} ,
368
396
{
369
397
filename : 'test.ts' ,
370
- code : ` const foo = () => {};` ,
398
+ code : ' const foo = () => {};' ,
371
399
options : [ { allowExpressions : true } ] ,
372
400
errors : [
373
401
{
@@ -379,7 +407,7 @@ class Test {
379
407
} ,
380
408
{
381
409
filename : 'test.ts' ,
382
- code : ` const foo = function() {};` ,
410
+ code : ' const foo = function() {};' ,
383
411
options : [ { allowExpressions : true } ] ,
384
412
errors : [
385
413
{
@@ -391,7 +419,7 @@ class Test {
391
419
} ,
392
420
{
393
421
filename : 'test.ts' ,
394
- code : ` var arrowFn = () => 'test';` ,
422
+ code : " var arrowFn = () => 'test';" ,
395
423
options : [ { allowTypedFunctionExpressions : true } ] ,
396
424
errors : [
397
425
{
@@ -403,7 +431,7 @@ class Test {
403
431
} ,
404
432
{
405
433
filename : 'test.ts' ,
406
- code : ` var funcExpr = function() { return 'test'; };` ,
434
+ code : " var funcExpr = function() { return 'test'; };" ,
407
435
options : [ { allowTypedFunctionExpressions : true } ] ,
408
436
errors : [
409
437
{
@@ -416,7 +444,7 @@ class Test {
416
444
417
445
{
418
446
filename : 'test.ts' ,
419
- code : ` const x = (() => {}) as Foo` ,
447
+ code : ' const x = (() => {}) as Foo' ,
420
448
options : [ { allowTypedFunctionExpressions : false } ] ,
421
449
errors : [
422
450
{
@@ -459,84 +487,72 @@ const x: Foo = {
459
487
} ,
460
488
{
461
489
filename : 'test.ts' ,
462
- code : `
463
- () => () => {};
464
- ` ,
490
+ code : '() => () => {};' ,
465
491
options : [ { allowHigherOrderFunctions : true } ] ,
466
492
errors : [
467
493
{
468
494
messageId : 'missingReturnType' ,
469
- line : 2 ,
495
+ line : 1 ,
470
496
column : 7 ,
471
497
} ,
472
498
] ,
473
499
} ,
474
500
{
475
501
filename : 'test.ts' ,
476
- code : `
477
- () => function () {};
478
- ` ,
502
+ code : '() => function () {};' ,
479
503
options : [ { allowHigherOrderFunctions : true } ] ,
480
504
errors : [
481
505
{
482
506
messageId : 'missingReturnType' ,
483
- line : 2 ,
507
+ line : 1 ,
484
508
column : 7 ,
485
509
} ,
486
510
] ,
487
511
} ,
488
512
{
489
513
filename : 'test.ts' ,
490
- code : `
491
- () => { return () => {} };
492
- ` ,
514
+ code : '() => { return () => {} };' ,
493
515
options : [ { allowHigherOrderFunctions : true } ] ,
494
516
errors : [
495
517
{
496
518
messageId : 'missingReturnType' ,
497
- line : 2 ,
519
+ line : 1 ,
498
520
column : 16 ,
499
521
} ,
500
522
] ,
501
523
} ,
502
524
{
503
525
filename : 'test.ts' ,
504
- code : `
505
- () => { return function () {} };
506
- ` ,
526
+ code : '() => { return function () {} };' ,
507
527
options : [ { allowHigherOrderFunctions : true } ] ,
508
528
errors : [
509
529
{
510
530
messageId : 'missingReturnType' ,
511
- line : 2 ,
531
+ line : 1 ,
512
532
column : 16 ,
513
533
} ,
514
534
] ,
515
535
} ,
516
536
{
517
537
filename : 'test.ts' ,
518
- code : `
519
- function fn() { return () => {} };
520
- ` ,
538
+ code : 'function fn() { return () => {} };' ,
521
539
options : [ { allowHigherOrderFunctions : true } ] ,
522
540
errors : [
523
541
{
524
542
messageId : 'missingReturnType' ,
525
- line : 2 ,
543
+ line : 1 ,
526
544
column : 24 ,
527
545
} ,
528
546
] ,
529
547
} ,
530
548
{
531
549
filename : 'test.ts' ,
532
- code : `
533
- function fn() { return function () {} };
534
- ` ,
550
+ code : 'function fn() { return function () {} };' ,
535
551
options : [ { allowHigherOrderFunctions : true } ] ,
536
552
errors : [
537
553
{
538
554
messageId : 'missingReturnType' ,
539
- line : 2 ,
555
+ line : 1 ,
540
556
column : 24 ,
541
557
} ,
542
558
] ,
@@ -566,14 +582,12 @@ function FunctionDeclaration() {
566
582
} ,
567
583
{
568
584
filename : 'test.ts' ,
569
- code : `
570
- () => () => { return () => { return; } };
571
- ` ,
585
+ code : '() => () => { return () => { return; } };' ,
572
586
options : [ { allowHigherOrderFunctions : true } ] ,
573
587
errors : [
574
588
{
575
589
messageId : 'missingReturnType' ,
576
- line : 2 ,
590
+ line : 1 ,
577
591
column : 22 ,
578
592
} ,
579
593
] ,
@@ -643,10 +657,41 @@ new Accumulator().accumulate(() => 1);
643
657
} ,
644
658
] ,
645
659
} ,
660
+ {
661
+ filename : 'test.ts' ,
662
+ code : '(() => true)()' ,
663
+ options : [
664
+ {
665
+ allowTypedFunctionExpressions : false ,
666
+ } ,
667
+ ] ,
668
+ errors : [
669
+ {
670
+ messageId : 'missingReturnType' ,
671
+ line : 1 ,
672
+ column : 2 ,
673
+ } ,
674
+ ] ,
675
+ } ,
646
676
{
647
677
filename : 'test.ts' ,
648
678
code : `
649
- (() => true)()
679
+ declare function foo(arg: { meth: () => number }): void
680
+ foo({
681
+ meth() {
682
+ return 1;
683
+ },
684
+ })
685
+ foo({
686
+ meth: function () {
687
+ return 1;
688
+ },
689
+ })
690
+ foo({
691
+ meth: () => {
692
+ return 1;
693
+ },
694
+ })
650
695
` ,
651
696
options : [
652
697
{
@@ -656,8 +701,18 @@ new Accumulator().accumulate(() => 1);
656
701
errors : [
657
702
{
658
703
messageId : 'missingReturnType' ,
659
- line : 2 ,
660
- column : 2 ,
704
+ line : 4 ,
705
+ column : 7 ,
706
+ } ,
707
+ {
708
+ messageId : 'missingReturnType' ,
709
+ line : 9 ,
710
+ column : 9 ,
711
+ } ,
712
+ {
713
+ messageId : 'missingReturnType' ,
714
+ line : 14 ,
715
+ column : 9 ,
661
716
} ,
662
717
] ,
663
718
} ,
0 commit comments