diff --git a/src/core/parseReflectedType.ts b/src/core/parseReflectedType.ts index a2e9866..6212320 100644 --- a/src/core/parseReflectedType.ts +++ b/src/core/parseReflectedType.ts @@ -11,6 +11,7 @@ export type FunctionDef = { export type ImplementationDef = { fn: FunctionDef, dependencies: Record + genericParameter: string | null } /** @@ -23,6 +24,11 @@ export function parseReflectedType(name: string, reflectedType: string): Impleme const [factoryArgs, fnsClause] = split(reflectedType, '=>', 2).map(trim) const fn = parseAlias(name, fnsClause) + // extract the generic parameter like '' at the start of the type + const genericParameter = factoryArgs.trim().startsWith('<') + ? findBlockContents(factoryArgs, '<', '>')?.innerText || null + : null + const factoryArgsInner = findBlockContents(factoryArgs, '(', ')') const depArg = split(factoryArgsInner.innerText, ':').map(trim)[1] const depArgBlocks: string[] = depArg ? split(depArg, '&').map(trim) : [] @@ -39,7 +45,7 @@ export function parseReflectedType(name: string, reflectedType: string): Impleme const dependencies: Record = groupBy(deps, 'name') - return {fn, dependencies} + return {fn, dependencies, genericParameter } } function parseDependencies(deps: string): FunctionDef[] {