From 0d417f5a0e246d09149b8bfc02e5e17eed99495d Mon Sep 17 00:00:00 2001 From: beratagaca_9a91 Date: Fri, 11 Jul 2025 10:07:57 +0300 Subject: [PATCH] fix interop-ts2s-static-access-ts-type rule Description: added isMixedEnum check Issue: #ICLO03 Signed-off-by: beratagaca_9a91 --- ets2panda/linter/src/lib/TypeScriptLinter.ts | 35 ++- .../test/interop/ignore_files/unique_types.ts | 6 + .../linter/test/interop/unique_types.ets | 2 + .../test/interop/unique_types.ets.arkts2.json | 236 +++++++------- .../interop/unique_types.ets.autofix.json | 295 ++++++++++-------- .../linter/test/interop/unique_types.ets.json | 44 +-- .../test/interop/unique_types.ets.migrate.ets | 2 + .../interop/unique_types.ets.migrate.json | 198 ++++++------ 8 files changed, 461 insertions(+), 357 deletions(-) diff --git a/ets2panda/linter/src/lib/TypeScriptLinter.ts b/ets2panda/linter/src/lib/TypeScriptLinter.ts index 393b46cc96..41c4f211f9 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -1426,12 +1426,45 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { TsUtils.isAnyType(baseType) || TsUtils.isUnknownType(baseType) || this.tsUtils.isStdFunctionType(baseType) || - typeString === 'symbol' + typeString === 'symbol' || + this.isMixedEnum(baseType) ) { this.incrementCounters(node, FaultID.InteropDirectAccessToTSTypes); } } + private isMixedEnum(type: ts.Type): boolean { + const symbol = type.getSymbol(); + if (!symbol) { + return false; + } + + const declarations = symbol.getDeclarations(); + if (!declarations) { + return false; + } + + for (const decl of declarations) { + if (ts.isEnumDeclaration(decl)) { + const initializerTypes = new Set(); + + for (const member of decl.members) { + if (member.initializer) { + const memberType = this.tsTypeChecker.getTypeAtLocation(member.initializer); + const baseTypeStr = this.tsTypeChecker.typeToString(this.tsTypeChecker.getBaseTypeOfLiteralType(memberType)); + initializerTypes.add(baseTypeStr); + } + } + + if (initializerTypes.size > 1) { + return true; + } + } + } + + return false; + } + checkUnionTypes(propertyAccessNode: ts.PropertyAccessExpression): void { if (!this.options.arkts2) { return; diff --git a/ets2panda/linter/test/interop/ignore_files/unique_types.ts b/ets2panda/linter/test/interop/ignore_files/unique_types.ts index f56856f73a..60cf239e96 100644 --- a/ets2panda/linter/test/interop/ignore_files/unique_types.ts +++ b/ets2panda/linter/test/interop/ignore_files/unique_types.ts @@ -30,6 +30,12 @@ export let function_var: Function = function() { return true; }; +//mixed enum +export enum enum_var { + a = 0, + b = '1', +} + export class A { static instance = new A(); } diff --git a/ets2panda/linter/test/interop/unique_types.ets b/ets2panda/linter/test/interop/unique_types.ets index 9c16a54d2b..10b1d97c33 100644 --- a/ets2panda/linter/test/interop/unique_types.ets +++ b/ets2panda/linter/test/interop/unique_types.ets @@ -18,6 +18,7 @@ import { unknown_var, symbol_var, function_var, + enum_var, A, B, TestHelper, @@ -71,6 +72,7 @@ typeof symbol_var === 'object'; function_var() === true; A.instance; let obj: B = { name: "hello" }; +enum_var.a === 0; export function test_ts_non_standard_exception(testCaseRet: Array) { let test_helper = new TestHelper("TEST_TS_NON_STANDARD_EXCEPTION"); diff --git a/ets2panda/linter/test/interop/unique_types.ets.arkts2.json b/ets2panda/linter/test/interop/unique_types.ets.arkts2.json index 7fb34afcb3..ad93ff0af7 100644 --- a/ets2panda/linter/test/interop/unique_types.ets.arkts2.json +++ b/ets2panda/linter/test/interop/unique_types.ets.arkts2.json @@ -15,9 +15,9 @@ ], "result": [ { - "line": 68, + "line": 69, "column": 8, - "endLine": 68, + "endLine": 69, "endColumn": 15, "problem": "InteropDirectAccessToTSTypes", "suggest": "", @@ -25,9 +25,9 @@ "severity": "ERROR" }, { - "line": 69, + "line": 70, "column": 8, - "endLine": 69, + "endLine": 70, "endColumn": 19, "problem": "InteropDirectAccessToTSTypes", "suggest": "", @@ -35,9 +35,9 @@ "severity": "ERROR" }, { - "line": 70, + "line": 71, "column": 8, - "endLine": 70, + "endLine": 71, "endColumn": 18, "problem": "InteropDirectAccessToTSTypes", "suggest": "", @@ -45,9 +45,9 @@ "severity": "ERROR" }, { - "line": 71, + "line": 72, "column": 1, - "endLine": 71, + "endLine": 72, "endColumn": 13, "problem": "ExplicitFunctionType", "suggest": "", @@ -55,9 +55,9 @@ "severity": "ERROR" }, { - "line": 71, + "line": 72, "column": 1, - "endLine": 71, + "endLine": 72, "endColumn": 13, "problem": "InteropDirectAccessToTSTypes", "suggest": "", @@ -65,9 +65,29 @@ "severity": "ERROR" }, { - "line": 76, + "line": 75, + "column": 1, + "endLine": 75, + "endColumn": 9, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 75, + "column": 16, + "endLine": 75, + "endColumn": 17, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 78, "column": 7, - "endLine": 76, + "endLine": 78, "endColumn": 69, "problem": "AnyType", "suggest": "", @@ -75,9 +95,9 @@ "severity": "ERROR" }, { - "line": 76, + "line": 78, "column": 25, - "endLine": 76, + "endLine": 78, "endColumn": 35, "problem": "DynamicCtorCall", "suggest": "", @@ -85,9 +105,9 @@ "severity": "ERROR" }, { - "line": 80, + "line": 82, "column": 7, - "endLine": 80, + "endLine": 82, "endColumn": 21, "problem": "InteropTSFunctionInvoke", "suggest": "", @@ -95,9 +115,9 @@ "severity": "ERROR" }, { - "line": 82, + "line": 84, "column": 30, - "endLine": 82, + "endLine": 84, "endColumn": 33, "problem": "NumericSemantics", "suggest": "", @@ -105,9 +125,9 @@ "severity": "ERROR" }, { - "line": 89, + "line": 91, "column": 7, - "endLine": 89, + "endLine": 91, "endColumn": 22, "problem": "InteropTSFunctionInvoke", "suggest": "", @@ -115,9 +135,9 @@ "severity": "ERROR" }, { - "line": 98, + "line": 100, "column": 7, - "endLine": 98, + "endLine": 100, "endColumn": 21, "problem": "InteropTSFunctionInvoke", "suggest": "", @@ -125,9 +145,9 @@ "severity": "ERROR" }, { - "line": 107, + "line": 109, "column": 7, - "endLine": 107, + "endLine": 109, "endColumn": 21, "problem": "InteropTSFunctionInvoke", "suggest": "", @@ -135,9 +155,9 @@ "severity": "ERROR" }, { - "line": 116, + "line": 118, "column": 7, - "endLine": 116, + "endLine": 118, "endColumn": 18, "problem": "InteropTSFunctionInvoke", "suggest": "", @@ -145,9 +165,9 @@ "severity": "ERROR" }, { - "line": 138, + "line": 140, "column": 36, - "endLine": 138, + "endLine": 140, "endColumn": 39, "problem": "NumericSemantics", "suggest": "", @@ -155,9 +175,9 @@ "severity": "ERROR" }, { - "line": 138, + "line": 140, "column": 60, - "endLine": 138, + "endLine": 140, "endColumn": 63, "problem": "NumericSemantics", "suggest": "", @@ -165,9 +185,9 @@ "severity": "ERROR" }, { - "line": 158, + "line": 160, "column": 7, - "endLine": 158, + "endLine": 160, "endColumn": 58, "problem": "AnyType", "suggest": "", @@ -175,9 +195,9 @@ "severity": "ERROR" }, { - "line": 158, + "line": 160, "column": 25, - "endLine": 158, + "endLine": 160, "endColumn": 35, "problem": "DynamicCtorCall", "suggest": "", @@ -185,9 +205,9 @@ "severity": "ERROR" }, { - "line": 176, + "line": 178, "column": 1, - "endLine": 176, + "endLine": 178, "endColumn": 18, "problem": "DecoratorsNotSupported", "suggest": "", @@ -195,9 +215,9 @@ "severity": "ERROR" }, { - "line": 181, + "line": 183, "column": 3, - "endLine": 181, + "endLine": 183, "endColumn": 21, "problem": "DecoratorsNotSupported", "suggest": "", @@ -205,9 +225,9 @@ "severity": "ERROR" }, { - "line": 187, + "line": 189, "column": 3, - "endLine": 187, + "endLine": 189, "endColumn": 19, "problem": "DecoratorsNotSupported", "suggest": "", @@ -215,9 +235,9 @@ "severity": "ERROR" }, { - "line": 195, + "line": 197, "column": 22, - "endLine": 195, + "endLine": 197, "endColumn": 41, "problem": "DecoratorsNotSupported", "suggest": "", @@ -225,9 +245,9 @@ "severity": "ERROR" }, { - "line": 195, + "line": 197, "column": 52, - "endLine": 195, + "endLine": 197, "endColumn": 55, "problem": "AnyType", "suggest": "", @@ -235,9 +255,9 @@ "severity": "ERROR" }, { - "line": 203, + "line": 205, "column": 3, - "endLine": 203, + "endLine": 205, "endColumn": 21, "problem": "DecoratorsNotSupported", "suggest": "", @@ -245,9 +265,9 @@ "severity": "ERROR" }, { - "line": 215, + "line": 217, "column": 3, - "endLine": 215, + "endLine": 217, "endColumn": 18, "problem": "DecoratorsNotSupported", "suggest": "", @@ -255,9 +275,9 @@ "severity": "ERROR" }, { - "line": 226, + "line": 228, "column": 3, - "endLine": 226, + "endLine": 228, "endColumn": 20, "problem": "DecoratorsNotSupported", "suggest": "", @@ -265,9 +285,9 @@ "severity": "ERROR" }, { - "line": 231, + "line": 233, "column": 5, - "endLine": 231, + "endLine": 233, "endColumn": 23, "problem": "DecoratorsNotSupported", "suggest": "", @@ -275,9 +295,9 @@ "severity": "ERROR" }, { - "line": 237, + "line": 239, "column": 5, - "endLine": 237, + "endLine": 239, "endColumn": 21, "problem": "DecoratorsNotSupported", "suggest": "", @@ -285,9 +305,9 @@ "severity": "ERROR" }, { - "line": 245, + "line": 247, "column": 24, - "endLine": 245, + "endLine": 247, "endColumn": 43, "problem": "DecoratorsNotSupported", "suggest": "", @@ -295,9 +315,9 @@ "severity": "ERROR" }, { - "line": 245, + "line": 247, "column": 54, - "endLine": 245, + "endLine": 247, "endColumn": 57, "problem": "AnyType", "suggest": "", @@ -305,9 +325,9 @@ "severity": "ERROR" }, { - "line": 256, + "line": 258, "column": 5, - "endLine": 256, + "endLine": 258, "endColumn": 23, "problem": "DecoratorsNotSupported", "suggest": "", @@ -315,9 +335,9 @@ "severity": "ERROR" }, { - "line": 271, + "line": 273, "column": 5, - "endLine": 271, + "endLine": 273, "endColumn": 21, "problem": "DecoratorsNotSupported", "suggest": "", @@ -325,9 +345,9 @@ "severity": "ERROR" }, { - "line": 282, + "line": 284, "column": 7, - "endLine": 282, + "endLine": 284, "endColumn": 57, "problem": "AnyType", "suggest": "", @@ -335,9 +355,9 @@ "severity": "ERROR" }, { - "line": 282, + "line": 284, "column": 25, - "endLine": 282, + "endLine": 284, "endColumn": 35, "problem": "DynamicCtorCall", "suggest": "", @@ -345,9 +365,9 @@ "severity": "ERROR" }, { - "line": 303, + "line": 305, "column": 7, - "endLine": 303, + "endLine": 305, "endColumn": 60, "problem": "AnyType", "suggest": "", @@ -355,9 +375,9 @@ "severity": "ERROR" }, { - "line": 303, + "line": 305, "column": 25, - "endLine": 303, + "endLine": 305, "endColumn": 35, "problem": "DynamicCtorCall", "suggest": "", @@ -365,9 +385,9 @@ "severity": "ERROR" }, { - "line": 306, + "line": 308, "column": 26, - "endLine": 306, + "endLine": 308, "endColumn": 33, "problem": "DynamicCtorCall", "suggest": "", @@ -375,9 +395,9 @@ "severity": "ERROR" }, { - "line": 307, + "line": 309, "column": 51, - "endLine": 307, + "endLine": 309, "endColumn": 58, "problem": "DynamicCtorCall", "suggest": "", @@ -385,9 +405,9 @@ "severity": "ERROR" }, { - "line": 308, + "line": 310, "column": 52, - "endLine": 308, + "endLine": 310, "endColumn": 59, "problem": "DynamicCtorCall", "suggest": "", @@ -395,9 +415,9 @@ "severity": "ERROR" }, { - "line": 309, + "line": 311, "column": 46, - "endLine": 309, + "endLine": 311, "endColumn": 53, "problem": "DynamicCtorCall", "suggest": "", @@ -405,9 +425,9 @@ "severity": "ERROR" }, { - "line": 310, + "line": 312, "column": 33, - "endLine": 310, + "endLine": 312, "endColumn": 40, "problem": "DynamicCtorCall", "suggest": "", @@ -415,9 +435,9 @@ "severity": "ERROR" }, { - "line": 311, + "line": 313, "column": 39, - "endLine": 311, + "endLine": 313, "endColumn": 46, "problem": "DynamicCtorCall", "suggest": "", @@ -425,9 +445,9 @@ "severity": "ERROR" }, { - "line": 312, + "line": 314, "column": 35, - "endLine": 312, + "endLine": 314, "endColumn": 42, "problem": "DynamicCtorCall", "suggest": "", @@ -435,9 +455,9 @@ "severity": "ERROR" }, { - "line": 313, + "line": 315, "column": 35, - "endLine": 313, + "endLine": 315, "endColumn": 42, "problem": "DynamicCtorCall", "suggest": "", @@ -445,9 +465,9 @@ "severity": "ERROR" }, { - "line": 314, + "line": 316, "column": 31, - "endLine": 314, + "endLine": 316, "endColumn": 38, "problem": "DynamicCtorCall", "suggest": "", @@ -455,9 +475,9 @@ "severity": "ERROR" }, { - "line": 315, + "line": 317, "column": 31, - "endLine": 315, + "endLine": 317, "endColumn": 38, "problem": "DynamicCtorCall", "suggest": "", @@ -465,9 +485,9 @@ "severity": "ERROR" }, { - "line": 316, + "line": 318, "column": 33, - "endLine": 316, + "endLine": 318, "endColumn": 40, "problem": "DynamicCtorCall", "suggest": "", @@ -475,9 +495,9 @@ "severity": "ERROR" }, { - "line": 324, + "line": 326, "column": 23, - "endLine": 324, + "endLine": 326, "endColumn": 24, "problem": "NumericSemantics", "suggest": "", @@ -485,9 +505,9 @@ "severity": "ERROR" }, { - "line": 355, + "line": 357, "column": 7, - "endLine": 355, + "endLine": 357, "endColumn": 61, "problem": "AnyType", "suggest": "", @@ -495,9 +515,9 @@ "severity": "ERROR" }, { - "line": 355, + "line": 357, "column": 25, - "endLine": 355, + "endLine": 357, "endColumn": 35, "problem": "DynamicCtorCall", "suggest": "", @@ -505,9 +525,9 @@ "severity": "ERROR" }, { - "line": 373, + "line": 375, "column": 23, - "endLine": 373, + "endLine": 375, "endColumn": 24, "problem": "NumericSemantics", "suggest": "", @@ -515,9 +535,9 @@ "severity": "ERROR" }, { - "line": 182, + "line": 184, "column": 3, - "endLine": 182, + "endLine": 184, "endColumn": 13, "problem": "StrictDiagnostic", "suggest": "Property 'myProperty' has no initializer and is not definitely assigned in the constructor.", @@ -525,9 +545,9 @@ "severity": "ERROR" }, { - "line": 202, + "line": 204, "column": 11, - "endLine": 202, + "endLine": 204, "endColumn": 16, "problem": "StrictDiagnostic", "suggest": "Property '_name' has no initializer and is not definitely assigned in the constructor.", @@ -535,9 +555,9 @@ "severity": "ERROR" }, { - "line": 214, + "line": 216, "column": 11, - "endLine": 214, + "endLine": 216, "endColumn": 15, "problem": "StrictDiagnostic", "suggest": "Property '_age' has no initializer and is not definitely assigned in the constructor.", @@ -545,9 +565,9 @@ "severity": "ERROR" }, { - "line": 232, + "line": 234, "column": 5, - "endLine": 232, + "endLine": 234, "endColumn": 15, "problem": "StrictDiagnostic", "suggest": "Property 'myProperty' has no initializer and is not definitely assigned in the constructor.", diff --git a/ets2panda/linter/test/interop/unique_types.ets.autofix.json b/ets2panda/linter/test/interop/unique_types.ets.autofix.json index bdb124b2ed..203ab57067 100644 --- a/ets2panda/linter/test/interop/unique_types.ets.autofix.json +++ b/ets2panda/linter/test/interop/unique_types.ets.autofix.json @@ -15,9 +15,9 @@ ], "result": [ { - "line": 68, + "line": 69, "column": 8, - "endLine": 68, + "endLine": 69, "endColumn": 15, "problem": "InteropDirectAccessToTSTypes", "suggest": "", @@ -25,9 +25,9 @@ "severity": "ERROR" }, { - "line": 69, + "line": 70, "column": 8, - "endLine": 69, + "endLine": 70, "endColumn": 19, "problem": "InteropDirectAccessToTSTypes", "suggest": "", @@ -35,9 +35,9 @@ "severity": "ERROR" }, { - "line": 70, + "line": 71, "column": 8, - "endLine": 70, + "endLine": 71, "endColumn": 18, "problem": "InteropDirectAccessToTSTypes", "suggest": "", @@ -45,19 +45,19 @@ "severity": "ERROR" }, { - "line": 71, + "line": 72, "column": 1, - "endLine": 71, + "endLine": 72, "endColumn": 13, "problem": "ExplicitFunctionType", "autofix": [ { - "start": 1767, - "end": 1779, + "start": 1778, + "end": 1790, "replacementText": "function_var.unsafeCall", - "line": 71, + "line": 72, "column": 1, - "endLine": 71, + "endLine": 72, "endColumn": 13 } ], @@ -66,9 +66,9 @@ "severity": "ERROR" }, { - "line": 71, + "line": 72, "column": 1, - "endLine": 71, + "endLine": 72, "endColumn": 13, "problem": "InteropDirectAccessToTSTypes", "suggest": "", @@ -76,9 +76,40 @@ "severity": "ERROR" }, { - "line": 76, + "line": 75, + "column": 1, + "endLine": 75, + "endColumn": 9, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 75, + "column": 16, + "endLine": 75, + "endColumn": 17, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1862, + "end": 1863, + "replacementText": "0.0", + "line": 75, + "column": 16, + "endLine": 75, + "endColumn": 17 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 78, "column": 7, - "endLine": 76, + "endLine": 78, "endColumn": 69, "problem": "AnyType", "suggest": "", @@ -86,9 +117,9 @@ "severity": "ERROR" }, { - "line": 76, + "line": 78, "column": 25, - "endLine": 76, + "endLine": 78, "endColumn": 35, "problem": "DynamicCtorCall", "suggest": "", @@ -96,9 +127,9 @@ "severity": "ERROR" }, { - "line": 80, + "line": 82, "column": 7, - "endLine": 80, + "endLine": 82, "endColumn": 21, "problem": "InteropTSFunctionInvoke", "suggest": "", @@ -106,19 +137,19 @@ "severity": "ERROR" }, { - "line": 82, + "line": 84, "column": 30, - "endLine": 82, + "endLine": 84, "endColumn": 33, "problem": "NumericSemantics", "autofix": [ { - "start": 2118, - "end": 2121, + "start": 2147, + "end": 2150, "replacementText": "123.0", - "line": 82, + "line": 84, "column": 30, - "endLine": 82, + "endLine": 84, "endColumn": 33 } ], @@ -127,9 +158,9 @@ "severity": "ERROR" }, { - "line": 89, + "line": 91, "column": 7, - "endLine": 89, + "endLine": 91, "endColumn": 22, "problem": "InteropTSFunctionInvoke", "suggest": "", @@ -137,9 +168,9 @@ "severity": "ERROR" }, { - "line": 98, + "line": 100, "column": 7, - "endLine": 98, + "endLine": 100, "endColumn": 21, "problem": "InteropTSFunctionInvoke", "suggest": "", @@ -147,9 +178,9 @@ "severity": "ERROR" }, { - "line": 107, + "line": 109, "column": 7, - "endLine": 107, + "endLine": 109, "endColumn": 21, "problem": "InteropTSFunctionInvoke", "suggest": "", @@ -157,9 +188,9 @@ "severity": "ERROR" }, { - "line": 116, + "line": 118, "column": 7, - "endLine": 116, + "endLine": 118, "endColumn": 18, "problem": "InteropTSFunctionInvoke", "suggest": "", @@ -167,19 +198,19 @@ "severity": "ERROR" }, { - "line": 138, + "line": 140, "column": 36, - "endLine": 138, + "endLine": 140, "endColumn": 39, "problem": "NumericSemantics", "autofix": [ { - "start": 3384, - "end": 3387, + "start": 3413, + "end": 3416, "replacementText": "123.0", - "line": 138, + "line": 140, "column": 36, - "endLine": 138, + "endLine": 140, "endColumn": 39 } ], @@ -188,19 +219,19 @@ "severity": "ERROR" }, { - "line": 138, + "line": 140, "column": 60, - "endLine": 138, + "endLine": 140, "endColumn": 63, "problem": "NumericSemantics", "autofix": [ { - "start": 3408, - "end": 3411, + "start": 3437, + "end": 3440, "replacementText": "456.0", - "line": 138, + "line": 140, "column": 60, - "endLine": 138, + "endLine": 140, "endColumn": 63 } ], @@ -209,9 +240,9 @@ "severity": "ERROR" }, { - "line": 158, + "line": 160, "column": 7, - "endLine": 158, + "endLine": 160, "endColumn": 58, "problem": "AnyType", "suggest": "", @@ -219,9 +250,9 @@ "severity": "ERROR" }, { - "line": 158, + "line": 160, "column": 25, - "endLine": 158, + "endLine": 160, "endColumn": 35, "problem": "DynamicCtorCall", "suggest": "", @@ -229,9 +260,9 @@ "severity": "ERROR" }, { - "line": 176, + "line": 178, "column": 1, - "endLine": 176, + "endLine": 178, "endColumn": 18, "problem": "DecoratorsNotSupported", "suggest": "", @@ -239,9 +270,9 @@ "severity": "ERROR" }, { - "line": 181, + "line": 183, "column": 3, - "endLine": 181, + "endLine": 183, "endColumn": 21, "problem": "DecoratorsNotSupported", "suggest": "", @@ -249,9 +280,9 @@ "severity": "ERROR" }, { - "line": 187, + "line": 189, "column": 3, - "endLine": 187, + "endLine": 189, "endColumn": 19, "problem": "DecoratorsNotSupported", "suggest": "", @@ -259,9 +290,9 @@ "severity": "ERROR" }, { - "line": 195, + "line": 197, "column": 22, - "endLine": 195, + "endLine": 197, "endColumn": 41, "problem": "DecoratorsNotSupported", "suggest": "", @@ -269,9 +300,9 @@ "severity": "ERROR" }, { - "line": 195, + "line": 197, "column": 52, - "endLine": 195, + "endLine": 197, "endColumn": 55, "problem": "AnyType", "suggest": "", @@ -279,9 +310,9 @@ "severity": "ERROR" }, { - "line": 203, + "line": 205, "column": 3, - "endLine": 203, + "endLine": 205, "endColumn": 21, "problem": "DecoratorsNotSupported", "suggest": "", @@ -289,9 +320,9 @@ "severity": "ERROR" }, { - "line": 215, + "line": 217, "column": 3, - "endLine": 215, + "endLine": 217, "endColumn": 18, "problem": "DecoratorsNotSupported", "suggest": "", @@ -299,9 +330,9 @@ "severity": "ERROR" }, { - "line": 226, + "line": 228, "column": 3, - "endLine": 226, + "endLine": 228, "endColumn": 20, "problem": "DecoratorsNotSupported", "suggest": "", @@ -309,9 +340,9 @@ "severity": "ERROR" }, { - "line": 231, + "line": 233, "column": 5, - "endLine": 231, + "endLine": 233, "endColumn": 23, "problem": "DecoratorsNotSupported", "suggest": "", @@ -319,9 +350,9 @@ "severity": "ERROR" }, { - "line": 237, + "line": 239, "column": 5, - "endLine": 237, + "endLine": 239, "endColumn": 21, "problem": "DecoratorsNotSupported", "suggest": "", @@ -329,9 +360,9 @@ "severity": "ERROR" }, { - "line": 245, + "line": 247, "column": 24, - "endLine": 245, + "endLine": 247, "endColumn": 43, "problem": "DecoratorsNotSupported", "suggest": "", @@ -339,9 +370,9 @@ "severity": "ERROR" }, { - "line": 245, + "line": 247, "column": 54, - "endLine": 245, + "endLine": 247, "endColumn": 57, "problem": "AnyType", "suggest": "", @@ -349,9 +380,9 @@ "severity": "ERROR" }, { - "line": 256, + "line": 258, "column": 5, - "endLine": 256, + "endLine": 258, "endColumn": 23, "problem": "DecoratorsNotSupported", "suggest": "", @@ -359,9 +390,9 @@ "severity": "ERROR" }, { - "line": 271, + "line": 273, "column": 5, - "endLine": 271, + "endLine": 273, "endColumn": 21, "problem": "DecoratorsNotSupported", "suggest": "", @@ -369,9 +400,9 @@ "severity": "ERROR" }, { - "line": 282, + "line": 284, "column": 7, - "endLine": 282, + "endLine": 284, "endColumn": 57, "problem": "AnyType", "suggest": "", @@ -379,9 +410,9 @@ "severity": "ERROR" }, { - "line": 282, + "line": 284, "column": 25, - "endLine": 282, + "endLine": 284, "endColumn": 35, "problem": "DynamicCtorCall", "suggest": "", @@ -389,9 +420,9 @@ "severity": "ERROR" }, { - "line": 303, + "line": 305, "column": 7, - "endLine": 303, + "endLine": 305, "endColumn": 60, "problem": "AnyType", "suggest": "", @@ -399,9 +430,9 @@ "severity": "ERROR" }, { - "line": 303, + "line": 305, "column": 25, - "endLine": 303, + "endLine": 305, "endColumn": 35, "problem": "DynamicCtorCall", "suggest": "", @@ -409,9 +440,9 @@ "severity": "ERROR" }, { - "line": 306, + "line": 308, "column": 26, - "endLine": 306, + "endLine": 308, "endColumn": 33, "problem": "DynamicCtorCall", "suggest": "", @@ -419,9 +450,9 @@ "severity": "ERROR" }, { - "line": 307, + "line": 309, "column": 51, - "endLine": 307, + "endLine": 309, "endColumn": 58, "problem": "DynamicCtorCall", "suggest": "", @@ -429,9 +460,9 @@ "severity": "ERROR" }, { - "line": 308, + "line": 310, "column": 52, - "endLine": 308, + "endLine": 310, "endColumn": 59, "problem": "DynamicCtorCall", "suggest": "", @@ -439,9 +470,9 @@ "severity": "ERROR" }, { - "line": 309, + "line": 311, "column": 46, - "endLine": 309, + "endLine": 311, "endColumn": 53, "problem": "DynamicCtorCall", "suggest": "", @@ -449,9 +480,9 @@ "severity": "ERROR" }, { - "line": 310, + "line": 312, "column": 33, - "endLine": 310, + "endLine": 312, "endColumn": 40, "problem": "DynamicCtorCall", "suggest": "", @@ -459,9 +490,9 @@ "severity": "ERROR" }, { - "line": 311, + "line": 313, "column": 39, - "endLine": 311, + "endLine": 313, "endColumn": 46, "problem": "DynamicCtorCall", "suggest": "", @@ -469,9 +500,9 @@ "severity": "ERROR" }, { - "line": 312, + "line": 314, "column": 35, - "endLine": 312, + "endLine": 314, "endColumn": 42, "problem": "DynamicCtorCall", "suggest": "", @@ -479,9 +510,9 @@ "severity": "ERROR" }, { - "line": 313, + "line": 315, "column": 35, - "endLine": 313, + "endLine": 315, "endColumn": 42, "problem": "DynamicCtorCall", "suggest": "", @@ -489,9 +520,9 @@ "severity": "ERROR" }, { - "line": 314, + "line": 316, "column": 31, - "endLine": 314, + "endLine": 316, "endColumn": 38, "problem": "DynamicCtorCall", "suggest": "", @@ -499,9 +530,9 @@ "severity": "ERROR" }, { - "line": 315, + "line": 317, "column": 31, - "endLine": 315, + "endLine": 317, "endColumn": 38, "problem": "DynamicCtorCall", "suggest": "", @@ -509,9 +540,9 @@ "severity": "ERROR" }, { - "line": 316, + "line": 318, "column": 33, - "endLine": 316, + "endLine": 318, "endColumn": 40, "problem": "DynamicCtorCall", "suggest": "", @@ -519,19 +550,19 @@ "severity": "ERROR" }, { - "line": 324, + "line": 326, "column": 23, - "endLine": 324, + "endLine": 326, "endColumn": 24, "problem": "NumericSemantics", "autofix": [ { - "start": 7971, - "end": 7972, + "start": 8000, + "end": 8001, "replacementText": "1.0", - "line": 324, + "line": 326, "column": 23, - "endLine": 324, + "endLine": 326, "endColumn": 24 } ], @@ -540,9 +571,9 @@ "severity": "ERROR" }, { - "line": 355, + "line": 357, "column": 7, - "endLine": 355, + "endLine": 357, "endColumn": 61, "problem": "AnyType", "suggest": "", @@ -550,9 +581,9 @@ "severity": "ERROR" }, { - "line": 355, + "line": 357, "column": 25, - "endLine": 355, + "endLine": 357, "endColumn": 35, "problem": "DynamicCtorCall", "suggest": "", @@ -560,19 +591,19 @@ "severity": "ERROR" }, { - "line": 373, + "line": 375, "column": 23, - "endLine": 373, + "endLine": 375, "endColumn": 24, "problem": "NumericSemantics", "autofix": [ { - "start": 9425, - "end": 9426, + "start": 9454, + "end": 9455, "replacementText": "1.0", - "line": 373, + "line": 375, "column": 23, - "endLine": 373, + "endLine": 375, "endColumn": 24 } ], @@ -581,9 +612,9 @@ "severity": "ERROR" }, { - "line": 182, + "line": 184, "column": 3, - "endLine": 182, + "endLine": 184, "endColumn": 13, "problem": "StrictDiagnostic", "suggest": "Property 'myProperty' has no initializer and is not definitely assigned in the constructor.", @@ -591,9 +622,9 @@ "severity": "ERROR" }, { - "line": 202, + "line": 204, "column": 11, - "endLine": 202, + "endLine": 204, "endColumn": 16, "problem": "StrictDiagnostic", "suggest": "Property '_name' has no initializer and is not definitely assigned in the constructor.", @@ -601,9 +632,9 @@ "severity": "ERROR" }, { - "line": 214, + "line": 216, "column": 11, - "endLine": 214, + "endLine": 216, "endColumn": 15, "problem": "StrictDiagnostic", "suggest": "Property '_age' has no initializer and is not definitely assigned in the constructor.", @@ -611,9 +642,9 @@ "severity": "ERROR" }, { - "line": 232, + "line": 234, "column": 5, - "endLine": 232, + "endLine": 234, "endColumn": 15, "problem": "StrictDiagnostic", "suggest": "Property 'myProperty' has no initializer and is not definitely assigned in the constructor.", diff --git a/ets2panda/linter/test/interop/unique_types.ets.json b/ets2panda/linter/test/interop/unique_types.ets.json index 017acb4fb6..b8a27de873 100644 --- a/ets2panda/linter/test/interop/unique_types.ets.json +++ b/ets2panda/linter/test/interop/unique_types.ets.json @@ -15,9 +15,9 @@ ], "result": [ { - "line": 76, + "line": 78, "column": 7, - "endLine": 76, + "endLine": 78, "endColumn": 69, "problem": "AnyType", "suggest": "", @@ -25,9 +25,9 @@ "severity": "ERROR" }, { - "line": 158, + "line": 160, "column": 7, - "endLine": 158, + "endLine": 160, "endColumn": 58, "problem": "AnyType", "suggest": "", @@ -35,9 +35,9 @@ "severity": "ERROR" }, { - "line": 195, + "line": 197, "column": 52, - "endLine": 195, + "endLine": 197, "endColumn": 55, "problem": "AnyType", "suggest": "", @@ -45,9 +45,9 @@ "severity": "ERROR" }, { - "line": 245, + "line": 247, "column": 54, - "endLine": 245, + "endLine": 247, "endColumn": 57, "problem": "AnyType", "suggest": "", @@ -55,9 +55,9 @@ "severity": "ERROR" }, { - "line": 282, + "line": 284, "column": 7, - "endLine": 282, + "endLine": 284, "endColumn": 57, "problem": "AnyType", "suggest": "", @@ -65,9 +65,9 @@ "severity": "ERROR" }, { - "line": 303, + "line": 305, "column": 7, - "endLine": 303, + "endLine": 305, "endColumn": 60, "problem": "AnyType", "suggest": "", @@ -75,9 +75,9 @@ "severity": "ERROR" }, { - "line": 355, + "line": 357, "column": 7, - "endLine": 355, + "endLine": 357, "endColumn": 61, "problem": "AnyType", "suggest": "", @@ -85,9 +85,9 @@ "severity": "ERROR" }, { - "line": 182, + "line": 184, "column": 3, - "endLine": 182, + "endLine": 184, "endColumn": 13, "problem": "StrictDiagnostic", "suggest": "Property 'myProperty' has no initializer and is not definitely assigned in the constructor.", @@ -95,9 +95,9 @@ "severity": "ERROR" }, { - "line": 202, + "line": 204, "column": 11, - "endLine": 202, + "endLine": 204, "endColumn": 16, "problem": "StrictDiagnostic", "suggest": "Property '_name' has no initializer and is not definitely assigned in the constructor.", @@ -105,9 +105,9 @@ "severity": "ERROR" }, { - "line": 214, + "line": 216, "column": 11, - "endLine": 214, + "endLine": 216, "endColumn": 15, "problem": "StrictDiagnostic", "suggest": "Property '_age' has no initializer and is not definitely assigned in the constructor.", @@ -115,9 +115,9 @@ "severity": "ERROR" }, { - "line": 232, + "line": 234, "column": 5, - "endLine": 232, + "endLine": 234, "endColumn": 15, "problem": "StrictDiagnostic", "suggest": "Property 'myProperty' has no initializer and is not definitely assigned in the constructor.", diff --git a/ets2panda/linter/test/interop/unique_types.ets.migrate.ets b/ets2panda/linter/test/interop/unique_types.ets.migrate.ets index 6f0585bf51..9aed01dd79 100644 --- a/ets2panda/linter/test/interop/unique_types.ets.migrate.ets +++ b/ets2panda/linter/test/interop/unique_types.ets.migrate.ets @@ -18,6 +18,7 @@ import { unknown_var, symbol_var, function_var, + enum_var, A, B, TestHelper, @@ -71,6 +72,7 @@ typeof symbol_var === 'object'; function_var.unsafeCall() === true; A.instance; let obj: B = { name: "hello" }; +enum_var.a === 0.0; export function test_ts_non_standard_exception(testCaseRet: Array) { let test_helper = new TestHelper("TEST_TS_NON_STANDARD_EXCEPTION"); diff --git a/ets2panda/linter/test/interop/unique_types.ets.migrate.json b/ets2panda/linter/test/interop/unique_types.ets.migrate.json index e78688989e..7f90aef8ec 100644 --- a/ets2panda/linter/test/interop/unique_types.ets.migrate.json +++ b/ets2panda/linter/test/interop/unique_types.ets.migrate.json @@ -15,9 +15,9 @@ ], "result": [ { - "line": 68, + "line": 69, "column": 8, - "endLine": 68, + "endLine": 69, "endColumn": 15, "problem": "InteropDirectAccessToTSTypes", "suggest": "", @@ -25,9 +25,9 @@ "severity": "ERROR" }, { - "line": 69, + "line": 70, "column": 8, - "endLine": 69, + "endLine": 70, "endColumn": 19, "problem": "InteropDirectAccessToTSTypes", "suggest": "", @@ -35,9 +35,9 @@ "severity": "ERROR" }, { - "line": 70, + "line": 71, "column": 8, - "endLine": 70, + "endLine": 71, "endColumn": 18, "problem": "InteropDirectAccessToTSTypes", "suggest": "", @@ -45,9 +45,19 @@ "severity": "ERROR" }, { - "line": 76, + "line": 75, + "column": 1, + "endLine": 75, + "endColumn": 9, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, + { + "line": 78, "column": 7, - "endLine": 76, + "endLine": 78, "endColumn": 69, "problem": "AnyType", "suggest": "", @@ -55,9 +65,9 @@ "severity": "ERROR" }, { - "line": 76, + "line": 78, "column": 25, - "endLine": 76, + "endLine": 78, "endColumn": 35, "problem": "DynamicCtorCall", "suggest": "", @@ -65,9 +75,9 @@ "severity": "ERROR" }, { - "line": 80, + "line": 82, "column": 7, - "endLine": 80, + "endLine": 82, "endColumn": 21, "problem": "InteropTSFunctionInvoke", "suggest": "", @@ -75,9 +85,9 @@ "severity": "ERROR" }, { - "line": 89, + "line": 91, "column": 7, - "endLine": 89, + "endLine": 91, "endColumn": 22, "problem": "InteropTSFunctionInvoke", "suggest": "", @@ -85,9 +95,9 @@ "severity": "ERROR" }, { - "line": 98, + "line": 100, "column": 7, - "endLine": 98, + "endLine": 100, "endColumn": 21, "problem": "InteropTSFunctionInvoke", "suggest": "", @@ -95,9 +105,9 @@ "severity": "ERROR" }, { - "line": 107, + "line": 109, "column": 7, - "endLine": 107, + "endLine": 109, "endColumn": 21, "problem": "InteropTSFunctionInvoke", "suggest": "", @@ -105,9 +115,9 @@ "severity": "ERROR" }, { - "line": 116, + "line": 118, "column": 7, - "endLine": 116, + "endLine": 118, "endColumn": 18, "problem": "InteropTSFunctionInvoke", "suggest": "", @@ -115,9 +125,9 @@ "severity": "ERROR" }, { - "line": 158, + "line": 160, "column": 7, - "endLine": 158, + "endLine": 160, "endColumn": 58, "problem": "AnyType", "suggest": "", @@ -125,9 +135,9 @@ "severity": "ERROR" }, { - "line": 158, + "line": 160, "column": 25, - "endLine": 158, + "endLine": 160, "endColumn": 35, "problem": "DynamicCtorCall", "suggest": "", @@ -135,9 +145,9 @@ "severity": "ERROR" }, { - "line": 176, + "line": 178, "column": 1, - "endLine": 176, + "endLine": 178, "endColumn": 18, "problem": "DecoratorsNotSupported", "suggest": "", @@ -145,9 +155,9 @@ "severity": "ERROR" }, { - "line": 181, + "line": 183, "column": 3, - "endLine": 181, + "endLine": 183, "endColumn": 21, "problem": "DecoratorsNotSupported", "suggest": "", @@ -155,9 +165,9 @@ "severity": "ERROR" }, { - "line": 187, + "line": 189, "column": 3, - "endLine": 187, + "endLine": 189, "endColumn": 19, "problem": "DecoratorsNotSupported", "suggest": "", @@ -165,9 +175,9 @@ "severity": "ERROR" }, { - "line": 195, + "line": 197, "column": 22, - "endLine": 195, + "endLine": 197, "endColumn": 41, "problem": "DecoratorsNotSupported", "suggest": "", @@ -175,9 +185,9 @@ "severity": "ERROR" }, { - "line": 195, + "line": 197, "column": 52, - "endLine": 195, + "endLine": 197, "endColumn": 55, "problem": "AnyType", "suggest": "", @@ -185,9 +195,9 @@ "severity": "ERROR" }, { - "line": 203, + "line": 205, "column": 3, - "endLine": 203, + "endLine": 205, "endColumn": 21, "problem": "DecoratorsNotSupported", "suggest": "", @@ -195,9 +205,9 @@ "severity": "ERROR" }, { - "line": 215, + "line": 217, "column": 3, - "endLine": 215, + "endLine": 217, "endColumn": 18, "problem": "DecoratorsNotSupported", "suggest": "", @@ -205,9 +215,9 @@ "severity": "ERROR" }, { - "line": 226, + "line": 228, "column": 3, - "endLine": 226, + "endLine": 228, "endColumn": 20, "problem": "DecoratorsNotSupported", "suggest": "", @@ -215,9 +225,9 @@ "severity": "ERROR" }, { - "line": 231, + "line": 233, "column": 5, - "endLine": 231, + "endLine": 233, "endColumn": 23, "problem": "DecoratorsNotSupported", "suggest": "", @@ -225,9 +235,9 @@ "severity": "ERROR" }, { - "line": 237, + "line": 239, "column": 5, - "endLine": 237, + "endLine": 239, "endColumn": 21, "problem": "DecoratorsNotSupported", "suggest": "", @@ -235,9 +245,9 @@ "severity": "ERROR" }, { - "line": 245, + "line": 247, "column": 24, - "endLine": 245, + "endLine": 247, "endColumn": 43, "problem": "DecoratorsNotSupported", "suggest": "", @@ -245,9 +255,9 @@ "severity": "ERROR" }, { - "line": 245, + "line": 247, "column": 54, - "endLine": 245, + "endLine": 247, "endColumn": 57, "problem": "AnyType", "suggest": "", @@ -255,9 +265,9 @@ "severity": "ERROR" }, { - "line": 256, + "line": 258, "column": 5, - "endLine": 256, + "endLine": 258, "endColumn": 23, "problem": "DecoratorsNotSupported", "suggest": "", @@ -265,9 +275,9 @@ "severity": "ERROR" }, { - "line": 271, + "line": 273, "column": 5, - "endLine": 271, + "endLine": 273, "endColumn": 21, "problem": "DecoratorsNotSupported", "suggest": "", @@ -275,9 +285,9 @@ "severity": "ERROR" }, { - "line": 282, + "line": 284, "column": 7, - "endLine": 282, + "endLine": 284, "endColumn": 57, "problem": "AnyType", "suggest": "", @@ -285,9 +295,9 @@ "severity": "ERROR" }, { - "line": 282, + "line": 284, "column": 25, - "endLine": 282, + "endLine": 284, "endColumn": 35, "problem": "DynamicCtorCall", "suggest": "", @@ -295,9 +305,9 @@ "severity": "ERROR" }, { - "line": 303, + "line": 305, "column": 7, - "endLine": 303, + "endLine": 305, "endColumn": 60, "problem": "AnyType", "suggest": "", @@ -305,9 +315,9 @@ "severity": "ERROR" }, { - "line": 303, + "line": 305, "column": 25, - "endLine": 303, + "endLine": 305, "endColumn": 35, "problem": "DynamicCtorCall", "suggest": "", @@ -315,9 +325,9 @@ "severity": "ERROR" }, { - "line": 306, + "line": 308, "column": 26, - "endLine": 306, + "endLine": 308, "endColumn": 33, "problem": "DynamicCtorCall", "suggest": "", @@ -325,9 +335,9 @@ "severity": "ERROR" }, { - "line": 307, + "line": 309, "column": 51, - "endLine": 307, + "endLine": 309, "endColumn": 58, "problem": "DynamicCtorCall", "suggest": "", @@ -335,9 +345,9 @@ "severity": "ERROR" }, { - "line": 308, + "line": 310, "column": 52, - "endLine": 308, + "endLine": 310, "endColumn": 59, "problem": "DynamicCtorCall", "suggest": "", @@ -345,9 +355,9 @@ "severity": "ERROR" }, { - "line": 309, + "line": 311, "column": 46, - "endLine": 309, + "endLine": 311, "endColumn": 53, "problem": "DynamicCtorCall", "suggest": "", @@ -355,9 +365,9 @@ "severity": "ERROR" }, { - "line": 310, + "line": 312, "column": 33, - "endLine": 310, + "endLine": 312, "endColumn": 40, "problem": "DynamicCtorCall", "suggest": "", @@ -365,9 +375,9 @@ "severity": "ERROR" }, { - "line": 311, + "line": 313, "column": 39, - "endLine": 311, + "endLine": 313, "endColumn": 46, "problem": "DynamicCtorCall", "suggest": "", @@ -375,9 +385,9 @@ "severity": "ERROR" }, { - "line": 312, + "line": 314, "column": 35, - "endLine": 312, + "endLine": 314, "endColumn": 42, "problem": "DynamicCtorCall", "suggest": "", @@ -385,9 +395,9 @@ "severity": "ERROR" }, { - "line": 313, + "line": 315, "column": 35, - "endLine": 313, + "endLine": 315, "endColumn": 42, "problem": "DynamicCtorCall", "suggest": "", @@ -395,9 +405,9 @@ "severity": "ERROR" }, { - "line": 314, + "line": 316, "column": 31, - "endLine": 314, + "endLine": 316, "endColumn": 38, "problem": "DynamicCtorCall", "suggest": "", @@ -405,9 +415,9 @@ "severity": "ERROR" }, { - "line": 315, + "line": 317, "column": 31, - "endLine": 315, + "endLine": 317, "endColumn": 38, "problem": "DynamicCtorCall", "suggest": "", @@ -415,9 +425,9 @@ "severity": "ERROR" }, { - "line": 316, + "line": 318, "column": 33, - "endLine": 316, + "endLine": 318, "endColumn": 40, "problem": "DynamicCtorCall", "suggest": "", @@ -425,9 +435,9 @@ "severity": "ERROR" }, { - "line": 355, + "line": 357, "column": 7, - "endLine": 355, + "endLine": 357, "endColumn": 61, "problem": "AnyType", "suggest": "", @@ -435,9 +445,9 @@ "severity": "ERROR" }, { - "line": 355, + "line": 357, "column": 25, - "endLine": 355, + "endLine": 357, "endColumn": 35, "problem": "DynamicCtorCall", "suggest": "", @@ -445,9 +455,9 @@ "severity": "ERROR" }, { - "line": 182, + "line": 184, "column": 3, - "endLine": 182, + "endLine": 184, "endColumn": 13, "problem": "StrictDiagnostic", "suggest": "Property 'myProperty' has no initializer and is not definitely assigned in the constructor.", @@ -455,9 +465,9 @@ "severity": "ERROR" }, { - "line": 202, + "line": 204, "column": 11, - "endLine": 202, + "endLine": 204, "endColumn": 16, "problem": "StrictDiagnostic", "suggest": "Property '_name' has no initializer and is not definitely assigned in the constructor.", @@ -465,9 +475,9 @@ "severity": "ERROR" }, { - "line": 214, + "line": 216, "column": 11, - "endLine": 214, + "endLine": 216, "endColumn": 15, "problem": "StrictDiagnostic", "suggest": "Property '_age' has no initializer and is not definitely assigned in the constructor.", @@ -475,9 +485,9 @@ "severity": "ERROR" }, { - "line": 232, + "line": 234, "column": 5, - "endLine": 232, + "endLine": 234, "endColumn": 15, "problem": "StrictDiagnostic", "suggest": "Property 'myProperty' has no initializer and is not definitely assigned in the constructor.", -- Gitee