Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,9 @@ function generateStandaloneInterface(ast: TNamedInterface, options: Options): st
function generateStandaloneType(ast: ASTWithStandaloneName, options: Options): string {
return (
(hasComment(ast) ? generateComment(ast.comment) + '\n' : '') +
`export type ${toSafeString(ast.standaloneName)} = ${generateType(
omit<AST>(ast, 'standaloneName') as AST /* TODO */,
options
)}`
`export type ${toSafeString(ast.standaloneName)}` +
(ast.tsGenericParams ? `<${ast.tsGenericParams.join(', ')}>` : '') +
` = ${generateType(omit<AST>(ast, 'standaloneName') as AST /* TODO */, options)}`
)
}

Expand Down
5 changes: 4 additions & 1 deletion src/types/AST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ export interface AbstractAST {

export type ASTWithComment = AST & { comment: string }
export type ASTWithName = AST & { keyName: string }
export type ASTWithStandaloneName = AST & { standaloneName: string }
export type ASTWithStandaloneName = AST & {
standaloneName: string,
tsGenericParams?: string[],
}

export function hasComment(ast: AST): ast is ASTWithComment {
return 'comment' in ast && ast.comment != null && ast.comment !== ''
Expand Down