@@ -136,22 +136,25 @@ exports.astNodeVisitor = {
136136 lines [ 0 ] += ' @classdesc' ;
137137 }
138138 if ( node . superClass ) {
139+ // Remove the `@extends` tag because JSDoc does not does not handle generic type. (`@extends {Base<Type>}`)
140+ const extendsIndex = lines . findIndex ( line => line . includes ( '@extends' ) ) ;
141+ if ( extendsIndex !== - 1 ) {
142+ lines . splice ( extendsIndex , 1 ) ;
143+ }
139144 // Add class inheritance information because JSDoc does not honor
140145 // the ES6 class's `extends` keyword
141- if ( leadingComment . value . indexOf ( '@extends' ) === - 1 ) {
142- lines . push ( lines [ lines . length - 1 ] ) ;
143- const identifier = identifiers [ node . superClass . name ] ;
144- if ( identifier ) {
145- const absolutePath = path . resolve ( path . dirname ( currentSourceName ) , identifier . value ) ;
146- const moduleId = path . relative ( path . join ( process . cwd ( ) , moduleRoot ) , absolutePath ) . replace ( / \. j s $ / , '' ) ;
147- if ( getModuleInfo ( moduleId , parser ) ) {
148- const exportName = identifier . defaultImport ? getDefaultExportName ( moduleId , parser ) : node . superClass . name ;
149- const delimiter = identifier . defaultImport ? '~' : getDelimiter ( moduleId , exportName , parser ) ;
150- lines [ lines . length - 2 ] = ' * @extends ' + `module:${ moduleId . replace ( slashRegEx , '/' ) } ${ exportName ? delimiter + exportName : '' } ` ;
151- }
152- } else {
153- lines [ lines . length - 2 ] = ' * @extends ' + node . superClass . name ;
146+ lines . push ( lines [ lines . length - 1 ] ) ;
147+ const identifier = identifiers [ node . superClass . name ] ;
148+ if ( identifier ) {
149+ const absolutePath = path . resolve ( path . dirname ( currentSourceName ) , identifier . value ) ;
150+ const moduleId = path . relative ( path . join ( process . cwd ( ) , moduleRoot ) , absolutePath ) . replace ( / \. j s $ / , '' ) ;
151+ if ( getModuleInfo ( moduleId , parser ) ) {
152+ const exportName = identifier . defaultImport ? getDefaultExportName ( moduleId , parser ) : node . superClass . name ;
153+ const delimiter = identifier . defaultImport ? '~' : getDelimiter ( moduleId , exportName , parser ) ;
154+ lines [ lines . length - 2 ] = ' * @extends ' + `module:${ moduleId . replace ( slashRegEx , '/' ) } ${ exportName ? delimiter + exportName : '' } ` ;
154155 }
156+ } else {
157+ lines [ lines . length - 2 ] = ' * @extends ' + node . superClass . name ;
155158 }
156159 leadingComment . value = lines . join ( '\n' ) ;
157160 }
@@ -222,4 +225,4 @@ exports.handlers = {
222225 // Build inheritance chain after adding @extends annotations
223226 addInherited ( e . doclets , indexAll ( e . doclets ) ) ;
224227 }
225- }
228+ }
0 commit comments