File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -633,3 +633,37 @@ test('inferMembership - export', function() {
633
633
scope : 'instance'
634
634
} ) ;
635
635
} ) ;
636
+
637
+ test ( 'inferMembership - flow interface' , function ( ) {
638
+ expect (
639
+ pick (
640
+ evaluate ( `
641
+ interface Foo {
642
+ /** Test */
643
+ bar: number
644
+ }
645
+ ` ) [ 0 ] ,
646
+ [ 'memberof' , 'scope' ]
647
+ )
648
+ ) . toEqual ( {
649
+ memberof : 'Foo' ,
650
+ scope : 'instance'
651
+ } ) ;
652
+ } ) ;
653
+
654
+ test ( 'inferMembership - flow object type alias' , function ( ) {
655
+ expect (
656
+ pick (
657
+ evaluate ( `
658
+ type Foo = {
659
+ /** Test */
660
+ bar: number
661
+ }
662
+ ` ) [ 0 ] ,
663
+ [ 'memberof' , 'scope' ]
664
+ )
665
+ ) . toEqual ( {
666
+ memberof : 'Foo' ,
667
+ scope : 'instance'
668
+ } ) ;
669
+ } ) ;
Original file line number Diff line number Diff line change @@ -397,6 +397,21 @@ module.exports = function() {
397
397
}
398
398
}
399
399
400
+ // type Foo = { bar: T }
401
+ // interface Foo { bar: T }
402
+ if (
403
+ path . isObjectTypeProperty ( ) &&
404
+ path . parentPath . isObjectTypeAnnotation ( ) &&
405
+ ( path . parentPath . parentPath . isTypeAlias ( ) ||
406
+ path . parentPath . parentPath . isInterfaceDeclaration ( ) )
407
+ ) {
408
+ return inferMembershipFromIdentifiers (
409
+ comment ,
410
+ [ path . parentPath . parentPath . get ( 'id' ) . node . name ] ,
411
+ 'instance'
412
+ ) ;
413
+ }
414
+
400
415
return comment ;
401
416
} ;
402
417
} ;
You can’t perform that action at this time.
0 commit comments