File tree Expand file tree Collapse file tree 2 files changed +59
-8
lines changed Expand file tree Collapse file tree 2 files changed +59
-8
lines changed Original file line number Diff line number Diff line change @@ -22,15 +22,17 @@ The following patterns are considered problems:
2222
2323```` ts 
2424/** 
25-  * @param  {Function}  abc  
25+  * @param  {Function}  fooBar  
2626 */  
27- function  quux () {}
27+ function  quux (fooBar ) {
28+   console .log (fooBar (3 ));
29+ }
2830//  Message: Prefer a more specific type to `Function`
2931
3032/** 
3133 * @param  {string|Array<Function>}  abc  
3234 */  
33- function  quux ( ) {}
35+ function  buzz ( abc ) {}
3436//  Message: Prefer a more specific type to `Function`
3537```` 
3638
@@ -46,6 +48,28 @@ The following patterns are not considered problems:
4648/** 
4749 * @param  {SomeType}  abc  
4850 */  
49- function  quux () {}
51+ function  quux (abc ) {}
52+ 
53+ //  To avoid referencing a generic Function, define a callback
54+ //    with its inputs/outputs and a name.
55+ /** 
56+  * @callback           FOOBAR  
57+  * @param     {number}  baz  
58+  * @return    {number}  
59+  */  
60+ 
61+ 
62+ //  Then reference the callback name as the type.
63+ /** 
64+  * @param  {FOOBAR}  fooBar  
65+  */  
66+ function  quux (fooBar ) {
67+   console .log (fooBar (3 ));
68+ }
69+ 
70+ /** 
71+  * @param  {string|Array<FOOBAR>}  abc  
72+  */  
73+ function  buzz (abc ) {}
5074```` 
5175
Original file line number Diff line number Diff line change @@ -3,9 +3,11 @@ export default {
33    { 
44      code : ` 
55        /** 
6-          * @param {Function} abc  
6+          * @param {Function} fooBar  
77         */ 
8-         function quux () {} 
8+         function quux (fooBar) { 
9+           console.log(fooBar(3)); 
10+         } 
911      ` , 
1012      errors : [ 
1113        { 
@@ -19,7 +21,7 @@ export default {
1921        /** 
2022         * @param {string|Array<Function>} abc 
2123         */ 
22-         function quux ( ) {} 
24+         function buzz (abc ) {} 
2325      ` , 
2426      errors : [ 
2527        { 
@@ -35,7 +37,32 @@ export default {
3537        /** 
3638         * @param {SomeType} abc 
3739         */ 
38-         function quux () {} 
40+         function quux (abc) {} 
41+       ` , 
42+     } , 
43+     { 
44+       code : ` 
45+         // To avoid referencing a generic Function, define a callback 
46+         //   with its inputs/outputs and a name. 
47+         /** 
48+          * @callback          FOOBAR 
49+          * @param    {number} baz 
50+          * @return   {number} 
51+          */ 
52+ 
53+ 
54+         // Then reference the callback name as the type. 
55+         /** 
56+          * @param {FOOBAR} fooBar 
57+          */ 
58+         function quux (fooBar) { 
59+           console.log(fooBar(3)); 
60+         } 
61+ 
62+         /** 
63+          * @param {string|Array<FOOBAR>} abc 
64+          */ 
65+         function buzz (abc) {} 
3966      ` , 
4067    } , 
4168  ] , 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments