eslint-plugin-jsdoc 43.1.1 → 44.0.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 -24393
  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 +2 -2
  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 +1117 -0
  65. package/docs/rules/check-types.md +1198 -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 +731 -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 +834 -0
  108. package/docs/settings.md +355 -0
  109. package/package.json +15 -15
@@ -0,0 +1,731 @@
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
+ // Settings: {"jsdoc":{"mode":"jsdoc"}}
205
+ // Message: The type 'TEMPLATE_TYPE_A' is undefined.
206
+
207
+ /**
208
+ * @param {...VAR_TYPE} varargs
209
+ */
210
+ function quux (varargs) {
211
+ }
212
+ // Message: The type 'VAR_TYPE' is undefined.
213
+
214
+ /**
215
+ * @this {Navigator}
216
+ */
217
+ function quux () {}
218
+ // Settings: {"jsdoc":{"mode":"closure"}}
219
+ // Message: The type 'Navigator' is undefined.
220
+
221
+ /**
222
+ * @export {SomeType}
223
+ */
224
+ function quux () {}
225
+ // Settings: {"jsdoc":{"mode":"closure"}}
226
+ // Message: The type 'SomeType' is undefined.
227
+
228
+ /**
229
+ * @aCustomTag {SomeType}
230
+ */
231
+ function quux () {}
232
+ // Settings: {"jsdoc":{"structuredTags":{"aCustomTag":{"type":true}}}}
233
+ // Message: The type 'SomeType' is undefined.
234
+
235
+ /**
236
+ * @aCustomTag {SomeType}
237
+ */
238
+ function quux () {}
239
+ // Settings: {"jsdoc":{"structuredTags":{"aCustomTag":{"type":["aType","anotherType"]}}}}
240
+ // Message: The type 'SomeType' is undefined.
241
+
242
+ /**
243
+ * @namepathDefiner SomeType
244
+ */
245
+ /**
246
+ * @type {SomeType}
247
+ */
248
+ // Settings: {"jsdoc":{"structuredTags":{"namepathDefiner":{"name":"namepath-referencing"}}}}
249
+ // Message: The type 'SomeType' is undefined.
250
+
251
+ /**
252
+ * @namepathDefiner SomeType
253
+ */
254
+ /**
255
+ * @type {SomeType}
256
+ */
257
+ // Message: The type 'SomeType' is undefined.
258
+
259
+ /**
260
+ * @template abc TEMPLATE_TYPE
261
+ * @param {TEMPLATE_TYPE} bar
262
+ */
263
+ function foo (bar) {
264
+ };
265
+ // Settings: {"jsdoc":{"mode":"closure"}}
266
+ // Message: The type 'TEMPLATE_TYPE' is undefined.
267
+
268
+ /**
269
+ * @suppress {visibility}
270
+ */
271
+ function foo () {
272
+ }
273
+ // Settings: {"jsdoc":{"mode":"jsdoc"}}
274
+ // Message: The type 'visibility' is undefined.
275
+
276
+ /**
277
+ * @typedef Todo
278
+ * @property description
279
+ * @property otherStuff
280
+ */
281
+ /**
282
+ * @type {Omit<Todo, "description">}
283
+ */
284
+ const a = new Todo();
285
+ // Settings: {"jsdoc":{"mode":"jsdoc"}}
286
+ // Message: The type 'Omit' is undefined.
287
+ ````
288
+
289
+
290
+
291
+ <a name="user-content-no-undefined-types-passing-examples"></a>
292
+ <a name="no-undefined-types-passing-examples"></a>
293
+ ## Passing examples
294
+
295
+ The following patterns are not considered problems:
296
+
297
+ ````js
298
+ /**
299
+ * @param {string} foo - Bar.
300
+ */
301
+ function quux(foo) {
302
+
303
+ }
304
+
305
+ /**
306
+ * @param {Promise} foo - Bar.
307
+ */
308
+ function quux(foo) {
309
+
310
+ }
311
+
312
+ class MyClass {}
313
+
314
+ /**
315
+ * @param {MyClass} foo - Bar.
316
+ */
317
+ function quux(foo) {
318
+ console.log(foo);
319
+ }
320
+
321
+ quux(0);
322
+
323
+ const MyType = require('my-library').MyType;
324
+
325
+ /**
326
+ * @param {MyType} foo - Bar.
327
+ */
328
+ function quux(foo) {
329
+
330
+ }
331
+
332
+ const MyType = require('my-library').MyType;
333
+
334
+ /**
335
+ * @param {MyType} foo - Bar.
336
+ */
337
+ function quux(foo) {
338
+
339
+ }
340
+
341
+ const MyType = require('my-library').MyType;
342
+
343
+ /**
344
+ * @param {MyType} foo - Bar.
345
+ */
346
+ function quux(foo) {
347
+
348
+ }
349
+
350
+ import {MyType} from 'my-library';
351
+
352
+ /**
353
+ * @param {MyType} foo - Bar.
354
+ * @param {object<string, number>} foo
355
+ * @param {Array<string>} baz
356
+ */
357
+ function quux(foo, bar, baz) {
358
+
359
+ }
360
+
361
+ /*globals MyType*/
362
+
363
+ /**
364
+ * @param {MyType} foo - Bar.
365
+ * @param {HisType} bar - Foo.
366
+ */
367
+ function quux(foo, bar) {
368
+
369
+ }
370
+
371
+ /**
372
+ * @typedef {object} hello
373
+ * @property {string} a - a.
374
+ */
375
+
376
+ /**
377
+ * @param {hello} foo
378
+ */
379
+ function quux(foo) {
380
+
381
+ }
382
+
383
+ /**
384
+ * @param {Array<syntaxError} foo
385
+ */
386
+ function quux(foo) {
387
+
388
+ }
389
+
390
+ /**
391
+ * Callback test.
392
+ *
393
+ * @callback addStuffCallback
394
+ * @param {String} sum - An test integer.
395
+ */
396
+ /**
397
+ * Test Eslint.
398
+ *
399
+ * @param {addStuffCallback} callback - A callback to run.
400
+ */
401
+ function testFunction(callback) {
402
+ callback();
403
+ }
404
+
405
+ /**
406
+ *
407
+ *
408
+ */
409
+ function foo () {
410
+
411
+ }
412
+
413
+ /**
414
+ * @param {MyType} foo - Bar.
415
+ * @param {HisType} bar - Foo.
416
+ */
417
+ function quux(foo, bar) {
418
+
419
+ }
420
+ // "jsdoc/no-undefined-types": ["error"|"warn", {"definedTypes":["MyType","HisType"]}]
421
+
422
+ /**
423
+ * @param {MyType} foo - Bar.
424
+ * @param {HisType} bar - Foo.
425
+ * @param {HerType} baz - Foo.
426
+ */
427
+ function quux(foo, bar, baz) {
428
+
429
+ }
430
+ // Settings: {"jsdoc":{"preferredTypes":{"hertype":{"replacement":"HerType"},"histype":"HisType"}}}
431
+ // "jsdoc/no-undefined-types": ["error"|"warn", {"definedTypes":["MyType"]}]
432
+
433
+ /**
434
+ * @param {MyType} foo - Bar.
435
+ * @param {HisType} bar - Foo.
436
+ * @param {HerType} baz - Foo.
437
+ */
438
+ function quux(foo, bar, baz) {
439
+
440
+ }
441
+ // Settings: {"jsdoc":{"preferredTypes":{"hertype":{"replacement":"HerType<>"},"histype":"HisType.<>"}}}
442
+ // "jsdoc/no-undefined-types": ["error"|"warn", {"definedTypes":["MyType"]}]
443
+
444
+ /**
445
+ * @template TEMPLATE_TYPE
446
+ * @param {TEMPLATE_TYPE} bar
447
+ * @return {TEMPLATE_TYPE}
448
+ */
449
+ function foo (bar) {
450
+ };
451
+ // Settings: {"jsdoc":{"mode":"closure"}}
452
+
453
+ /**
454
+ * @template TEMPLATE_TYPE
455
+ */
456
+ class Foo {
457
+ /**
458
+ * @return {TEMPLATE_TYPE}
459
+ */
460
+ bar () {
461
+ }
462
+ }
463
+ // Settings: {"jsdoc":{"mode":"closure"}}
464
+
465
+ /**
466
+ * @template TEMPLATE_TYPE
467
+ */
468
+ class Foo {
469
+ /**
470
+ * @return {TEMPLATE_TYPE}
471
+ */
472
+ bar () {}
473
+
474
+ /**
475
+ * @return {TEMPLATE_TYPE}
476
+ */
477
+ baz () {}
478
+ }
479
+ // Settings: {"jsdoc":{"mode":"closure"}}
480
+
481
+ /**
482
+ * @template TEMPLATE_TYPE_A, TEMPLATE_TYPE_B
483
+ */
484
+ class Foo {
485
+ /**
486
+ * @param {TEMPLATE_TYPE_A} baz
487
+ * @return {TEMPLATE_TYPE_B}
488
+ */
489
+ bar (baz) {
490
+ }
491
+ }
492
+ // Settings: {"jsdoc":{"mode":"closure"}}
493
+
494
+ /**
495
+ * @template TEMPLATE_TYPE_A, TEMPLATE_TYPE_B - Some description
496
+ */
497
+ class Foo {
498
+ /**
499
+ * @param {TEMPLATE_TYPE_A} baz
500
+ * @return {TEMPLATE_TYPE_B}
501
+ */
502
+ bar (baz) {
503
+ }
504
+ }
505
+ // Settings: {"jsdoc":{"mode":"closure"}}
506
+
507
+ /****/
508
+
509
+ /* */
510
+
511
+ /*** */
512
+
513
+ /**
514
+ *
515
+ */
516
+ function quux () {
517
+
518
+ }
519
+
520
+ /**
521
+ * @typedef {object} BaseObject
522
+ */
523
+ /**
524
+ * Run callback when hooked method is called.
525
+ *
526
+ * @template {BaseObject} T
527
+ * @param {T} obj - object whose method should be hooked.
528
+ * @param {string} method - method which should be hooked.
529
+ * @param {(sender: T) => void} callback - callback which should
530
+ * be called when the hooked method was invoked.
531
+ */
532
+ function registerEvent(obj, method, callback) {
533
+
534
+ }
535
+ // Settings: {"jsdoc":{"mode":"typescript"}}
536
+
537
+ /**
538
+ * @param {...} varargs
539
+ */
540
+ function quux (varargs) {
541
+ }
542
+
543
+ /**
544
+ * @param {...number} varargs
545
+ */
546
+ function quux (varargs) {
547
+ }
548
+
549
+ class Navigator {}
550
+ /**
551
+ * @this {Navigator}
552
+ */
553
+ function quux () {}
554
+ // Settings: {"jsdoc":{"mode":"closure"}}
555
+
556
+ class SomeType {}
557
+ /**
558
+ * @export {SomeType}
559
+ */
560
+ function quux () {}
561
+ // Settings: {"jsdoc":{"mode":"closure"}}
562
+
563
+ /**
564
+ * @template T
565
+ * @param {T} arg
566
+ */
567
+ function example(arg) {
568
+
569
+ /** @param {T} */
570
+ function inner(x) {
571
+ }
572
+ }
573
+ // Settings: {"jsdoc":{"mode":"closure"}}
574
+
575
+ const init = () => {
576
+ /**
577
+ * Makes request
578
+ * @returns {Promise}
579
+ */
580
+ function request() {
581
+ return Promise.resolve('success');
582
+ }
583
+ };
584
+
585
+ /** Gets a Promise resolved with a given value.
586
+ *
587
+ * @template ValueType
588
+ * @param {ValueType} value Value to resolve.
589
+ * @returns {Promise<ValueType>} Promise resolved with value.
590
+ */
591
+ exports.resolve1 = function resolve1(value) {
592
+ return Promise.resolve(value);
593
+ };
594
+ // Settings: {"jsdoc":{"mode":"typescript"}}
595
+
596
+ /**
597
+ * A function returning the same type as its argument.
598
+ *
599
+ * @template ValueType
600
+ * @typedef {ValueType} ValueFunc
601
+ */
602
+ // Settings: {"jsdoc":{"mode":"typescript"}}
603
+
604
+ /**
605
+ * @aCustomTag {SomeType}
606
+ */
607
+ function quux () {}
608
+ // Settings: {"jsdoc":{"structuredTags":{"aCustomTag":{"type":false}}}}
609
+
610
+ /**
611
+ * @aCustomTag {SomeType}
612
+ */
613
+ function quux () {}
614
+ // Settings: {"jsdoc":{"structuredTags":{"aCustomTag":{"type":["aType","SomeType"]}}}}
615
+
616
+ /**
617
+ * @namepathDefiner SomeType
618
+ */
619
+ /**
620
+ * @type {SomeType}
621
+ */
622
+ // Settings: {"jsdoc":{"structuredTags":{"namepathDefiner":{"name":"namepath-defining"}}}}
623
+
624
+ class Test {
625
+ /**
626
+ * Method.
627
+ *
628
+ * @returns {this} Return description.
629
+ */
630
+ method (): this {
631
+ return this;
632
+ }
633
+ }
634
+
635
+ /**
636
+ * Bad types ignored here and handled instead by `valid-types`.
637
+ * @param {string(} foo - Bar.
638
+ */
639
+ function quux(foo) {
640
+
641
+ }
642
+
643
+ /**
644
+ * @template T
645
+ * @param {T} arg
646
+ * @returns {[T]}
647
+ */
648
+ function genericFunctionExample(arg) {
649
+ const result = /** @type {[T]} */ (new Array());
650
+ result[0] = arg;
651
+ return result;
652
+ }
653
+ // Settings: {"jsdoc":{"mode":"closure"}}
654
+
655
+ /** @typedef QDigestNode */
656
+ class A {
657
+ /**
658
+ * @template {object} T
659
+ * @param {(node: QDigestNode) => T} callback
660
+ * @returns {T[]}
661
+ */
662
+ map(callback) {
663
+ /** @type {T[]} */
664
+ let vals;
665
+ return vals;
666
+ }
667
+ }
668
+ // Settings: {"jsdoc":{"mode":"typescript"}}
669
+
670
+ /**
671
+ * @template T
672
+ * @param {T} arg
673
+ */
674
+ function example(arg) {
675
+
676
+ /** @param {T} */
677
+ function inner(x) {
678
+ }
679
+ }
680
+ // Settings: {"jsdoc":{"mode":"typescript"}}
681
+
682
+ /**
683
+ * @suppress {visibility}
684
+ */
685
+ function foo () {
686
+ }
687
+ // Settings: {"jsdoc":{"mode":"closure"}}
688
+
689
+ /**
690
+ * @template T
691
+ */
692
+ export class Foo {
693
+ // cast to T
694
+ getType() {
695
+ const x = "hello";
696
+ const y = /** @type {T} */ (x);
697
+ return y;
698
+ }
699
+ }
700
+ // Settings: {"jsdoc":{"mode":"typescript"}}
701
+
702
+ /**
703
+ * @type {const}
704
+ */
705
+ const a = 'string';
706
+
707
+ /**
708
+ * @typedef Todo
709
+ * @property description
710
+ * @property otherStuff
711
+ */
712
+ /**
713
+ * @type {Omit<Todo, "description">}
714
+ */
715
+ const a = new Todo();
716
+ // Settings: {"jsdoc":{"mode":"typescript"}}
717
+
718
+ /**
719
+ * @template A, [B=SomeDefault]
720
+ */
721
+ class Foo {
722
+ /**
723
+ * @param {A} baz
724
+ * @return {B}
725
+ */
726
+ bar (baz) {
727
+ }
728
+ }
729
+ // Settings: {"jsdoc":{"mode":"typescript"}}
730
+ ````
731
+