@@ -98,6 +98,14 @@ export function isTypeDeclaration(item: unknown): item is TypeDeclaration {
9898 return reflection . isInstance ( item , TypeDeclaration ) ;
9999}
100100
101+ export type TypeDefFieldTypes = Enum | TypeDef ;
102+
103+ export const TypeDefFieldTypes = 'TypeDefFieldTypes' ;
104+
105+ export function isTypeDefFieldTypes ( item : unknown ) : item is TypeDefFieldTypes {
106+ return reflection . isInstance ( item , TypeDefFieldTypes ) ;
107+ }
108+
101109export interface Argument extends AstNode {
102110 readonly $container : InvocationExpr ;
103111 readonly $type : 'Argument' ;
@@ -654,7 +662,7 @@ export interface TypeDefFieldType extends AstNode {
654662 readonly $type : 'TypeDefFieldType' ;
655663 array : boolean
656664 optional : boolean
657- reference ?: Reference < TypeDef >
665+ reference ?: Reference < TypeDefFieldTypes >
658666 type ?: BuiltinType
659667}
660668
@@ -738,14 +746,15 @@ export type ZModelAstType = {
738746 TypeDef : TypeDef
739747 TypeDefField : TypeDefField
740748 TypeDefFieldType : TypeDefFieldType
749+ TypeDefFieldTypes : TypeDefFieldTypes
741750 UnaryExpr : UnaryExpr
742751 UnsupportedFieldType : UnsupportedFieldType
743752}
744753
745754export class ZModelAstReflection extends AbstractAstReflection {
746755
747756 getAllTypes ( ) : string [ ] {
748- return [ 'AbstractDeclaration' , 'Argument' , 'ArrayExpr' , 'Attribute' , 'AttributeArg' , 'AttributeParam' , 'AttributeParamType' , 'BinaryExpr' , 'BooleanLiteral' , 'ConfigArrayExpr' , 'ConfigExpr' , 'ConfigField' , 'ConfigInvocationArg' , 'ConfigInvocationExpr' , 'DataModel' , 'DataModelAttribute' , 'DataModelField' , 'DataModelFieldAttribute' , 'DataModelFieldType' , 'DataSource' , 'Enum' , 'EnumField' , 'Expression' , 'FieldInitializer' , 'FunctionDecl' , 'FunctionParam' , 'FunctionParamType' , 'GeneratorDecl' , 'InternalAttribute' , 'InvocationExpr' , 'LiteralExpr' , 'MemberAccessExpr' , 'Model' , 'ModelImport' , 'NullExpr' , 'NumberLiteral' , 'ObjectExpr' , 'Plugin' , 'PluginField' , 'ReferenceArg' , 'ReferenceExpr' , 'ReferenceTarget' , 'StringLiteral' , 'ThisExpr' , 'TypeDeclaration' , 'TypeDef' , 'TypeDefField' , 'TypeDefFieldType' , 'UnaryExpr' , 'UnsupportedFieldType' ] ;
757+ return [ 'AbstractDeclaration' , 'Argument' , 'ArrayExpr' , 'Attribute' , 'AttributeArg' , 'AttributeParam' , 'AttributeParamType' , 'BinaryExpr' , 'BooleanLiteral' , 'ConfigArrayExpr' , 'ConfigExpr' , 'ConfigField' , 'ConfigInvocationArg' , 'ConfigInvocationExpr' , 'DataModel' , 'DataModelAttribute' , 'DataModelField' , 'DataModelFieldAttribute' , 'DataModelFieldType' , 'DataSource' , 'Enum' , 'EnumField' , 'Expression' , 'FieldInitializer' , 'FunctionDecl' , 'FunctionParam' , 'FunctionParamType' , 'GeneratorDecl' , 'InternalAttribute' , 'InvocationExpr' , 'LiteralExpr' , 'MemberAccessExpr' , 'Model' , 'ModelImport' , 'NullExpr' , 'NumberLiteral' , 'ObjectExpr' , 'Plugin' , 'PluginField' , 'ReferenceArg' , 'ReferenceExpr' , 'ReferenceTarget' , 'StringLiteral' , 'ThisExpr' , 'TypeDeclaration' , 'TypeDef' , 'TypeDefField' , 'TypeDefFieldType' , 'TypeDefFieldTypes' , ' UnaryExpr', 'UnsupportedFieldType' ] ;
749758 }
750759
751760 protected override computeIsSubtype ( subtype : string , supertype : string ) : boolean {
@@ -775,16 +784,18 @@ export class ZModelAstReflection extends AbstractAstReflection {
775784 case ConfigArrayExpr : {
776785 return this . isSubtype ( ConfigExpr , supertype ) ;
777786 }
778- case DataModel :
779- case Enum :
780- case TypeDef : {
787+ case DataModel : {
781788 return this . isSubtype ( AbstractDeclaration , supertype ) || this . isSubtype ( TypeDeclaration , supertype ) ;
782789 }
783790 case DataModelField :
784791 case EnumField :
785792 case FunctionParam : {
786793 return this . isSubtype ( ReferenceTarget , supertype ) ;
787794 }
795+ case Enum :
796+ case TypeDef : {
797+ return this . isSubtype ( AbstractDeclaration , supertype ) || this . isSubtype ( TypeDeclaration , supertype ) || this . isSubtype ( TypeDefFieldTypes , supertype ) ;
798+ }
788799 case InvocationExpr :
789800 case LiteralExpr : {
790801 return this . isSubtype ( ConfigExpr , supertype ) || this . isSubtype ( Expression , supertype ) ;
@@ -821,7 +832,7 @@ export class ZModelAstReflection extends AbstractAstReflection {
821832 return ReferenceTarget ;
822833 }
823834 case 'TypeDefFieldType:reference' : {
824- return TypeDef ;
835+ return TypeDefFieldTypes ;
825836 }
826837 default : {
827838 throw new Error ( `${ referenceId } is not a valid reference id.` ) ;
0 commit comments