eslint-plugin-jsdoc 43.1.0 → 43.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/README.md +58 -24372
  2. package/dist/WarnSettings.js.map +1 -1
  3. package/dist/alignTransform.js.map +1 -1
  4. package/dist/bin/generateRule.js.map +1 -1
  5. package/dist/exportParser.js.map +1 -1
  6. package/dist/generateRule.js.map +1 -1
  7. package/dist/iterateJsdoc.js +4 -4
  8. package/dist/iterateJsdoc.js.map +1 -1
  9. package/dist/jsdocUtils.js.map +1 -1
  10. package/dist/rules/checkAccess.js.map +1 -1
  11. package/dist/rules/checkExamples.js.map +1 -1
  12. package/dist/rules/checkLineAlignment.js.map +1 -1
  13. package/dist/rules/checkParamNames.js.map +1 -1
  14. package/dist/rules/checkPropertyNames.js.map +1 -1
  15. package/dist/rules/checkTagNames.js.map +1 -1
  16. package/dist/rules/checkTypes.js.map +1 -1
  17. package/dist/rules/checkValues.js.map +1 -1
  18. package/dist/rules/emptyTags.js.map +1 -1
  19. package/dist/rules/implementsOnClasses.js.map +1 -1
  20. package/dist/rules/informativeDocs.js.map +1 -1
  21. package/dist/rules/matchDescription.js.map +1 -1
  22. package/dist/rules/matchName.js.map +1 -1
  23. package/dist/rules/multilineBlocks.js.map +1 -1
  24. package/dist/rules/noBadBlocks.js.map +1 -1
  25. package/dist/rules/noBlankBlockDescriptions.js.map +1 -1
  26. package/dist/rules/noBlankBlocks.js.map +1 -1
  27. package/dist/rules/noDefaults.js.map +1 -1
  28. package/dist/rules/noMultiAsterisks.js.map +1 -1
  29. package/dist/rules/noTypes.js.map +1 -1
  30. package/dist/rules/noUndefinedTypes.js.map +1 -1
  31. package/dist/rules/requireDescription.js.map +1 -1
  32. package/dist/rules/requireDescriptionCompleteSentence.js.map +1 -1
  33. package/dist/rules/requireExample.js.map +1 -1
  34. package/dist/rules/requireFileOverview.js.map +1 -1
  35. package/dist/rules/requireHyphenBeforeParamDescription.js.map +1 -1
  36. package/dist/rules/requireJsdoc.js.map +1 -1
  37. package/dist/rules/requireParam.js.map +1 -1
  38. package/dist/rules/requireParamDescription.js.map +1 -1
  39. package/dist/rules/requireParamName.js.map +1 -1
  40. package/dist/rules/requireParamType.js.map +1 -1
  41. package/dist/rules/requirePropertyDescription.js.map +1 -1
  42. package/dist/rules/requirePropertyName.js.map +1 -1
  43. package/dist/rules/requirePropertyType.js.map +1 -1
  44. package/dist/rules/requireReturns.js.map +1 -1
  45. package/dist/rules/requireReturnsCheck.js.map +1 -1
  46. package/dist/rules/requireReturnsDescription.js.map +1 -1
  47. package/dist/rules/requireThrows.js.map +1 -1
  48. package/dist/rules/requireYields.js.map +1 -1
  49. package/dist/rules/requireYieldsCheck.js.map +1 -1
  50. package/dist/rules/sortTags.js.map +1 -1
  51. package/dist/rules/tagLines.js.map +1 -1
  52. package/dist/rules/textEscaping.js.map +1 -1
  53. package/dist/rules/validTypes.js.map +1 -1
  54. package/dist/utils/hasReturnValue.js.map +1 -1
  55. package/docs/advanced.md +102 -0
  56. package/docs/rules/check-access.md +193 -0
  57. package/docs/rules/check-alignment.md +169 -0
  58. package/docs/rules/check-examples.md +784 -0
  59. package/docs/rules/check-indentation.md +296 -0
  60. package/docs/rules/check-line-alignment.md +995 -0
  61. package/docs/rules/check-param-names.md +1035 -0
  62. package/docs/rules/check-property-names.md +244 -0
  63. package/docs/rules/check-syntax.md +80 -0
  64. package/docs/rules/check-tag-names.md +1116 -0
  65. package/docs/rules/check-types.md +1197 -0
  66. package/docs/rules/check-values.md +409 -0
  67. package/docs/rules/empty-tags.md +220 -0
  68. package/docs/rules/implements-on-classes.md +219 -0
  69. package/docs/rules/informative-docs.md +400 -0
  70. package/docs/rules/match-description.md +979 -0
  71. package/docs/rules/match-name.md +243 -0
  72. package/docs/rules/multiline-blocks.md +398 -0
  73. package/docs/rules/no-bad-blocks.md +174 -0
  74. package/docs/rules/no-blank-block-descriptions.md +91 -0
  75. package/docs/rules/no-blank-blocks.md +98 -0
  76. package/docs/rules/no-defaults.md +207 -0
  77. package/docs/rules/no-missing-syntax.md +269 -0
  78. package/docs/rules/no-multi-asterisks.md +278 -0
  79. package/docs/rules/no-restricted-syntax.md +377 -0
  80. package/docs/rules/no-types.md +168 -0
  81. package/docs/rules/no-undefined-types.md +730 -0
  82. package/docs/rules/require-asterisk-prefix.md +297 -0
  83. package/docs/rules/require-description-complete-sentence.md +584 -0
  84. package/docs/rules/require-description.md +820 -0
  85. package/docs/rules/require-example.md +390 -0
  86. package/docs/rules/require-file-overview.md +317 -0
  87. package/docs/rules/require-hyphen-before-param-description.md +258 -0
  88. package/docs/rules/require-jsdoc.md +1837 -0
  89. package/docs/rules/require-param-description.md +1816 -0
  90. package/docs/rules/require-param-name.md +238 -0
  91. package/docs/rules/require-param-type.md +163 -0
  92. package/docs/rules/require-param.md +227 -0
  93. package/docs/rules/require-property-description.md +128 -0
  94. package/docs/rules/require-property-name.md +88 -0
  95. package/docs/rules/require-property-type.md +79 -0
  96. package/docs/rules/require-property.md +79 -0
  97. package/docs/rules/require-returns-check.md +1164 -0
  98. package/docs/rules/require-returns-description.md +1053 -0
  99. package/docs/rules/require-returns-type.md +181 -0
  100. package/docs/rules/require-returns.md +144 -0
  101. package/docs/rules/require-throws.md +326 -0
  102. package/docs/rules/require-yields-check.md +823 -0
  103. package/docs/rules/require-yields.md +544 -0
  104. package/docs/rules/sort-tags.md +635 -0
  105. package/docs/rules/tag-lines.md +551 -0
  106. package/docs/rules/text-escaping.md +177 -0
  107. package/docs/rules/valid-types.md +833 -0
  108. package/docs/settings.md +355 -0
  109. package/package.json +15 -15
