diff --git a/compiler/src/fast_build/ark_compiler/interop/process_arkts_evolution.ts b/compiler/src/fast_build/ark_compiler/interop/process_arkts_evolution.ts index 7cf11fe98c789047b8d91337b4267025298e4a26..c374bfac72a1491ecccffef3110b6bd9037f2f67 100644 --- a/compiler/src/fast_build/ark_compiler/interop/process_arkts_evolution.ts +++ b/compiler/src/fast_build/ark_compiler/interop/process_arkts_evolution.ts @@ -604,9 +604,11 @@ function collectDeepInheritedInterfacesFromType(type: ts.Type, checker: ts.TypeC const ifacePath: string = getArkTSEvoFileOHMUrl(type); interfaces.add(`L${ifacePath}/${type.symbol.name};`); } - const baseTypes: ts.BaseType[] = checker.getBaseTypes(type as ts.InterfaceType) ?? []; - for (const baseType of baseTypes) { - collectDeepInheritedInterfacesFromType(baseType, checker, visited, interfaces); + if (hasResolvedBaseTypes(type)) { + const baseTypes: ts.BaseType[] = checker.getBaseTypes(type) ?? []; + for (const baseType of baseTypes) { + collectDeepInheritedInterfacesFromType(baseType, checker, visited, interfaces); + } } if (decls) { @@ -618,6 +620,14 @@ function collectDeepInheritedInterfacesFromType(type: ts.Type, checker: ts.TypeC } } +function hasResolvedBaseTypes(type: ts.Type): type is ts.InterfaceType { + return ( + (type.flags & ts.TypeFlags.Object) !== 0 && + ((type as ts.ObjectType).objectFlags & (ts.ObjectFlags.Class | ts.ObjectFlags.Interface)) !== 0 && + 'resolvedBaseTypes' in type + ); +} + function transformHeritage(context: ts.TransformationContext, classToInterfacesMap: Map>): ts.Visitor { return function visitor(node: ts.SourceFile): ts.SourceFile {