From 5cb91855a53508392335bd4a8de319fef2055160 Mon Sep 17 00:00:00 2001 From: ZhongNing Date: Thu, 10 Jul 2025 20:34:24 +0800 Subject: [PATCH] fix issue for arkts-no-structural-typing Issue:https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICKXWC Test scenarios: new tests added to the linter Signed-off-by: ZhongNing --- .../src/lib/utils/consts/ExtendedBaseTypes.ts | 3 ++- .../test/main/structural_identity_promise.ets | 6 +++++ ...tructural_identity_promise.ets.arkts2.json | 23 ++++++++++++++++++- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/ets2panda/linter/src/lib/utils/consts/ExtendedBaseTypes.ts b/ets2panda/linter/src/lib/utils/consts/ExtendedBaseTypes.ts index 198e45afb1..de0c40e186 100644 --- a/ets2panda/linter/src/lib/utils/consts/ExtendedBaseTypes.ts +++ b/ets2panda/linter/src/lib/utils/consts/ExtendedBaseTypes.ts @@ -33,5 +33,6 @@ export const EXTENDED_BASE_TYPES = new Map([ ['ReadonlyArray', ['ConcatArray']], ['Array', ['ReadonlyArray']], ['Map', ['ReadonlyMap']], - ['Set', ['ReadonlySet']] + ['Set', ['ReadonlySet']], + ['Promise', ['PromiseLike']] ]); diff --git a/ets2panda/linter/test/main/structural_identity_promise.ets b/ets2panda/linter/test/main/structural_identity_promise.ets index e9fe68fd17..59edca4ff0 100644 --- a/ets2panda/linter/test/main/structural_identity_promise.ets +++ b/ets2panda/linter/test/main/structural_identity_promise.ets @@ -32,4 +32,10 @@ class PromiseTest { public async bar(): Promise { return this.foo(); // No error in ArkTS 1.2 } +} + +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/structural_identity_promise.ets.arkts2.json b/ets2panda/linter/test/main/structural_identity_promise.ets.arkts2.json index ca88f857e9..239919cb52 100644 --- a/ets2panda/linter/test/main/structural_identity_promise.ets.arkts2.json +++ b/ets2panda/linter/test/main/structural_identity_promise.ets.arkts2.json @@ -13,5 +13,26 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [] + "result": [ + { + "line": 39, + "column": 74, + "endLine": 39, + "endColumn": 81, + "problem": "NoTsLikeSmartType", + "suggest": "", + "rule": "Smart type differences (arkts-no-ts-like-smart-type)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 83, + "endLine": 39, + "endColumn": 85, + "problem": "NoTsLikeSmartType", + "suggest": "", + "rule": "Smart type differences (arkts-no-ts-like-smart-type)", + "severity": "ERROR" + } + ] } \ No newline at end of file -- Gitee