@@ -86,7 +86,8 @@ export function createGenerator(config?: GeneratorOptions | Project) {
8686 project : config ,
8787 }
8888 : config ;
89- const cacheType = options ?. cache ?? 'fs' ;
89+ const cacheType =
90+ options ?. cache ?? ( process . env . NODE_ENV !== 'development' ? 'fs' : false ) ;
9091 const cache = cacheType === 'fs' ? createCache ( ) : null ;
9192 let instance : Project | undefined ;
9293
@@ -214,13 +215,18 @@ function getDocEntry(
214215 } ) satisfies RawTag ,
215216 ) ;
216217
217- let type = getFullType ( subType ) ;
218+ let simplifiedType = getSimpleForm (
219+ subType ,
220+ program . getTypeChecker ( ) ,
221+ isOptional ,
222+ ) ;
218223
219- for ( const tag of tags ) {
220- if ( tag . name !== 'remarks' ) continue ;
224+ const remarksTag = tags . find ( ( tag ) => tag . name === 'remarks' ) ;
225+ if ( remarksTag ) {
226+ const match = / ^ ` (?< name > .+ ) ` / . exec ( remarksTag . text ) ?. [ 1 ] ;
221227
222228 // replace type with @remarks
223- type = / ^ ` (?< name > . + ) ` / . exec ( tag . text ) ?. [ 1 ] ?? type ;
229+ if ( match ) simplifiedType = match ;
224230 }
225231
226232 const entry : DocEntry = {
@@ -231,12 +237,8 @@ function getDocEntry(
231237 ) ,
232238 ) ,
233239 tags,
234- type,
235- simplifiedType : getSimpleForm (
236- subType ,
237- program . getTypeChecker ( ) ,
238- isOptional ,
239- ) ,
240+ type : getFullType ( subType ) ,
241+ simplifiedType,
240242 required : ! isOptional ,
241243 deprecated : tags . some ( ( tag ) => tag . name === 'deprecated' ) ,
242244 } ;
@@ -247,16 +249,18 @@ function getDocEntry(
247249}
248250
249251function getFullType ( type : Type ) : string {
250- let typeName = type . getText (
252+ const alias = type . getAliasSymbol ( ) ;
253+ if ( alias ) {
254+ return alias
255+ . getDeclaredType ( )
256+ . getText ( undefined , ts . TypeFormatFlags . NoTruncation ) ;
257+ }
258+
259+ return type . getText (
251260 undefined ,
252261 ts . TypeFormatFlags . UseAliasDefinedOutsideCurrentScope |
253262 ts . TypeFormatFlags . NoTruncation |
263+ // we use `InTypeAlias` to force TypeScript to extend generic types like `ExtractParams<T>` into more detailed forms like `T extends string? ExtractParamsFromString<T> : never`.
254264 ts . TypeFormatFlags . InTypeAlias ,
255265 ) ;
256-
257- if ( type . getAliasSymbol ( ) && type . getAliasTypeArguments ( ) . length === 0 ) {
258- typeName = type . getAliasSymbol ( ) ?. getEscapedName ( ) ?? typeName ;
259- }
260-
261- return typeName ;
262266}
0 commit comments