diff --git a/ets2panda/linter/src/lib/TypeScriptLinter.ts b/ets2panda/linter/src/lib/TypeScriptLinter.ts index 15cb57df9756729c54421c58b47a3e02152778ff..336dc94bb31631be11fbd0653fefe10775bea8d0 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 d7b51db205f71bcce62ef33cbef39d93e6621c6c..367815236a2855e0d75090a8dcf1bea2654df18e 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 14bb6037da9ced68fe2554de13bd02a18e4da5ef..e62b41b88259ffcc40d2716fc777308e6fe69436 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 1956437aeefa800c27da7d5b6fee943d858db914..996a2de958ed13a4bc7319d32937a07b7e84fb85 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,