From df6f89338138fa1769bb94dd32aaa766e9df5fa7 Mon Sep 17 00:00:00 2001 From: Utku Enes GURSEL Date: Fri, 30 May 2025 11:13:48 +0300 Subject: [PATCH] fix ConstructIfaceFromSdk rule check Issue: ICB9IW Description: Instead using ts.Compiler's controller method, checking the type declaration if we are trying to instantiate a interface we raise the error. Signed-off-by: Utku Enes GURSEL --- ets2panda/linter/src/lib/TypeScriptLinter.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ets2panda/linter/src/lib/TypeScriptLinter.ts b/ets2panda/linter/src/lib/TypeScriptLinter.ts index 4caeea6c34..bbbd666b47 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -5042,9 +5042,19 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } const type = this.tsTypeChecker.getTypeAtLocation(calleeExpr); - if (type.isClassOrInterface()) { - this.incrementCounters(calleeExpr, FaultID.ConstructorIfaceFromSdk); + if (!type.symbol) { + return; + } + const typeDeclarations = type.symbol.declarations; + if (!typeDeclarations || typeDeclarations.length === 0) { + return; } + + if (!ts.isInterfaceDeclaration(typeDeclarations[0])) { + return; + } + + this.incrementCounters(calleeExpr, FaultID.ConstructorIfaceFromSdk); } private handleNewExpression(node: ts.Node): void { -- Gitee