File tree 3 files changed +64
-6
lines changed 3 files changed +64
-6
lines changed Original file line number Diff line number Diff line change @@ -1371,6 +1371,13 @@ function quux(foo) {
1371
1371
1372
1372
}
1373
1373
1374
+ /**
1375
+ * @param {Promise} foo - Bar.
1376
+ */
1377
+ function quux (foo ) {
1378
+
1379
+ }
1380
+
1374
1381
class MyClass {}
1375
1382
1376
1383
/**
@@ -1391,6 +1398,15 @@ const MyType = require('my-library').MyType;
1391
1398
1392
1399
}
1393
1400
1401
+ const MyType = require (' my-library' ).MyType ;
1402
+
1403
+ /**
1404
+ * @param {MyType} foo - Bar.
1405
+ */
1406
+ function quux (foo ) {
1407
+
1408
+ }
1409
+
1394
1410
import {MyType } from ' my-library' ;
1395
1411
1396
1412
/**
@@ -1402,7 +1418,7 @@ import {MyType} from 'my-library';
1402
1418
1403
1419
}
1404
1420
1405
- /* global MyType*/
1421
+ /* globals MyType*/
1406
1422
1407
1423
/**
1408
1424
* @param {MyType} foo - Bar.
Original file line number Diff line number Diff line change @@ -51,9 +51,20 @@ export default iterateJsdoc(({
51
51
} )
52
52
53
53
// If the file is a module, concat the variables from the module scope.
54
- . concat ( scopeManager . isModule ( ) ? globalScope . childScopes [ 0 ] . variables . map ( ( variable ) => {
55
- return variable . name ;
56
- } ) : [ ] )
54
+ . concat (
55
+
56
+ // This covers `commonjs` as well as `node`
57
+ scopeManager . __options . nodejsScope ||
58
+ scopeManager . isModule ( ) ?
59
+ globalScope . childScopes . reduce ( ( arr , { variables} ) => {
60
+ // Flatten
61
+ arr . push ( ...variables ) ;
62
+
63
+ return arr ;
64
+ } , [ ] ) . map ( ( { name} ) => {
65
+ return name ;
66
+ } ) : [ ]
67
+ )
57
68
. concat ( extraTypes )
58
69
. concat ( typedefDeclarations ) ;
59
70
Original file line number Diff line number Diff line change @@ -31,6 +31,19 @@ export default {
31
31
}
32
32
`
33
33
} ,
34
+ {
35
+ code : `
36
+ /**
37
+ * @param {Promise} foo - Bar.
38
+ */
39
+ function quux(foo) {
40
+
41
+ }
42
+ ` ,
43
+ env : {
44
+ es6 : true
45
+ }
46
+ } ,
34
47
{
35
48
code : `
36
49
class MyClass {}
@@ -58,7 +71,25 @@ export default {
58
71
function quux(foo) {
59
72
60
73
}
61
- `
74
+ ` ,
75
+ env : {
76
+ node : true
77
+ }
78
+ } ,
79
+ {
80
+ code : `
81
+ const MyType = require('my-library').MyType;
82
+
83
+ /**
84
+ * @param {MyType} foo - Bar.
85
+ */
86
+ function quux(foo) {
87
+
88
+ }
89
+ ` ,
90
+ env : {
91
+ node : false
92
+ }
62
93
} ,
63
94
{
64
95
code : `
@@ -79,7 +110,7 @@ export default {
79
110
} ,
80
111
{
81
112
code : `
82
- /*global MyType*/
113
+ /*globals MyType*/
83
114
84
115
/**
85
116
* @param {MyType} foo - Bar.
You can’t perform that action at this time.
0 commit comments