Skip to content

Commit 0acd2a0

Browse files
author
Boris Cherny
committed
Emit comments for literal unions (fix #475)
1 parent 34de194 commit 0acd2a0

File tree

4 files changed

+119413
-30028
lines changed

4 files changed

+119413
-30028
lines changed

Diff for: src/generator.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,11 @@ function generateRawType(ast: AST, options: Options): string {
285285
* Generate a Union or Intersection
286286
*/
287287
function generateSetOperation(ast: TIntersection | TUnion, options: Options): string {
288-
const members = (ast as TUnion).params.map(_ => generateType(_, options))
288+
const members = (ast as TUnion).params.map(_ =>
289+
[_.comment && !_.standaloneName ? generateComment(_.comment) : null, generateType(_, options)]
290+
.filter(Boolean)
291+
.join('\n')
292+
)
289293
const separator = ast.type === 'UNION' ? '|' : '&'
290294
return members.length === 1 ? members[0] : '(' + members.join(' ' + separator + ' ') + ')'
291295
}

0 commit comments

Comments
 (0)