File tree Expand file tree Collapse file tree 4 files changed +281
-30
lines changed Expand file tree Collapse file tree 4 files changed +281
-30
lines changed Original file line number Diff line number Diff line change 156156 */
157157```
158158
159+ ### Tuples
160+
161+ ``` js
162+ /**
163+ * @type {[string, number]}
164+ */
165+ ```
166+
167+ To:
168+ ``` js
169+ /**
170+ * @type {Array}
171+ */
172+ ```
173+
159174## Module id resolution
160175
161176For 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)/;
1111const extensionReplaceRegEx = / \. m ? j s $ / ;
1212const extensionEnsureRegEx = / ( \. j s ) ? $ / ;
1313const slashRegEx = / \\ / g;
14-
14+ const variableNameRegEx = / ^ [ a - z A - Z _ $ ] [ 0 - 9 a - z A - Z _ $ ] * $ / ;
1515const moduleInfos = { } ;
1616const fileNodes = { } ;
1717const resolvedPathCache = new Set ( ) ;
@@ -228,6 +228,7 @@ exports.defineTags = function (dictionary) {
228228 /** @type {Array<[number, number, string]> } */
229229 let replacements = [ ] ;
230230 let openCurly = 0 ;
231+ let openSquare = 0 ;
231232 let openRound = 0 ;
232233 let isWithinString = false ;
233234 let quoteChar = '' ;
@@ -295,6 +296,24 @@ exports.defineTags = function (dictionary) {
295296 functionStartIndex = null ;
296297 }
297298
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+ }
298317 break ;
299318 case '{' :
300319 ++ openCurly ;
You can’t perform that action at this time.
0 commit comments