Skip to content

Commit 48d3699

Browse files
committed
Check length of @codegen_names at compile time
1 parent 4165c17 commit 48d3699

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

compiler/model/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,10 @@ export function hoistTypeAnnotations (type: model.TypeDefinition, jsDocs: JSDoc[
650650
type.docUrl = value
651651
} else if (tag === 'codegen_names') {
652652
type.codegenNames = value.split(',').map(v => v.trim())
653+
assert(jsDocs,
654+
type.kind == 'type_alias' && type.type.kind == 'union_of' && type.type.items.length == type.codegenNames.length,
655+
'@codegen_names must have the number of items as the union definition'
656+
)
653657
} else {
654658
assert(jsDocs, false, `Unhandled tag: '${tag}' with value: '${value}' on type ${type.name.name}`)
655659
}

0 commit comments

Comments
 (0)