@@ -0,0 +1,730 @@
1
+ <a name="user-content-no-undefined-types"></a>
2
+ <a name="no-undefined-types"></a>
3
+ # <code>no-undefined-types</code>
4
+
5
+ * [Options](#user-content-no-undefined-types-options)
6
+ * [Context and settings](#user-content-no-undefined-types-context-and-settings)
7
+ * [Failing examples](#user-content-no-undefined-types-failing-examples)
8
+ * [Passing examples](#user-content-no-undefined-types-passing-examples)
9
+
10
+
11
+ Checks that types in jsdoc comments are defined. This can be used to check
12
+ unimported types.
13
+
14
+ When enabling this rule, types in jsdoc comments will resolve as used
15
+ variables, i.e. will not be marked as unused by `no-unused-vars`.
16
+
17
+ In addition to considering globals found in code (or in ESLint-indicated
18
+ `globals`) as defined, the following tags will also be checked for
19
+ name(path) definitions to also serve as a potential "type" for checking
20
+ the tag types in the table below:
21
+
22
+ `@callback`, `@class` (or `@constructor`), `@constant` (or `@const`),
23
+ `@event`, `@external` (or `@host`), `@function` (or `@func` or `@method`),
24
+ `@interface`, `@member` (or `@var`), `@mixin`, `@name`, `@namespace`,
25
+ `@template` (for "closure" or "typescript" `settings.jsdoc.mode` only),
26
+ `@typedef`.
27
+
28
+ The following tags will also be checked but only when the mode is `closure`:
29
+
30
+ `@package`, `@private`, `@protected`, `@public`, `@static`
31
+
32
+ The following types are always considered defined.
33
+
34
+ - `null`, `undefined`, `void`, `string`, `boolean`, `object`,
35
+ `function`, `symbol`
36
+ - `number`, `bigint`, `NaN`, `Infinity`
37
+ - `any`, `*`, `never`, `unknown`, `const`
38
+ - `this`, `true`, `false`
39
+ - `Array`, `Object`, `RegExp`, `Date`, `Function`
40
+
41
+ Note that preferred types indicated within `settings.jsdoc.preferredTypes` will
42
+ also be assumed to be defined.
43
+
44
+ Also note that if there is an error [parsing](https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser)
45
+ types for a tag, the function will silently ignore that tag, leaving it to
46
+ the `valid-types` rule to report parsing errors.
47
+
48
+ If you define your own tags, you can use `settings.jsdoc.structuredTags`
49
+ to indicate that a tag's `name` is "namepath-defining" (and should prevent
50
+ reporting on use of that namepath elsewhere) and/or that a tag's `type` is
51
+ `false` (and should not be checked for types). If the `type` is an array, that
52
+ array's items will be considered as defined for the purposes of that tag.
53
+
54
+ <a name="user-content-no-undefined-types-options"></a>
55
+ <a name="no-undefined-types-options"></a>
56
+ ## Options
57
+
58
+ An option object may have the following key:
59
+
60
+ - `definedTypes` - This array can be populated to indicate other types which
61
+ are automatically considered as defined (in addition to globals, etc.).
62
+ Defaults to an empty array.
63
+
64
+ <a name="user-content-no-undefined-types-context-and-settings"></a>
65
+ <a name="no-undefined-types-context-and-settings"></a>
66
+ ## Context and settings
67
+
68
+ |||
69
+ |---|---|
70
+ |Context|everywhere|
71
+ |Tags|`augments`, `class`, `constant`, `enum`, `implements`, `member`, `module`, `namespace`, `param`, `property`, `returns`, `throws`, `type`, `typedef`, `yields`|
72
+ |Aliases|`constructor`, `const`, `extends`, `var`, `arg`, `argument`, `prop`, `return`, `exception`, `yield`|
73
+ |Closure-only|`package`, `private`, `protected`, `public`, `static`|
74
+ |Recommended|true|
75
+ |Options|`definedTypes`|
76
+ |Settings|`preferredTypes`, `mode`, `structuredTags`|
77
+
78
+
79
+ <a name="user-content-no-undefined-types-failing-examples"></a>
80
+ <a name="no-undefined-types-failing-examples"></a>
81
+ ## Failing examples
82
+
83
+ The following patterns are considered problems:
84
+
85
+ ````js
86
+ /**
87
+ * @param {HerType} baz - Foo.
88
+ */
89
+ function quux(foo, bar, baz) {
90
+
91
+ }
92
+ // Settings: {"jsdoc":{"preferredTypes":{"HerType":1000}}}
93
+ // Message: Invalid `settings.jsdoc.preferredTypes`. Values must be falsy, a string, or an object.
94
+
95
+ /**
96
+ * @param {HerType} baz - Foo.
97
+ */
98
+ function quux(foo, bar, baz) {
99
+
100
+ }
101
+ // Settings: {"jsdoc":{"preferredTypes":{"HerType":false}}}
102
+ // Message: The type 'HerType' is undefined.
103
+
104
+ /**
105
+ * @param {strnig} foo - Bar.
106
+ */
107
+ function quux(foo) {
108
+
109
+ }
110
+ // Message: The type 'strnig' is undefined.
111
+
112
+ /**
113
+ * @param {MyType} foo - Bar.
114
+ * @param {HisType} bar - Foo.
115
+ */
116
+ function quux(foo, bar) {
117
+
118
+ }
119
+ // "jsdoc/no-undefined-types": ["error"|"warn", {"definedTypes":["MyType"]}]
120
+ // Message: The type 'HisType' is undefined.
121
+
122
+ /**
123
+ * @param {MyType} foo - Bar.
124
+ * @param {HisType} bar - Foo.
125
+ * @param {HerType} baz - Foo.
126
+ */
127
+ function quux(foo, bar, baz) {
128
+
129
+ }
130
+ // Settings: {"jsdoc":{"preferredTypes":{"hertype":{"replacement":"HerType"}}}}
131
+ // "jsdoc/no-undefined-types": ["error"|"warn", {"definedTypes":["MyType"]}]
132
+ // Message: The type 'HisType' is undefined.
133
+
134
+ /**
135
+ * @param {MyType} foo - Bar.
136
+ * @param {HisType} bar - Foo.
137
+ * @param {HerType} baz - Foo.
138
+ */
139
+ function quux(foo, bar, baz) {
140
+
141
+ }
142
+ // Settings: {"jsdoc":{"preferredTypes":{"hertype":{"replacement":false},"histype":"HisType"}}}
143
+ // "jsdoc/no-undefined-types": ["error"|"warn", {"definedTypes":["MyType"]}]
144
+ // Message: The type 'HerType' is undefined.
145
+
146
+ /**
147
+ * @template TEMPLATE_TYPE
148
+ * @param {WRONG_TEMPLATE_TYPE} bar
149
+ */
150
+ function foo (bar) {
151
+ };
152
+ // Settings: {"jsdoc":{"mode":"closure"}}
153
+ // Message: The type 'WRONG_TEMPLATE_TYPE' is undefined.
154
+
155
+ class Foo {
156
+ /**
157
+ * @return {TEMPLATE_TYPE}
158
+ */
159
+ bar () {
160
+ }
161
+ }
162
+ // Message: The type 'TEMPLATE_TYPE' is undefined.
163
+
164
+ class Foo {
165
+ /**
166
+ * @return {TEMPLATE_TYPE}
167
+ */
168
+ invalidTemplateReference () {
169
+ }
170
+ }
171
+
172
+ /**
173
+ * @template TEMPLATE_TYPE
174
+ */
175
+ class Bar {
176
+ /**
177
+ * @return {TEMPLATE_TYPE}
178
+ */
179
+ validTemplateReference () {
180
+ }
181
+ }
182
+ // Settings: {"jsdoc":{"mode":"typescript"}}
183
+ // Message: The type 'TEMPLATE_TYPE' is undefined.
184
+
185
+ /**
186
+ * @type {strnig}
187
+ */
188
+ var quux = {
189
+
190
+ };
191
+ // Message: The type 'strnig' is undefined.
192
+
193
+ /**
194
+ * @template TEMPLATE_TYPE_A, TEMPLATE_TYPE_B
195
+ */
196
+ class Foo {
197
+ /**
198
+ * @param {TEMPLATE_TYPE_A} baz
199
+ * @return {TEMPLATE_TYPE_B}
200
+ */
201
+ bar (baz) {
202
+ }
203
+ }
204
+ // Message: The type 'TEMPLATE_TYPE_A' is undefined.
205
+
206
+ /**
207
+ * @param {...VAR_TYPE} varargs
208
+ */
209
+ function quux (varargs) {
210
+ }
211
+ // Message: The type 'VAR_TYPE' is undefined.
212
+
213
+ /**
214
+ * @this {Navigator}
215
+ */
216
+ function quux () {}
217
+ // Settings: {"jsdoc":{"mode":"closure"}}
218
+ // Message: The type 'Navigator' is undefined.
219
+
220
+ /**
221
+ * @export {SomeType}
222
+ */
223
+ function quux () {}
224
+ // Settings: {"jsdoc":{"mode":"closure"}}
225
+ // Message: The type 'SomeType' is undefined.
226
+
227
+ /**
228
+ * @aCustomTag {SomeType}
229
+ */
230
+ function quux () {}
231
+ // Settings: {"jsdoc":{"structuredTags":{"aCustomTag":{"type":true}}}}
232
+ // Message: The type 'SomeType' is undefined.
233
+
234
+ /**
235
+ * @aCustomTag {SomeType}
236
+ */
237
+ function quux () {}
238
+ // Settings: {"jsdoc":{"structuredTags":{"aCustomTag":{"type":["aType","anotherType"]}}}}
239
+ // Message: The type 'SomeType' is undefined.
240
+
241
+ /**
242
+ * @namepathDefiner SomeType
243
+ */
244
+ /**
245
+ * @type {SomeType}
246
+ */
247
+ // Settings: {"jsdoc":{"structuredTags":{"namepathDefiner":{"name":"namepath-referencing"}}}}
248
+ // Message: The type 'SomeType' is undefined.
249
+
250
+ /**
251
+ * @namepathDefiner SomeType
252
+ */
253
+ /**
254
+ * @type {SomeType}
255
+ */
256
+ // Message: The type 'SomeType' is undefined.
257
+
258
+ /**
259
+ * @template abc TEMPLATE_TYPE
260
+ * @param {TEMPLATE_TYPE} bar
261
+ */
262
+ function foo (bar) {
263
+ };
264
+ // Settings: {"jsdoc":{"mode":"closure"}}
265
+ // Message: The type 'TEMPLATE_TYPE' is undefined.
266
+
267
+ /**
268
+ * @suppress {visibility}
269
+ */
270
+ function foo () {
271
+ }
272
+ // Settings: {"jsdoc":{"mode":"jsdoc"}}
273
+ // Message: The type 'visibility' is undefined.
274
+
275
+ /**
276
+ * @typedef Todo
277
+ * @property description
278
+ * @property otherStuff
279
+ */
280
+ /**
281
+ * @type {Omit<Todo, "description">}
282
+ */
283
+ const a = new Todo();
284
+ // Settings: {"jsdoc":{"mode":"jsdoc"}}
285
+ // Message: The type 'Omit' is undefined.
286
+ ````
287
+
288
+
289
+
290
+ <a name="user-content-no-undefined-types-passing-examples"></a>
291
+ <a name="no-undefined-types-passing-examples"></a>
292
+ ## Passing examples
293
+
294
+ The following patterns are not considered problems:
295
+
296
+ ````js
297
+ /**
298
+ * @param {string} foo - Bar.
299
+ */
300
+ function quux(foo) {
301
+
302
+ }
303
+
304
+ /**
305
+ * @param {Promise} foo - Bar.
306
+ */
307
+ function quux(foo) {
308
+
309
+ }
310
+
311
+ class MyClass {}
312
+
313
+ /**
314
+ * @param {MyClass} foo - Bar.
315
+ */
316
+ function quux(foo) {
317
+ console.log(foo);
318
+ }
319
+
320
+ quux(0);
321
+
322
+ const MyType = require('my-library').MyType;
323
+
324
+ /**
325
+ * @param {MyType} foo - Bar.
326
+ */
327
+ function quux(foo) {
328
+
329
+ }
330
+
331
+ const MyType = require('my-library').MyType;
332
+
333
+ /**
334
+ * @param {MyType} foo - Bar.
335
+ */
336
+ function quux(foo) {
337
+
338
+ }
339
+
340
+ const MyType = require('my-library').MyType;
341
+
342
+ /**
343
+ * @param {MyType} foo - Bar.
344
+ */
345
+ function quux(foo) {
346
+
347
+ }
348
+
349
+ import {MyType} from 'my-library';
350
+
351
+ /**
352
+ * @param {MyType} foo - Bar.
353
+ * @param {object<string, number>} foo
354
+ * @param {Array<string>} baz
355
+ */
356
+ function quux(foo, bar, baz) {
357
+
358
+ }
359
+
360
+ /*globals MyType*/
361
+
362
+ /**
363
+ * @param {MyType} foo - Bar.
364
+ * @param {HisType} bar - Foo.
365
+ */
366
+ function quux(foo, bar) {
367
+
368
+ }
369
+
370
+ /**
371
+ * @typedef {object} hello
372
+ * @property {string} a - a.
373
+ */
374
+
375
+ /**
376
+ * @param {hello} foo
377
+ */
378
+ function quux(foo) {
379
+
380
+ }
381
+
382
+ /**
383
+ * @param {Array<syntaxError} foo
384
+ */
385
+ function quux(foo) {
386
+
387
+ }
388
+
389
+ /**
390
+ * Callback test.
391
+ *
392
+ * @callback addStuffCallback
393
+ * @param {String} sum - An test integer.
394
+ */
395
+ /**
396
+ * Test Eslint.
397
+ *
398
+ * @param {addStuffCallback} callback - A callback to run.
399
+ */
400
+ function testFunction(callback) {
401
+ callback();
402
+ }
403
+
404
+ /**
405
+ *
406
+ *
407
+ */
408
+ function foo () {
409
+
410
+ }
411
+
412
+ /**
413
+ * @param {MyType} foo - Bar.
414
+ * @param {HisType} bar - Foo.
415
+ */
416
+ function quux(foo, bar) {
417
+
418
+ }
419
+ // "jsdoc/no-undefined-types": ["error"|"warn", {"definedTypes":["MyType","HisType"]}]
420
+
421
+ /**
422
+ * @param {MyType} foo - Bar.
423
+ * @param {HisType} bar - Foo.
424
+ * @param {HerType} baz - Foo.
425
+ */
426
+ function quux(foo, bar, baz) {
427
+
428
+ }
429
+ // Settings: {"jsdoc":{"preferredTypes":{"hertype":{"replacement":"HerType"},"histype":"HisType"}}}
430
+ // "jsdoc/no-undefined-types": ["error"|"warn", {"definedTypes":["MyType"]}]
431
+
432
+ /**
433
+ * @param {MyType} foo - Bar.
434
+ * @param {HisType} bar - Foo.
435
+ * @param {HerType} baz - Foo.
436
+ */
437
+ function quux(foo, bar, baz) {
438
+
439
+ }
440
+ // Settings: {"jsdoc":{"preferredTypes":{"hertype":{"replacement":"HerType<>"},"histype":"HisType.<>"}}}
441
+ // "jsdoc/no-undefined-types": ["error"|"warn", {"definedTypes":["MyType"]}]
442
+
443
+ /**
444
+ * @template TEMPLATE_TYPE
445
+ * @param {TEMPLATE_TYPE} bar
446
+ * @return {TEMPLATE_TYPE}
447
+ */
448
+ function foo (bar) {
449
+ };
450
+ // Settings: {"jsdoc":{"mode":"closure"}}
451
+
452
+ /**
453
+ * @template TEMPLATE_TYPE
454
+ */
455
+ class Foo {
456
+ /**
457
+ * @return {TEMPLATE_TYPE}
458
+ */
459
+ bar () {
460
+ }
461
+ }
462
+ // Settings: {"jsdoc":{"mode":"closure"}}
463
+
464
+ /**
465
+ * @template TEMPLATE_TYPE
466
+ */
467
+ class Foo {
468
+ /**
469
+ * @return {TEMPLATE_TYPE}
470
+ */
471
+ bar () {}
472
+
473
+ /**
474
+ * @return {TEMPLATE_TYPE}
475
+ */
476
+ baz () {}
477
+ }
478
+ // Settings: {"jsdoc":{"mode":"closure"}}
479
+
480
+ /**
481
+ * @template TEMPLATE_TYPE_A, TEMPLATE_TYPE_B
482
+ */
483
+ class Foo {
484
+ /**
485
+ * @param {TEMPLATE_TYPE_A} baz
486
+ * @return {TEMPLATE_TYPE_B}
487
+ */
488
+ bar (baz) {
489
+ }
490
+ }
491
+ // Settings: {"jsdoc":{"mode":"closure"}}
492
+
493
+ /**
494
+ * @template TEMPLATE_TYPE_A, TEMPLATE_TYPE_B - Some description
495
+ */
496
+ class Foo {
497
+ /**
498
+ * @param {TEMPLATE_TYPE_A} baz
499
+ * @return {TEMPLATE_TYPE_B}
500
+ */
501
+ bar (baz) {
502
+ }
503
+ }
504
+ // Settings: {"jsdoc":{"mode":"closure"}}
505
+
506
+ /****/
507
+
508
+ /* */
509
+
510
+ /*** */
511
+
512
+ /**
513
+ *
514
+ */
515
+ function quux () {
516
+
517
+ }
518
+
519
+ /**
520
+ * @typedef {object} BaseObject
521
+ */
522
+ /**
523
+ * Run callback when hooked method is called.
524
+ *
525
+ * @template {BaseObject} T
526
+ * @param {T} obj - object whose method should be hooked.
527
+ * @param {string} method - method which should be hooked.
528
+ * @param {(sender: T) => void} callback - callback which should
529
+ * be called when the hooked method was invoked.
530
+ */
531
+ function registerEvent(obj, method, callback) {
532
+
533
+ }
534
+ // Settings: {"jsdoc":{"mode":"typescript"}}
535
+
536
+ /**
537
+ * @param {...} varargs
538
+ */
539
+ function quux (varargs) {
540
+ }
541
+
542
+ /**
543
+ * @param {...number} varargs
544
+ */
545
+ function quux (varargs) {
546
+ }
547
+
548
+ class Navigator {}
549
+ /**
550
+ * @this {Navigator}
551
+ */
552
+ function quux () {}
553
+ // Settings: {"jsdoc":{"mode":"closure"}}
554
+
555
+ class SomeType {}
556
+ /**
557
+ * @export {SomeType}
558
+ */
559
+ function quux () {}
560
+ // Settings: {"jsdoc":{"mode":"closure"}}
561
+
562
+ /**
563
+ * @template T
564
+ * @param {T} arg
565
+ */
566
+ function example(arg) {
567
+
568
+ /** @param {T} */
569
+ function inner(x) {
570
+ }
571
+ }
572
+ // Settings: {"jsdoc":{"mode":"closure"}}
573
+
574
+ const init = () => {
575
+ /**
576
+ * Makes request
577
+ * @returns {Promise}
578
+ */
579
+ function request() {
580
+ return Promise.resolve('success');
581
+ }
582
+ };
583
+
584
+ /** Gets a Promise resolved with a given value.
585
+ *
586
+ * @template ValueType
587
+ * @param {ValueType} value Value to resolve.
588
+ * @returns {Promise<ValueType>} Promise resolved with value.
589
+ */
590
+ exports.resolve1 = function resolve1(value) {
591
+ return Promise.resolve(value);
592
+ };
593
+ // Settings: {"jsdoc":{"mode":"typescript"}}
594
+
595
+ /**
596
+ * A function returning the same type as its argument.
597
+ *
598
+ * @template ValueType
599
+ * @typedef {ValueType} ValueFunc
600
+ */
601
+ // Settings: {"jsdoc":{"mode":"typescript"}}
602
+
603
+ /**
604
+ * @aCustomTag {SomeType}
605
+ */
606
+ function quux () {}
607
+ // Settings: {"jsdoc":{"structuredTags":{"aCustomTag":{"type":false}}}}
608
+
609
+ /**
610
+ * @aCustomTag {SomeType}
611
+ */
612
+ function quux () {}
613
+ // Settings: {"jsdoc":{"structuredTags":{"aCustomTag":{"type":["aType","SomeType"]}}}}
614
+
615
+ /**
616
+ * @namepathDefiner SomeType
617
+ */
618
+ /**
619
+ * @type {SomeType}
620
+ */
621
+ // Settings: {"jsdoc":{"structuredTags":{"namepathDefiner":{"name":"namepath-defining"}}}}
622
+
623
+ class Test {
624
+ /**
625
+ * Method.
626
+ *
627
+ * @returns {this} Return description.
628
+ */
629
+ method (): this {
630
+ return this;
631
+ }
632
+ }
633
+
634
+ /**
635
+ * Bad types ignored here and handled instead by `valid-types`.
636
+ * @param {string(} foo - Bar.
637
+ */
638
+ function quux(foo) {
639
+
640
+ }
641
+
642
+ /**
643
+ * @template T
644
+ * @param {T} arg
645
+ * @returns {[T]}
646
+ */
647
+ function genericFunctionExample(arg) {
648
+ const result = /** @type {[T]} */ (new Array());
649
+ result[0] = arg;
650
+ return result;
651
+ }
652
+ // Settings: {"jsdoc":{"mode":"closure"}}
653
+
654
+ /** @typedef QDigestNode */
655
+ class A {
656
+ /**
657
+ * @template {object} T
658
+ * @param {(node: QDigestNode) => T} callback
659
+ * @returns {T[]}
660
+ */
661
+ map(callback) {
662
+ /** @type {T[]} */
663
+ let vals;
664
+ return vals;
665
+ }
666
+ }
667
+ // Settings: {"jsdoc":{"mode":"typescript"}}
668
+
669
+ /**
670
+ * @template T
671
+ * @param {T} arg
672
+ */
673
+ function example(arg) {
674
+
675
+ /** @param {T} */
676
+ function inner(x) {
677
+ }
678
+ }
679
+ // Settings: {"jsdoc":{"mode":"typescript"}}
680
+
681
+ /**
682
+ * @suppress {visibility}
683
+ */
684
+ function foo () {
685
+ }
686
+ // Settings: {"jsdoc":{"mode":"closure"}}
687
+
688
+ /**
689
+ * @template T
690
+ */
691
+ export class Foo {
692
+ // cast to T
693
+ getType() {
694
+ const x = "hello";
695
+ const y = /** @type {T} */ (x);
696
+ return y;
697
+ }
698
+ }
699
+ // Settings: {"jsdoc":{"mode":"typescript"}}
700
+
701
+ /**
702
+ * @type {const}
703
+ */
704
+ const a = 'string';
705
+
706
+ /**
707
+ * @typedef Todo
708
+ * @property description
709
+ * @property otherStuff
710
+ */
711
+ /**
712
+ * @type {Omit<Todo, "description">}
713
+ */
714
+ const a = new Todo();
715
+ // Settings: {"jsdoc":{"mode":"typescript"}}
716
+
717
+ /**
718
+ * @template A, [B=SomeDefault]
719
+ */
720
+ class Foo {
721
+ /**
722
+ * @param {A} baz
723
+ * @return {B}
724
+ */
725
+ bar (baz) {
726
+ }
727
+ }
728
+ // Settings: {"jsdoc":{"mode":"typescript"}}
729
+ ````
730
+