From 9e104a9f112dd0cc64fe00757848a06732ee5043 Mon Sep 17 00:00:00 2001 From: ZhongNing Date: Wed, 9 Jul 2025 16:30:53 +0800 Subject: [PATCH] fix arkts-no-ts-like-smart-type Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICKXXU Test scenarios: fix bug Signed-off-by: ZhongNing --- ets2panda/linter/src/lib/TypeScriptLinter.ts | 8 ++++++++ ets2panda/linter/test/main/no_ts_like_smart_type.ets | 6 ++++++ .../test/main/no_ts_like_smart_type.ets.arkts2.json | 10 ++++++++++ 3 files changed, 24 insertions(+) diff --git a/ets2panda/linter/src/lib/TypeScriptLinter.ts b/ets2panda/linter/src/lib/TypeScriptLinter.ts index ca04dbcfcd..35779c4ed0 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -9753,6 +9753,14 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (!this.options.arkts2) { return; } + + if (ts.isIdentifier(tsCallExpr.expression)) { + const funcName = tsCallExpr.expression.text; + if (funcName === 'setTimeout') { + return; + } + } + const isContinue = ts.isCallExpression(tsCallExpr) && ts.isIdentifier(tsCallExpr.expression) && diff --git a/ets2panda/linter/test/main/no_ts_like_smart_type.ets b/ets2panda/linter/test/main/no_ts_like_smart_type.ets index 7a82e0fd5e..22cfed5e76 100755 --- a/ets2panda/linter/test/main/no_ts_like_smart_type.ets +++ b/ets2panda/linter/test/main/no_ts_like_smart_type.ets @@ -118,4 +118,10 @@ async function taskInfo():Promise {//nopass ", name is:" + name); } } +} + +function sleep(ms: number): PromiseLike { + return new Promise( + (resolve: (value: T | PromiseLike) => void): number => setTimeout(resolve, ms) + ); } \ No newline at end of file diff --git a/ets2panda/linter/test/main/no_ts_like_smart_type.ets.arkts2.json b/ets2panda/linter/test/main/no_ts_like_smart_type.ets.arkts2.json index 679e8a5d6f..d4f6f7d2c6 100755 --- a/ets2panda/linter/test/main/no_ts_like_smart_type.ets.arkts2.json +++ b/ets2panda/linter/test/main/no_ts_like_smart_type.ets.arkts2.json @@ -243,6 +243,16 @@ "suggest": "", "rule": "Smart type differences (arkts-no-ts-like-smart-type)", "severity": "ERROR" + }, + { + "line": 124, + "column": 10, + "endLine": 126, + "endColumn": 4, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" } ] } \ No newline at end of file -- Gitee