@@ -17,7 +17,7 @@ if (!fs.existsSync(moduleRootAbsolute)) {
1717}
1818
1919const importRegEx = / i m p o r t \( [ " ' ] ( [ ^ " ' ] * ) [ " ' ] \) \. ( [ ^ \. \| \} > < , \) = # \n ] * ) ( [ \. \| \} > < , \) = # \n ] ) / g;
20- const typedefRegEx = / @ t y p e d e f \{ [ ^ \} ] * \} ( [ ^ \r ? \n ? ] * ) / ;
20+ const typedefRegEx = / @ t y p e d e f \{ [ ^ \} ] * \} ( \S * ) / ;
2121const noClassdescRegEx = / @ ( t y p e d e f | m o d u l e | t y p e ) / ;
2222const slashRegEx = / \\ / g;
2323
@@ -201,7 +201,8 @@ exports.astNodeVisitor = {
201201 node . comments . forEach ( comment => {
202202 // Replace local types with the full `module:` path
203203 Object . keys ( identifiers ) . forEach ( key => {
204- const regex = new RegExp ( `@(event |fires |.*[\{<\|,] ?!?)${ key } ` , 'g' ) ;
204+ const regex = new RegExp ( `@(event |fires |.*[\{<\|,] ?!?)${ key } ([}>|,\s])` , 'g' ) ;
205+
205206 if ( regex . test ( comment . value ) ) {
206207 const identifier = identifiers [ key ] ;
207208 const absolutePath = path . resolve ( path . dirname ( currentSourceName ) , identifier . value ) ;
@@ -210,7 +211,7 @@ exports.astNodeVisitor = {
210211 const exportName = identifier . defaultImport ? getDefaultExportName ( moduleId , parser ) : key ;
211212 const delimiter = identifier . defaultImport ? '~' : getDelimiter ( moduleId , exportName , parser ) ;
212213 const replacement = `module:${ moduleId . replace ( slashRegEx , '/' ) } ${ exportName ? delimiter + exportName : '' } ` ;
213- comment . value = comment . value . replace ( regex , '@$1' + replacement ) ;
214+ comment . value = comment . value . replace ( regex , '@$1' + replacement + '$2' ) ;
214215 }
215216 }
216217 } ) ;
0 commit comments