From 5cb595f44501d9667ebcb7f1d969250bfc69b3ee Mon Sep 17 00:00:00 2001 From: cihatfurkaneken Date: Wed, 27 Aug 2025 09:41:32 +0300 Subject: [PATCH] no-ts-like-smart-type wrong parameter scan Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICUXNJ Signed-off-by: cihatfurkaneken --- ets2panda/linter/src/lib/TypeScriptLinter.ts | 2 +- .../test/main/no_ts_like_smart_type.ets | 9 +++++++++ .../no_ts_like_smart_type.ets.arkts2.json | 20 +++++++++++++++++++ .../test/main/no_ts_like_smart_type.ets.json | 10 ++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/ets2panda/linter/src/lib/TypeScriptLinter.ts b/ets2panda/linter/src/lib/TypeScriptLinter.ts index 15cb57df97..336dc94bb3 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -12456,7 +12456,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } return; } - if (actualTypeName !== expectedType) { + if (actualTypeName !== expectedType && expectedType !== 'any') { this.incrementCounters(arg, FaultID.NoTsLikeSmartType); } } 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 d7b51db205..367815236a 100755 --- a/ets2panda/linter/test/main/no_ts_like_smart_type.ets +++ b/ets2panda/linter/test/main/no_ts_like_smart_type.ets @@ -365,3 +365,12 @@ class Downloader { } } } + +function isOperator(operator) { + return (operator === '+' || operator === "-") +} +function test(value: string) { + if (isOperator(value)) { //no error + console.log('5') + } +} \ 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 14bb6037da..e62b41b882 100644 --- 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 @@ -310,6 +310,26 @@ "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", "severity": "ERROR" }, + { + "line": 369, + "column": 21, + "endLine": 369, + "endColumn": 29, + "problem": "ParameterType", + "suggest": "", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", + "severity": "ERROR" + }, + { + "line": 369, + "column": 21, + "endLine": 369, + "endColumn": 29, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, { "line": 137, "column": 5, diff --git a/ets2panda/linter/test/main/no_ts_like_smart_type.ets.json b/ets2panda/linter/test/main/no_ts_like_smart_type.ets.json index 1956437aee..996a2de958 100644 --- a/ets2panda/linter/test/main/no_ts_like_smart_type.ets.json +++ b/ets2panda/linter/test/main/no_ts_like_smart_type.ets.json @@ -90,6 +90,16 @@ "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", "severity": "ERROR" }, + { + "line": 369, + "column": 21, + "endLine": 369, + "endColumn": 29, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, { "line": 137, "column": 5, -- Gitee