From 7c1d1b18558edbc1ae634305a684dae4a26699c0 Mon Sep 17 00:00:00 2001 From: zhangzezhong Date: Tue, 24 Jun 2025 09:52:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dschema=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangzezhong --- compiler/src/userIntents_parser/parseUserIntents.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/src/userIntents_parser/parseUserIntents.ts b/compiler/src/userIntents_parser/parseUserIntents.ts index 7d4b99dfc..2a0fc035e 100644 --- a/compiler/src/userIntents_parser/parseUserIntents.ts +++ b/compiler/src/userIntents_parser/parseUserIntents.ts @@ -838,7 +838,7 @@ class ParseIntent { const propertyClassName: string = typeSymbol.getName(); if (this.isArrayType(propType)) { elementType = (propType as ts.TypeReference).typeArguments?.[0]; - propDeclaration = elementType.getSymbol().getDeclarations()[0]; + propDeclaration = elementType.getSymbol()?.getDeclarations()[0]; } else { propDeclaration = typeSymbol.getDeclarations()?.[0]; } @@ -871,6 +871,8 @@ class ParseIntent { private getTypeCategory(type: ts.Type): { category: 'array' | 'object'; } { const flags: ts.TypeFlags = type.getFlags(); + const valueDeclaration: ts.Declaration | undefined = type.getSymbol()?.valueDeclaration; + const isEnum: boolean = valueDeclaration ? ts.isEnumDeclaration(valueDeclaration) : false; const isPrimitive: boolean = !!(flags & ts.TypeFlags.StringLike) || !!(flags & ts.TypeFlags.NumberLike) || @@ -881,7 +883,7 @@ class ParseIntent { const isArray: boolean = this.isArrayType(type); const isObject: boolean = !isPrimitive && !isArray && - !!(flags & ts.TypeFlags.Object); + (!!(flags & ts.TypeFlags.Object) || isEnum); let category: 'array' | 'object'; if (isArray) { category = 'array'; -- Gitee