From 48307d0b5aea359bdcba1a6d1d8e457c0b67f194 Mon Sep 17 00:00:00 2001 From: Igor Rossinski Date: Thu, 14 Sep 2023 15:20:09 +0300 Subject: [PATCH] [ArkTS Linter] fix #13474 (bug appears only with tsc4.2) Signed-off-by: Igor Rossinski --- linter-4.2/src/Utils.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/linter-4.2/src/Utils.ts b/linter-4.2/src/Utils.ts index 1fc3ed1ab..ae0ba01af 100644 --- a/linter-4.2/src/Utils.ts +++ b/linter-4.2/src/Utils.ts @@ -100,7 +100,7 @@ export class TsUtils { static LIMITED_STD_GLOBAL_VAR = ['Infinity', 'NaN']; static LIMITED_STD_OBJECT_API = [ '__proto__', '__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__', 'assign', 'create', - 'defineProperties', 'defineProperty', 'entries', 'freeze', 'fromEntries', 'getOwnPropertyDescriptor', + 'defineProperties', 'defineProperty', 'entries', 'freeze', 'fromEntries', 'getOwnPropertyDescriptor', 'getOwnPropertyDescriptors', 'getOwnPropertyNames', 'getOwnPropertySymbols', 'getPrototypeOf', 'hasOwn', 'hasOwnProperty', 'is', 'isExtensible', 'isFrozen', 'isPrototypeOf', 'isSealed', 'keys', 'preventExtensions', 'propertyIsEnumerable', 'seal', 'setPrototypeOf', 'values' @@ -110,7 +110,7 @@ export class TsUtils { 'has', 'isExtensible', 'ownKeys', 'preventExtensions', 'set', 'setPrototypeOf' ]; static LIMITED_STD_PROXYHANDLER_API = [ - 'apply', 'construct', 'defineProperty', 'deleteProperty', 'get', 'getOwnPropertyDescriptor', 'getPrototypeOf', + 'apply', 'construct', 'defineProperty', 'deleteProperty', 'get', 'getOwnPropertyDescriptor', 'getPrototypeOf', 'has', 'isExtensible', 'ownKeys', 'preventExtensions', 'set', 'setPrototypeOf' ]; static LIMITED_STD_ARRAY_API = ['isArray']; @@ -871,7 +871,7 @@ export class TsUtils { if (this.areCompatibleFunctionals(lhsType, rhsType)) { return true; } - + return lhsType === rhsType || this.hasBaseType(rhsType, this.getTargetType(lhsType)); } @@ -1229,13 +1229,19 @@ export class TsUtils { // foo({ ... }) if (ts.isCallExpression(curNode)) { const callExpr = curNode as ts.CallExpression; - let sym: ts.Symbol | undefined = this.tsTypeChecker.getTypeAtLocation(callExpr.expression).symbol; + const type = this.tsTypeChecker.getTypeAtLocation(callExpr.expression); + + // this check is a hack to fix #13474, only for tac 4.2 + if (this.isAnyType( type )) + return true; + + let sym: ts.Symbol | undefined = type.symbol; if(this.isLibrarySymbol(sym)) { return true; } // #13483: - // x.foo({ ... }), where 'x' is exported from some library: + // x.foo({ ... }), where 'x' is a variable exported from some library: if (ts.isPropertyAccessExpression(callExpr.expression)) { sym = this.tsTypeChecker.getSymbolAtLocation(callExpr.expression.expression); if (sym && sym.getFlags() & ts.SymbolFlags.Alias) { -- Gitee