File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
specification/compiler/model Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -152,7 +152,7 @@ export abstract class BaseType {
152
152
variantName ?: string
153
153
}
154
154
155
- export type Variants = ExternalTag | InternalTag
155
+ export type Variants = ExternalTag | InternalTag | Container
156
156
157
157
export class ExternalTag {
158
158
kind : 'external_tag'
@@ -163,6 +163,10 @@ export class InternalTag {
163
163
tag : string // Name of the property that holds the variant tag
164
164
}
165
165
166
+ export class Container {
167
+ kind : 'container'
168
+ }
169
+
166
170
/**
167
171
* Inherits clause (aka extends or implements) for an interface or request
168
172
*/
@@ -275,7 +279,7 @@ export class TypeAlias extends BaseType {
275
279
/** generic parameters: either concrete types or open parameters from the enclosing type */
276
280
generics ?: ValueOf [ ]
277
281
/** Identify typed_key unions (external) and variant inventories (internal) */
278
- variants ?: Variants
282
+ variants ?: InternalTag | ExternalTag
279
283
}
280
284
281
285
// ------------------------------------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -381,6 +381,10 @@ export function modelTypeAlias (declaration: TypeAliasDeclaration): model.TypeAl
381
381
if ( alias . kind === 'union_of' ) {
382
382
const variants = parseVariantsTag ( declaration . getJsDocs ( ) )
383
383
if ( variants != null ) {
384
+ assert (
385
+ variants . kind === 'internal_tag' || variants . kind === 'external_tag' ,
386
+ 'Type Aliases can only have internal or external variants'
387
+ )
384
388
typeAlias . variants = variants
385
389
}
386
390
}
@@ -668,6 +672,10 @@ export function parseVariantsTag (jsDoc: JSDoc[]): model.Variants | undefined {
668
672
return { kind : 'external_tag' }
669
673
}
670
674
675
+ if ( type === 'container' ) {
676
+ return { kind : 'container' }
677
+ }
678
+
671
679
assert ( type === 'internal' , `Bad variant type: ${ type } ` )
672
680
assert ( typeof value === 'string' , 'Internal variant requires a tag definition' )
673
681
const [ tag , property ] = value . split ( '=' )
You can’t perform that action at this time.
0 commit comments