From d7ce96779e85355ec23117f4997b94587bb30d6f Mon Sep 17 00:00:00 2001 From: Evgeniy Okolnov Date: Fri, 29 Sep 2023 16:11:52 +0300 Subject: [PATCH] [ArkTS Linter] Relax inferred type arguments check for interop calls to improve linter performance. Change-Id: Id9d14c69ef04dd3372a4dde02d25ca8dbcc87e16 Signed-off-by: Evgeniy Okolnov --- linter-4.2/src/TypeScriptLinter.ts | 12 ++++++------ linter/src/TypeScriptLinter.ts | 11 +++++++---- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/linter-4.2/src/TypeScriptLinter.ts b/linter-4.2/src/TypeScriptLinter.ts index cbe8b3106..240410518 100644 --- a/linter-4.2/src/TypeScriptLinter.ts +++ b/linter-4.2/src/TypeScriptLinter.ts @@ -1719,12 +1719,15 @@ export class TypeScriptLinter { private handleCallExpression(node: ts.Node) { let tsCallExpr = node as ts.CallExpression; + const exprSym = this.tsUtils.trueSymbolAtLocation(tsCallExpr.expression); this.handleImportCall(tsCallExpr); this.handleRequireCall(tsCallExpr); // NOTE: Keep handleFunctionApplyBindPropCall above handleGenericCallWithNoTypeArgs here!!! - this.handleFunctionApplyBindPropCall(tsCallExpr); - this.handleGenericCallWithNoTypeArgs(tsCallExpr); + this.handleFunctionApplyBindPropCall(tsCallExpr, exprSym); + if (!this.tsUtils.isLibrarySymbol(exprSym)) { + this.handleGenericCallWithNoTypeArgs(tsCallExpr); + } this.handleStructIdentAndUndefinedInArgs(tsCallExpr); this.handleStdlibAPICall(tsCallExpr); this.handleLibraryTypeCall(tsCallExpr); @@ -1801,7 +1804,7 @@ export class TypeScriptLinter { } } - private handleFunctionApplyBindPropCall(tsCallExpr: ts.CallExpression) { + private handleFunctionApplyBindPropCall(tsCallExpr: ts.CallExpression, exprSymbol: ts.Symbol | undefined) { const stdFunction = "Function"; const callableFunction = "CallableFunction"; const funcProps = [ @@ -1813,9 +1816,6 @@ export class TypeScriptLinter { `${callableFunction}.bind`, ]; - const exprSymbol = this.tsUtils.trueSymbolAtLocation( - tsCallExpr.expression - ); if (exprSymbol === undefined) { return; } diff --git a/linter/src/TypeScriptLinter.ts b/linter/src/TypeScriptLinter.ts index aaa107e74..01f8548ea 100644 --- a/linter/src/TypeScriptLinter.ts +++ b/linter/src/TypeScriptLinter.ts @@ -1410,11 +1410,15 @@ export class TypeScriptLinter { private handleCallExpression(node: ts.Node) { let tsCallExpr = node as ts.CallExpression; + const exprSym = this.tsUtils.trueSymbolAtLocation(tsCallExpr.expression); + this.handleImportCall(tsCallExpr); this.handleRequireCall(tsCallExpr); // NOTE: Keep handleFunctionApplyBindPropCall above handleGenericCallWithNoTypeArgs here!!! - this.handleFunctionApplyBindPropCall(tsCallExpr); - this.handleGenericCallWithNoTypeArgs(tsCallExpr); + this.handleFunctionApplyBindPropCall(tsCallExpr, exprSym); + if (!this.tsUtils.isLibrarySymbol(exprSym)) { + this.handleGenericCallWithNoTypeArgs(tsCallExpr); + } this.handleStructIdentAndUndefinedInArgs(tsCallExpr); this.handleStdlibAPICall(tsCallExpr); this.handleLibraryTypeCall(tsCallExpr); @@ -1477,7 +1481,7 @@ export class TypeScriptLinter { } } - private handleFunctionApplyBindPropCall(tsCallExpr: ts.CallExpression) { + private handleFunctionApplyBindPropCall(tsCallExpr: ts.CallExpression, exprSymbol: ts.Symbol | undefined) { const stdFunction = 'Function'; const callableFunction = 'CallableFunction'; const funcProps = [ @@ -1488,7 +1492,6 @@ export class TypeScriptLinter { `${callableFunction}.call`, `${callableFunction}.bind`, ]; - const exprSymbol = this.tsUtils.trueSymbolAtLocation(tsCallExpr.expression); if (exprSymbol === undefined) { return; } -- Gitee