File tree 4 files changed +281
-30
lines changed
4 files changed +281
-30
lines changed Original file line number Diff line number Diff line change 156
156
*/
157
157
```
158
158
159
+ ### Tuples
160
+
161
+ ``` js
162
+ /**
163
+ * @type {[string, number]}
164
+ */
165
+ ```
166
+
167
+ To:
168
+ ``` js
169
+ /**
170
+ * @type {Array}
171
+ */
172
+ ```
173
+
159
174
## Module id resolution
160
175
161
176
For resolving module ids, this plugin mirrors the method used by JSDoc:
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ const noClassdescRegEx = /@(typedef|module|type)/;
11
11
const extensionReplaceRegEx = / \. m ? j s $ / ;
12
12
const extensionEnsureRegEx = / ( \. j s ) ? $ / ;
13
13
const slashRegEx = / \\ / g;
14
-
14
+ const variableNameRegEx = / ^ [ a - z A - Z _ $ ] [ 0 - 9 a - z A - Z _ $ ] * $ / ;
15
15
const moduleInfos = { } ;
16
16
const fileNodes = { } ;
17
17
const resolvedPathCache = new Set ( ) ;
@@ -228,6 +228,7 @@ exports.defineTags = function (dictionary) {
228
228
/** @type {Array<[number, number, string]> } */
229
229
let replacements = [ ] ;
230
230
let openCurly = 0 ;
231
+ let openSquare = 0 ;
231
232
let openRound = 0 ;
232
233
let isWithinString = false ;
233
234
let quoteChar = '' ;
@@ -295,6 +296,24 @@ exports.defineTags = function (dictionary) {
295
296
functionStartIndex = null ;
296
297
}
297
298
299
+ break ;
300
+ case '[' :
301
+ if (
302
+ isWithinString ||
303
+ variableNameRegEx . test ( tagText . charAt ( i - 1 ) )
304
+ ) {
305
+ break ;
306
+ }
307
+ ++ openSquare ;
308
+ break ;
309
+ case ']' :
310
+ if ( isWithinString ) {
311
+ break ;
312
+ }
313
+ if ( ! -- openSquare ) {
314
+ // Replace [type1, type2] tuples with Array
315
+ replacements . push ( [ startIndex + 1 , i + 1 , 'Array' ] ) ;
316
+ }
298
317
break ;
299
318
case '{' :
300
319
++ openCurly ;
You can’t perform that action at this time.
0 commit comments