diff --git a/linter/cookbook_convertor/res/recipes.rst b/linter/cookbook_convertor/res/recipes.rst index 193fae7606d0eba13a8cc63d776b3fea0fd35a5d..a4da8f8ed7911ea48b7d6b68a84668d005b6914f 100644 --- a/linter/cookbook_convertor/res/recipes.rst +++ b/linter/cookbook_convertor/res/recipes.rst @@ -337,30 +337,6 @@ integers, ``n`` suffix is not supported: let x: long = 1 -.. _R011: - -|CB_R| #11: Use ``enum`` instead of string literal types ---------------------------------------------------------- - -|CB_RULE| -~~~~~~~~~ - -|LANG| does not support string literal types. Use ``enum`` instead. - -|CB_BAD| -~~~~~~~~ - -.. code-block:: typescript - - type Easing = "ease-in" | "ease-out" | "ease-in-out"; - -|CB_OK| -~~~~~~~ - -.. code-block:: typescript - - enum Easing {EaseIn, EaseOut, EaseInOut} - .. _R012: |CB_R| #12: Use ``T[]`` instead of ``Array`` to declare arrays @@ -596,38 +572,6 @@ instead. let myArray: X = new X() const secondItem = myArray.f[1] -.. _R018: - -|CB_R| #18: Use ``Object`` instead of union types -------------------------------------------------- - -|CB_RULE| -~~~~~~~~~ - -Currently, |LANG| provides limited support for union types; -nullable types are supported only in the form ``T | null``. -You can use ``Object`` to emulate the behaviour of the unions in standard |TS|. - -|CB_BAD| -~~~~~~~~ - -.. code-block:: typescript - - var x: string | number - -|CB_OK| -~~~~~~~ - -.. code-block:: typescript - - let x: Object - - x = 2 - console.log(x) - - x = "2" - console.log(x) - .. _R019: |CB_R| #19: Use inheritance instead of intersection types @@ -673,39 +617,6 @@ as a work-around. interface Employee extends Identity, Contact {} -.. _R020: - -|CB_R| #20: Default values for type parameters in generics are not supported ----------------------------------------------------------------------------- - -|CB_RULE| -~~~~~~~~~ - -Currently, |LANG| does not support default values for type parameters. Use -generic parameters without default values instead. - -|CB_BAD| -~~~~~~~~ - -.. code-block:: typescript - - // Declare a generic function: - function foo() {...} - - // Call the function: - foo() // foo() will be called - -|CB_OK| -~~~~~~~ - -.. code-block:: typescript - - // Declare a generic function: - function foo() {...} - - // Call the function: - foo() // N and S should be specified explicitly - .. _R021: |CB_R| #21: Returning ``this`` type is not supported @@ -895,59 +806,6 @@ You must declare them inside the ``class`` declaration instead. } } -.. _R026: - -|CB_R| #26: Specialized signatures are not supported ----------------------------------------------------- - -|CB_RULE| -~~~~~~~~~ - -Currently, |LANG| does not support specialized signatures as a form of -overloading with special type notation (string literal instead of type). -Use other patterns (e.g., interfaces) instead. - -|CB_BAD| -~~~~~~~~ - -.. code-block:: typescript - - inteface Document { - createElement(tagname: "div"): HTMLDivElement - createElement(tagname: "span"): HTMLDivElement - } - -|CB_OK| -~~~~~~~ - -.. code-block:: typescript - - class HTMLElement { - // ... - } - - class HTMLDivElement extends HTMLElement { - // ... - } - - class HTMLSpanElement extends HTMLElement { - // ... - } - - interface Document { - createElement(tagName: string): HTMLElement - } - - class D implements Document { - createElement(tagName: string): HTMLElement { - switch (tagname) { - case "div": return new HTMLDivElement() - case "span": return new HTMLSpanElement() - ... - } - } - } - .. _R027: |CB_R| #27: Construct signatures not supported in interfaces @@ -1448,43 +1306,6 @@ explicitly. * :ref:`R031` * :ref:`R032` -.. _R036: - -|CB_R| #36: Type widening is not supported ------------------------------------------- - -|CB_RULE| -~~~~~~~~~ - -|LANG| does not support widened types because in most cases type widening -is applied to the currently unsupported types ``any``, ``unknown`` -and ``undefined``. - -|CB_BAD| -~~~~~~~~ - -.. code-block:: typescript - - var a = null - var b = undefined - var c = {c: 0, y: null} - var d = [null, undefined] - -|CB_OK| -~~~~~~~ - -.. code-block:: typescript - - class C { - public c: number = 0 - public y: Object | null - } - - let a: Object | null = null - let b: Object - let c: C = {c: 0, y: null} - let d: Object[] = [null, null] - .. _R037: |CB_R| #37: RegExp literals are not supported @@ -1547,53 +1368,7 @@ The class or interface can be specified as a type annotation for a variable. |CB_SEE| ~~~~~~~~ -* :ref:`R039` -* :ref:`R040` -* :ref:`R042` -* :ref:`R043` - -.. _R039: - -|CB_R| #39: Object literals must correspond to explicitly declared class or interface -------------------------------------------------------------------------------------- - -|CB_RULE| -~~~~~~~~~ - -|LANG| supports the usage of object literals if the compiler can infer to what -classes or interfaces such literals correspond to. Otherwise, a compile-time -error occurs. - -The class or interface can be inferred from a type of the corresponding function parameter. - -|CB_BAD| -~~~~~~~~ - -.. code-block:: typescript - - function foo(x: any) {} - foo({f: 1}) - -|CB_OK| -~~~~~~~ - -.. code-block:: typescript - - class S { - f: number - } - - function foo(s: S) {} - - foo({f: 2}) // ok - foo({ff: 2}) // Compile-time error, class 'S' does not have field 'ff' - -|CB_SEE| -~~~~~~~~ - -* :ref:`R038` * :ref:`R040` -* :ref:`R042` * :ref:`R043` .. _R040: @@ -1637,42 +1412,6 @@ types in place. Declare classes and interfaces explicitly instead. ~~~~~~~~ * :ref:`R038` -* :ref:`R039` -* :ref:`R042` -* :ref:`R043` - -.. _R042: - -|CB_R| #42: Array literals must correspond to known array types ---------------------------------------------------------------- - -|CB_RULE| -~~~~~~~~~ - -|LANG| supports the usage of array literals if the compiler can infer -to what array types such literals correspond to. Otherwise, a compile-time -error occurs. - -|CB_BAD| -~~~~~~~~ - -.. code-block:: typescript - - let x = ["aa", "bb"] - -|CB_OK| -~~~~~~~ - -.. code-block:: typescript - - let x: string[] = ["aa", "bb"] - -|CB_SEE| -~~~~~~~~ - -* :ref:`R038` -* :ref:`R039` -* :ref:`R040` * :ref:`R043` .. _R043: @@ -1711,9 +1450,7 @@ define mixed types array. ~~~~~~~~ * :ref:`R038` -* :ref:`R039` * :ref:`R040` -* :ref:`R042` .. _R044: @@ -1845,35 +1582,7 @@ An explicit return type is mandatory for a lambda expression. * :ref:`R045` -.. _R048: - -|CB_R| #48: Shortcut syntax for lambdas is not supported --------------------------------------------------------- - -|CB_RULE| -~~~~~~~~~ - -Currently, |LANG| does not support shortcut syntax for lambdas. - -|CB_BAD| -~~~~~~~~ - -.. code-block:: typescript - - let a = (x: number) => { return x } - let b = (x: number) => x - -|CB_OK| -~~~~~~~ - -.. code-block:: typescript - - let a: (x: number) => number = - (x: number): number => { return x } - - let b: (x: number) => number = - (x: number): number => { return x } - +.. _R049: |CB_R| #49: Usage of arrow function with type assertions or generics -------------------------------------------------------------------- @@ -2845,70 +2554,6 @@ it is useless as it makes the execution order harder to understand. ++x x = x++ -|CB_R| #72: Usage of contextually typed expressions is supported partially --------------------------------------------------------------------------- - -|CB_RULE| -~~~~~~~~~ - -In many cases |TS| allows the use of contextually typed expressions, -where the actual type of expression is defined by the type of destination. -|LANG| allows the use of contextually typed expressions in the following -two situations: - -- as an initialization expresssion in a variable or constant declaration; and -- as an argument in a function call. - -Other usages are contradictory to the static typing. - -|CB_BAD| -~~~~~~~~ - -A literal can be contextually typed as Point, i.e., implicit. This feature -is prohibited in |LANG| due to the static typing. - -.. code:: typescript - - class Point { - x: number = 0.0 - y: number = 0.0 - ... - } - - function id_x_y(o: Point) : Point { - return o - } - - // type of expression determined by the type of the variable - let p: Point = {x: 5, y: 10} - - // type of expression determined by the type of the parameter - id_x_y({x: 5, y: 10}) - -|CB_OK| -~~~~~~~ - -A value with an instantiated type must be passed into a function. -There are no implicit casts from any arbitrary type to another type. - -.. code:: typescript - - class Point { - x: number = 0.0 - y: number = 0.0 - ... - } - - function id_x_y(o: Point): Point { - return o - } - - // type of expression determined by the type of the variable - let p: Point = {x: 5, y: 10} - - // type of expression determined by the type of the parameter - id_x_y({x: 5, y: 10}) - .. _R073: |CB_R| #74: Destructuring variable declarations are not supported diff --git a/linter/docs/rules/recipe11.md b/linter/docs/rules/recipe11.md deleted file mode 100644 index 13a06c196beafc0dc124a26c4718e472f98e17f4..0000000000000000000000000000000000000000 --- a/linter/docs/rules/recipe11.md +++ /dev/null @@ -1,32 +0,0 @@ -# Use ``enum`` instead of string literal types - -Rule ``arkts-no-str-literal-types`` - -**Severity: error** - -ArkTS does not support string literal types. Use ``enum`` instead. - - -## TypeScript - - -``` - - type Easing = "ease-in" | "ease-out" | "ease-in-out" - -``` - -## ArkTS - - -``` - - enum Easing {EaseIn, EaseOut, EaseInOut} - -``` - -## See also - -- Recipe 142: ``as const`` assertions are not supported (``arkts-no-as-const``) - - diff --git a/linter/docs/rules/recipe142.md b/linter/docs/rules/recipe142.md index 350326f677fbea84805cb6c306e5e82fd7e56329..af28e8ef855fd735d00f18701fed5c30dda5c270 100644 --- a/linter/docs/rules/recipe142.md +++ b/linter/docs/rules/recipe142.md @@ -46,9 +46,3 @@ does not support literal types. } ``` - -## See also - -- Recipe 011: Use ``enum`` instead of string literal types (``arkts-no-str-literal-types``) - - diff --git a/linter/docs/rules/recipe18.md b/linter/docs/rules/recipe18.md deleted file mode 100644 index 11f4989f7ff87633fe227f805381f8a13c639fdb..0000000000000000000000000000000000000000 --- a/linter/docs/rules/recipe18.md +++ /dev/null @@ -1,36 +0,0 @@ -# Use ``Object`` instead of union types - -Rule ``arkts-no-union-types`` - -**Severity: error** - -Currently, ArkTS provides limited support for union types; -nullable types are supported only in the form ``T | null``. -You can use ``Object`` to emulate the behaviour of the unions in standard TypeScript. - - -## TypeScript - - -``` - - var x: string | number - -``` - -## ArkTS - - -``` - - let x: Object - - x = 2 - console.log(x) - - x = "2" - console.log(x) - -``` - - diff --git a/linter/docs/rules/recipe20.md b/linter/docs/rules/recipe20.md deleted file mode 100644 index eeccef57f46e57f46e2d4b9a75d23b69793473fe..0000000000000000000000000000000000000000 --- a/linter/docs/rules/recipe20.md +++ /dev/null @@ -1,41 +0,0 @@ -# Default values for type parameters in generics are not supported - -Rule ``arkts-no-default-type-params`` - -**Severity: warning** - -Currently, ArkTS does not support default values for type parameters. Use -generic parameters without default values instead. - - -## TypeScript - - -``` - - // Declare a generic function: - function foo() { - return new Map() - } - - // Call the function: - foo() // foo() will be called - -``` - -## ArkTS - - -``` - - // Declare a generic function: - function foo() { - return new Map() - } - - // Call the function: - foo() // N and S should be specified explicitly - -``` - - diff --git a/linter/docs/rules/recipe26.md b/linter/docs/rules/recipe26.md deleted file mode 100644 index 3c675134f2996f377ff464d810ea0c1404a94da2..0000000000000000000000000000000000000000 --- a/linter/docs/rules/recipe26.md +++ /dev/null @@ -1,65 +0,0 @@ -# Specialized signatures are not supported - -Rule ``arkts-no-str-literals-in-signatures`` - -**Severity: error** - -Currently, ArkTS does not support specialized signatures as a form of -overloading with special type notation (string literal instead of type). -Use other patterns (e.g., interfaces) instead. - - -## TypeScript - - -``` - - class MyHTMLDivElement { - // ... - } - - class MyHTMLSpanElement { - // ... - } - - interface MyHTMLDocument { - createElement(tagname: "div"): MyHTMLDivElement - createElement(tagname: "span"): MyHTMLSpanElement - } - -``` - -## ArkTS - - -``` - - class MyHTMLElement { - // ... - } - - class MyHTMLDivElement extends MyHTMLElement { - // ... - } - - class MyHTMLSpanElement extends MyHTMLElement { - // ... - } - - interface MyHTMLDocument { - createElement(tagName: string): MyHTMLElement - } - - class D implements MyHTMLDocument { - createElement(tagName: string): MyHTMLElement { - switch (tagName) { - case "div": return new MyHTMLDivElement() - case "span": return new MyHTMLSpanElement() - // ... - } - } - } - -``` - - diff --git a/linter/docs/rules/recipe36.md b/linter/docs/rules/recipe36.md deleted file mode 100644 index 771515f965b916baf46cd3130062a72a2348ac88..0000000000000000000000000000000000000000 --- a/linter/docs/rules/recipe36.md +++ /dev/null @@ -1,41 +0,0 @@ -# Type widening is not supported - -Rule ``arkts-no-widening`` - -**Severity: warning** - -ArkTS does not support widened types because in most cases type widening -is applied to the currently unsupported types ``any``, ``unknown`` -and ``undefined``. - - -## TypeScript - - -``` - - var a = null - var b = undefined - var c = {c: 0, y: null} - var d = [null, undefined] - -``` - -## ArkTS - - -``` - - class C { - public c: number = 0 - public y: Object | null - } - - let a: Object | null = null - let b: Object - let c: C = {c: 0, y: null} - let d: Object[] = [null, null] - -``` - - diff --git a/linter/docs/rules/recipe38.md b/linter/docs/rules/recipe38.md index 16c5ded3100c8f7cbf24d4a5ce1a7014bbd51e84..1180f2b4366f2d49dbaf342c29bce3d927084b1d 100644 --- a/linter/docs/rules/recipe38.md +++ b/linter/docs/rules/recipe38.md @@ -37,9 +37,7 @@ The class or interface can be specified as a type annotation for a variable. ## See also -- Recipe 039: Object literals must correspond to explicitly declared class or interface (``arkts-no-mismatched-obj-literals``) - Recipe 040: Object literals cannot be used as type declarations (``arkts-no-obj-literals-as-types``) -- Recipe 042: Array literals must correspond to known array types (``arkts-no-untyped-arr-literals``) - Recipe 043: Untyped array literals are not supported (``arkts-no-noninferrable-arr-literals``) diff --git a/linter/docs/rules/recipe39.md b/linter/docs/rules/recipe39.md deleted file mode 100644 index bd6df2b9aa81ae18b9e56802f2d42dbc6a1a4321..0000000000000000000000000000000000000000 --- a/linter/docs/rules/recipe39.md +++ /dev/null @@ -1,48 +0,0 @@ -# Object literals must correspond to explicitly declared class or interface - -Rule ``arkts-no-mismatched-obj-literals`` - -**Severity: warning** - -ArkTS supports the usage of object literals if the compiler can infer to what -classes or interfaces such literals correspond to. Otherwise, a compile-time -error occurs. - -The class or interface can be inferred from a type of the corresponding function -parameter. - - -## TypeScript - - -``` - - function foo(x: any) {} - foo({f: 1}) - -``` - -## ArkTS - - -``` - - class S { - f: number - } - - function foo(s: S) {} - - foo({f: 2}) // ok - foo({ff: 2}) // Compile-time error, class 'S' does not have field 'ff' - -``` - -## See also - -- Recipe 038: Object literal must correspond to explicitly declared class or interface (``arkts-no-untyped-obj-literals``) -- Recipe 040: Object literals cannot be used as type declarations (``arkts-no-obj-literals-as-types``) -- Recipe 042: Array literals must correspond to known array types (``arkts-no-untyped-arr-literals``) -- Recipe 043: Untyped array literals are not supported (``arkts-no-noninferrable-arr-literals``) - - diff --git a/linter/docs/rules/recipe40.md b/linter/docs/rules/recipe40.md index d355852249e10cadd342577aa7bd312d0fff5805..0e70ca7c421b11e525f6f6bbb6cc6d7bef79eb18 100644 --- a/linter/docs/rules/recipe40.md +++ b/linter/docs/rules/recipe40.md @@ -41,8 +41,6 @@ types in place. Declare classes and interfaces explicitly instead. ## See also - Recipe 038: Object literal must correspond to explicitly declared class or interface (``arkts-no-untyped-obj-literals``) -- Recipe 039: Object literals must correspond to explicitly declared class or interface (``arkts-no-mismatched-obj-literals``) -- Recipe 042: Array literals must correspond to known array types (``arkts-no-untyped-arr-literals``) - Recipe 043: Untyped array literals are not supported (``arkts-no-noninferrable-arr-literals``) diff --git a/linter/docs/rules/recipe42.md b/linter/docs/rules/recipe42.md deleted file mode 100644 index 1b981bfc041f4018f88ce03dd7515f2fea61c0b4..0000000000000000000000000000000000000000 --- a/linter/docs/rules/recipe42.md +++ /dev/null @@ -1,37 +0,0 @@ -# Array literals must correspond to known array types - -Rule ``arkts-no-untyped-arr-literals`` - -**Severity: warning** - -ArkTS supports the usage of array literals if the compiler can infer -to what array types such literals correspond to. Otherwise, a compile-time -error occurs. - - -## TypeScript - - -``` - - let x = ["aa", "bb"] - -``` - -## ArkTS - - -``` - - let x: string[] = ["aa", "bb"] - -``` - -## See also - -- Recipe 038: Object literal must correspond to explicitly declared class or interface (``arkts-no-untyped-obj-literals``) -- Recipe 039: Object literals must correspond to explicitly declared class or interface (``arkts-no-mismatched-obj-literals``) -- Recipe 040: Object literals cannot be used as type declarations (``arkts-no-obj-literals-as-types``) -- Recipe 043: Untyped array literals are not supported (``arkts-no-noninferrable-arr-literals``) - - diff --git a/linter/docs/rules/recipe43.md b/linter/docs/rules/recipe43.md index a9e640bce4a9f03547d9c31c8eba1569ba6d0737..e722c354d594978495ef28df6c9b1a913b604fd6 100644 --- a/linter/docs/rules/recipe43.md +++ b/linter/docs/rules/recipe43.md @@ -37,8 +37,6 @@ define mixed types array. ## See also - Recipe 038: Object literal must correspond to explicitly declared class or interface (``arkts-no-untyped-obj-literals``) -- Recipe 039: Object literals must correspond to explicitly declared class or interface (``arkts-no-mismatched-obj-literals``) - Recipe 040: Object literals cannot be used as type declarations (``arkts-no-obj-literals-as-types``) -- Recipe 042: Array literals must correspond to known array types (``arkts-no-untyped-arr-literals``) diff --git a/linter/docs/rules/recipe48.md b/linter/docs/rules/recipe48.md deleted file mode 100644 index 667c098d9bcade45706c5b52671d30cefd3c1a6d..0000000000000000000000000000000000000000 --- a/linter/docs/rules/recipe48.md +++ /dev/null @@ -1,33 +0,0 @@ -# Shortcut syntax for lambdas is not supported - -Rule ``arkts-no-shortcut-syntax-in-lambdas`` - -**Severity: warning** - -Currently, ArkTS does not support shortcut syntax for lambdas. - - -## TypeScript - - -``` - - let a = (x: number) => { return x } - let b = (x: number) => x - -``` - -## ArkTS - - -``` - - let a: (x: number) => number = - (x: number): number => { return x } - - let b: (x: number) => number = - (x: number): number => { return x } - -``` - - diff --git a/linter/docs/rules/recipe72.md b/linter/docs/rules/recipe72.md deleted file mode 100644 index caa2554bbadf941826e0d7ce01befd57ad538759..0000000000000000000000000000000000000000 --- a/linter/docs/rules/recipe72.md +++ /dev/null @@ -1,70 +0,0 @@ -# Usage of contextually typed expressions is supported partially - -Rule ``arkts-no-contextually-typed-expressions`` - -**Severity: warning** - -In many cases TypeScript allows the use of contextually typed expressions, -where the actual type of expression is defined by the type of destination. -ArkTS allows the use of contextually typed expressions in the following -two situations: - -- as an initialization expression in a variable or constant declaration; and -- as an argument in a function call. - -Other usages are contradictory to the static typing. There are no implicit casts -from any arbitrary type to another type. - - -## TypeScript - - -``` - - class Point { - x: number = 0.0 - y: number = 0.0 - } - - function id_x_y(o: Point): Point { - return o - } - - // Structural typing is used to deduce that p is Point: - let p = {x: 5, y: 10} - id_x_y(p) - - // A literal can be contextually (i.e., implicitly) typed as Point: - id_x_y({x: 5, y: 10}) - -``` - -## ArkTS - - -``` - - class Point { - x: number = 0.0 - y: number = 0.0 - - // constructor() is used before composite initialization to create a valid object. - // Since there is no other Point constructors, - // constructor() is automatically added by compiler - } - - function id_x_y(o: Point): Point { - return o - } - - // Explicit type is required for composite initialization - let p: Point = {x: 5, y: 10} - id_x_y(p) - - // id_x_y expects Point explicitly - // New instance of Point is initialized with composite - id_x_y({x: 5, y: 10}) - -``` - - diff --git a/linter/src/CookBookMsg.ts b/linter/src/CookBookMsg.ts index 8adbe5d0a352ff8456791f5251a7e79ffedba016..4a49ab5b9b7cb26847b92d2efc77c7d46d77d0ac 100644 --- a/linter/src/CookBookMsg.ts +++ b/linter/src/CookBookMsg.ts @@ -30,22 +30,22 @@ cookBookTag[ 7 ] = ''; cookBookTag[ 8 ] = 'Use explicit types instead of "any", "undefined", "unknown" (arkts-no-any-undefined-unknown)'; cookBookTag[ 9 ] = ''; cookBookTag[ 10 ] = '"bigint" is not a builtin type, suffix "n" for numeric literals is not supported (arkts-no-n-suffix)'; -cookBookTag[ 11 ] = 'Use "enum" instead of string literal types (arkts-no-str-literal-types)'; +cookBookTag[ 11 ] = ''; cookBookTag[ 12 ] = ''; cookBookTag[ 13 ] = 'Use "Object[]" instead of tuples (arkts-no-tuples)'; cookBookTag[ 14 ] = 'Use "class" instead of a type with call signature (arkts-no-call-signatures)'; cookBookTag[ 15 ] = 'Use "class" instead of a type with constructor signature (arkts-no-ctor-signatures-type)'; cookBookTag[ 16 ] = 'Only one static block is supported (arkts-no-multiple-static-blocks)'; cookBookTag[ 17 ] = 'Indexed signatures are not supported (arkts-no-indexed-signatures)'; -cookBookTag[ 18 ] = 'Use "Object" instead of union types (arkts-no-union-types)'; +cookBookTag[ 18 ] = ''; cookBookTag[ 19 ] = 'Use inheritance instead of intersection types (arkts-no-intersection-types)'; -cookBookTag[ 20 ] = 'Default values for type parameters in generics are not supported (arkts-no-default-type-params)'; +cookBookTag[ 20 ] = ''; cookBookTag[ 21 ] = 'Returning "this" type is not supported (arkts-no-this-as-return-type)'; cookBookTag[ 22 ] = 'Conditional types are not supported (arkts-no-conditional-types)'; cookBookTag[ 23 ] = ''; cookBookTag[ 24 ] = 'Optional parameters are not supported for primitive types (arkts-no-opt-params)'; cookBookTag[ 25 ] = 'Declaring fields in "constructor" is not supported (arkts-no-ctor-prop-decls)'; -cookBookTag[ 26 ] = 'Specialized signatures are not supported (arkts-no-str-literals-in-signatures)'; +cookBookTag[ 26 ] = ''; cookBookTag[ 27 ] = 'Construct signatures not supported in interfaces (arkts-no-ctor-signatures-iface)'; cookBookTag[ 28 ] = 'Indexed access types are not supported (arkts-no-aliases-by-index)'; cookBookTag[ 29 ] = 'Indexed access is not supported for fields (arkts-no-props-by-index)'; @@ -55,19 +55,19 @@ cookBookTag[ 32 ] = 'Structural typing is not supported for assignability checks cookBookTag[ 33 ] = 'Optional properties are not supported for primitive types (arkts-no-opt-props)'; cookBookTag[ 34 ] = 'Generic functions must be called with explicit type specialization (arkts-no-inferred-generic-params)'; cookBookTag[ 35 ] = 'Structural typing is not supported for type inference (arkts-no-structural-inference)'; -cookBookTag[ 36 ] = 'Type widening is not supported (arkts-no-widening)'; +cookBookTag[ 36 ] = ''; cookBookTag[ 37 ] = 'RegExp literals are not supported (arkts-no-regexp-literals)'; cookBookTag[ 38 ] = 'Object literal must correspond to explicitly declared class or interface (arkts-no-untyped-obj-literals)'; -cookBookTag[ 39 ] = 'Object literals must correspond to explicitly declared class or interface (arkts-no-mismatched-obj-literals)'; +cookBookTag[ 39 ] = ''; cookBookTag[ 40 ] = 'Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)'; cookBookTag[ 41 ] = ''; -cookBookTag[ 42 ] = 'Array literals must correspond to known array types (arkts-no-untyped-arr-literals)'; +cookBookTag[ 42 ] = ''; cookBookTag[ 43 ] = 'Untyped array literals are not supported (arkts-no-noninferrable-arr-literals)'; cookBookTag[ 44 ] = ''; cookBookTag[ 45 ] = 'Lambdas require explicit type annotation for parameters (arkts-explicit-param-types-in-lambdas)'; cookBookTag[ 46 ] = 'Use arrow functions instead of function expressions (arkts-no-func-expressions)'; cookBookTag[ 47 ] = ''; -cookBookTag[ 48 ] = 'Shortcut syntax for lambdas is not supported (arkts-no-shortcut-syntax-in-lambdas)'; +cookBookTag[ 48 ] = ''; cookBookTag[ 49 ] = 'Use generic functions instead of generic arrow functions (arkts-no-generic-lambdas)'; cookBookTag[ 50 ] = 'Class literals are not supported (arkts-no-class-literals)'; cookBookTag[ 51 ] = 'Classes cannot be specified in "implements" clause (arkts-implements-only-iface)'; @@ -91,7 +91,7 @@ cookBookTag[ 68 ] = ''; cookBookTag[ 69 ] = 'Destructuring assignment is not supported (arkts-no-destruct-assignment)'; cookBookTag[ 70 ] = ''; cookBookTag[ 71 ] = 'The comma operator "," is supported only in "for" loops (arkts-no-comma-outside-loops)'; -cookBookTag[ 72 ] = 'Usage of contextually typed expressions is supported partially (arkts-no-contextually-typed-expressions)'; +cookBookTag[ 72 ] = ''; cookBookTag[ 73 ] = ''; cookBookTag[ 74 ] = 'Destructuring variable declarations are not supported (arkts-no-destruct-decls)'; cookBookTag[ 75 ] = ''; diff --git a/linter/src/Problems.ts b/linter/src/Problems.ts index 1e4242379dbc7c5a98c765b52de61cc9b66f876b..761f22d3699fa2fcf4764d9aaaaeb5ef7779217f 100644 --- a/linter/src/Problems.ts +++ b/linter/src/Problems.ts @@ -14,11 +14,11 @@ */ export enum FaultID { - AnyType, UndefinedValue, SymbolType, UnionType, TupleType, ObjectLiteralNoContextType, ArrayLiteralNoContextType, - ComputedPropertyName, LiteralAsPropertyName, TypeOfExpression, TupleLiteral, UnionLiteral, RegexLiteral, IsOperator, + AnyType, UndefinedValue, SymbolType, TupleType, ObjectLiteralNoContextType, ArrayLiteralNoContextType, + ComputedPropertyName, LiteralAsPropertyName, TypeOfExpression, TupleLiteral, RegexLiteral, IsOperator, DestructuringParameter, YieldExpression, InterfaceOrEnumMerging, InterfaceExtendsClass, IndexMember, WithStatement, ThrowStatement, IndexedAccessType, UnknownType, ForInStatement, InOperator, - KeyOfOperator, ImportFromPath, FunctionExpression, TypeParameterWithDefaultValue, IntersectionType, + KeyOfOperator, ImportFromPath, FunctionExpression, IntersectionType, ObjectTypeLiteral, AddWithWrongType, BitOpWithWrongType, CommaOperator, LimitedReturnTypeInference, ArrowFunctionWithOmittedTypes, LambdaWithTypeParameters, ClassExpression, DestructuringAssignment, DestructuringDeclaration, ForOfNonArray, VarDeclaration, CatchWithUnsupportedType, DeleteOperator, @@ -29,7 +29,7 @@ export enum FaultID { EnumMemberNonConstInit, ImplementsClass, MultipleStaticBlocks, ThisType, InferType, IntefaceExtendDifProps, StructuralIdentity, TypeOnlyImport, TypeOnlyExport, DefaultImport, ExportRenaming, ExportListDeclaration, ReExporting, ExportAssignment, ImportAssignment, PropertyRuntimeCheck, - GenericCallNoTypeArgs, StringLiteralType, InterfaceOptionalProp, ParameterProperties, + GenericCallNoTypeArgs, InterfaceOptionalProp, ParameterProperties, InstanceofUnsupported, ShorthandAmbientModuleDecl, WildcardsInModuleName, UMDModuleDefinition, JSExtensionInModuleIdent, NewTarget, DynamicImport, DefiniteAssignment, IifeAsNamespace, Prototype, GlobalThis, UtilityType, PropertyDeclOnFunction, FunctionApplyBindCall, ReadonlyArr, ConstAssertion, ImportAssertion, @@ -55,17 +55,13 @@ faultsAttrs[FaultID.AnyType] = {cookBookRef: '8'}; faultsAttrs[FaultID.UndefinedValue] = {cookBookRef: '8'}; faultsAttrs[FaultID.UnknownType] = {cookBookRef: '8',}; faultsAttrs[FaultID.BigIntLiteral] = {migratable: true, cookBookRef: '10',}; -faultsAttrs[FaultID.StringLiteralType] = {cookBookRef: '11',}; faultsAttrs[FaultID.TupleType] = {cookBookRef: '13',}; faultsAttrs[FaultID.TupleLiteral] = {cookBookRef: '13',}; faultsAttrs[FaultID.CallSignature] = {cookBookRef: '14',}; faultsAttrs[FaultID.ConstructorType] = {cookBookRef: '15',}; faultsAttrs[FaultID.MultipleStaticBlocks] = {cookBookRef: '16',}; faultsAttrs[FaultID.IndexMember] = {cookBookRef: '17',}; -faultsAttrs[FaultID.UnionType] = {cookBookRef: '18',}; -faultsAttrs[FaultID.UnionLiteral] = {cookBookRef: '18',}; faultsAttrs[FaultID.IntersectionType] = {cookBookRef: '19',}; -faultsAttrs[FaultID.TypeParameterWithDefaultValue] = {migratable: true, warning: true, cookBookRef: '20',}; faultsAttrs[FaultID.ThisType] = {cookBookRef: '21',}; faultsAttrs[FaultID.ConditionalType] = {cookBookRef: '22',}; faultsAttrs[FaultID.FuncOptionalParams] = {migratable: true, cookBookRef: '24',}; @@ -75,11 +71,10 @@ faultsAttrs[FaultID.PropertyAccessByIndex] = {migratable: true, cookBookRef: '29 faultsAttrs[FaultID.StructuralIdentity] = {cookBookRef: '30',}; faultsAttrs[FaultID.InterfaceOptionalProp] = {warning: true, cookBookRef: '33',}; faultsAttrs[FaultID.GenericCallNoTypeArgs] = {migratable: true, warning: true, cookBookRef: '34',}; -faultsAttrs[FaultID.ObjectLiteralNoContextType] = {warning: true, cookBookRef: '36',}; faultsAttrs[FaultID.RegexLiteral] = {cookBookRef: '37',}; -faultsAttrs[FaultID.ObjectLiteralNoContextType] = {warning: true, cookBookRef: '38',}; +faultsAttrs[FaultID.ObjectLiteralNoContextType] = {cookBookRef: '38',}; faultsAttrs[FaultID.ObjectTypeLiteral] = {cookBookRef: '40',}; -faultsAttrs[FaultID.ArrayLiteralNoContextType] = {warning: true, cookBookRef: '42',}; +faultsAttrs[FaultID.ArrayLiteralNoContextType] = {warning: true, cookBookRef: '43',}; faultsAttrs[FaultID.ArrowFunctionWithOmittedTypes] = {migratable: true, cookBookRef: '45',}; faultsAttrs[FaultID.FunctionExpression] = {migratable: true, cookBookRef: '46',}; faultsAttrs[FaultID.LambdaWithTypeParameters] = {migratable: true, cookBookRef: '49',}; diff --git a/linter/src/TypeScriptLinter.ts b/linter/src/TypeScriptLinter.ts index 65387785a9e3ad15beb714371ca9465bd21a1dff..4f43da6e5f07238fa82e27f7ee0d7a17d1f96dac 100644 --- a/linter/src/TypeScriptLinter.ts +++ b/linter/src/TypeScriptLinter.ts @@ -129,14 +129,13 @@ export class TypeScriptLinter { } readonly handlersMap = new Map([ - [ts.SyntaxKind.UnionType, this.handleUnionType], [ts.SyntaxKind.ObjectLiteralExpression, this.handleObjectLiteralExpression], [ts.SyntaxKind.ArrayLiteralExpression, this.handleArrayLiteralExpression], [ts.SyntaxKind.Parameter, this.handleParameter], [ts.SyntaxKind.TypeOperator, this.handleTypeOperator], [ts.SyntaxKind.EnumDeclaration, this.handleEnumDeclaration], [ts.SyntaxKind.InterfaceDeclaration, this.handleInterfaceDeclaration], [ts.SyntaxKind.ThrowStatement, this.handleThrowStatement], [ts.SyntaxKind.ImportClause, this.handleImportClause], - [ts.SyntaxKind.ForStatement, this.handleForStatement], [ts.SyntaxKind.LiteralType, this.handleLiteralType], + [ts.SyntaxKind.ForStatement, this.handleForStatement], [ts.SyntaxKind.ForInStatement, this.handleForInStatement], [ts.SyntaxKind.ForOfStatement, this.handleForOfStatement], [ts.SyntaxKind.ImportDeclaration, this.handleImportDeclaration], @@ -144,7 +143,7 @@ export class TypeScriptLinter { [ts.SyntaxKind.PropertyDeclaration, this.handlePropertyAssignmentOrDeclaration], [ts.SyntaxKind.PropertyAssignment, this.handlePropertyAssignmentOrDeclaration], [ts.SyntaxKind.FunctionExpression, this.handleFunctionExpression], - [ts.SyntaxKind.ArrowFunction, this.handleArrowFunction], [ts.SyntaxKind.TypeParameter, this.handleTypeParameter], + [ts.SyntaxKind.ArrowFunction, this.handleArrowFunction], [ts.SyntaxKind.ClassExpression, this.handleClassExpression], [ts.SyntaxKind.CatchClause, this.handleCatchClause], [ts.SyntaxKind.FunctionDeclaration, this.handleFunctionDeclaration], [ts.SyntaxKind.PrefixUnaryExpression, this.handlePrefixUnaryExpression], @@ -486,14 +485,6 @@ export class TypeScriptLinter { } } - private handleUnionType(node: ts.Node) { - // 'Type | null' now is a part of STS language. All other cases of union type should be counted as a problem. - let tsUT = node as ts.UnionTypeNode; - let uTypes = tsUT.types; - if (uTypes.length !== 2 || (!Utils.isNullType(uTypes[0]) && !Utils.isNullType(uTypes[1]))) - this.incrementCounters(node, FaultID.UnionType); - } - private handleObjectLiteralExpression(node: ts.Node) { let objectLiteralExpr = node as ts.ObjectLiteralExpression; @@ -665,11 +656,6 @@ export class TypeScriptLinter { } } - private handleLiteralType(node: ts.Node) { - let tsLiteralType = node as ts.LiteralTypeNode; - if (ts.isStringLiteral(tsLiteralType.literal)) this.incrementCounters(node, FaultID.StringLiteralType); - } - private handlePropertyAccessExpression(node: ts.Node) { let propertyAccessNode = node as ts.PropertyAccessExpression; if (this.isPropertyRuntimeCheck(propertyAccessNode)) this.incrementCounters(node, FaultID.PropertyRuntimeCheck); @@ -768,11 +754,6 @@ export class TypeScriptLinter { this.incrementCounters(node, FaultID.ClassExpression); } - private handleTypeParameter(node: ts.Node) { - let typeParameterNode = node as ts.TypeParameterDeclaration; - if (typeParameterNode.default) this.incrementCounters(node, FaultID.TypeParameterWithDefaultValue); - } - private handleFunctionDeclaration(node: ts.Node) { let tsFunctionDeclaration = node as ts.FunctionDeclaration; if (!tsFunctionDeclaration.type) this.handleMissingReturnType(tsFunctionDeclaration); diff --git a/linter/src/TypeScriptLinterConfig.ts b/linter/src/TypeScriptLinterConfig.ts index 98d7258bbd2d87f3abac24adc2beb68a2dd8d8a9..a92d21bc65592df9ea70487f2cffd0eb16eea059 100644 --- a/linter/src/TypeScriptLinterConfig.ts +++ b/linter/src/TypeScriptLinterConfig.ts @@ -24,7 +24,6 @@ export class LinterConfig { LinterConfig.nodeDesc[FaultID.AnyType] = '"any" type'; LinterConfig.nodeDesc[FaultID.UndefinedValue] = '"undefined" value in wrong context'; LinterConfig.nodeDesc[FaultID.SymbolType] = '"symbol" type'; - LinterConfig.nodeDesc[FaultID.UnionType] = 'Union type'; LinterConfig.nodeDesc[FaultID.TupleType] = 'Tuple type'; LinterConfig.nodeDesc[FaultID.ObjectLiteralNoContextType] = 'Object literals with no context Class or Interface type'; LinterConfig.nodeDesc[FaultID.ArrayLiteralNoContextType] = 'Array literals with no context Array type'; @@ -32,7 +31,6 @@ export class LinterConfig { LinterConfig.nodeDesc[FaultID.LiteralAsPropertyName] = 'String or integer literal as property name'; LinterConfig.nodeDesc[FaultID.TypeOfExpression] = '"typeof" operations'; LinterConfig.nodeDesc[FaultID.TupleLiteral] = 'tuple literals'; - LinterConfig.nodeDesc[FaultID.UnionLiteral] = 'union type literals'; LinterConfig.nodeDesc[FaultID.RegexLiteral] = 'regex literals'; LinterConfig.nodeDesc[FaultID.IsOperator] = '"is" operations'; LinterConfig.nodeDesc[FaultID.DestructuringParameter] = 'destructuring parameters'; @@ -49,7 +47,6 @@ export class LinterConfig { LinterConfig.nodeDesc[FaultID.KeyOfOperator] = '"keyof" operations'; LinterConfig.nodeDesc[FaultID.ImportFromPath] = 'imports from path'; LinterConfig.nodeDesc[FaultID.FunctionExpression] = 'function expressions'; - LinterConfig.nodeDesc[FaultID.TypeParameterWithDefaultValue] = 'type parameters with default value'; LinterConfig.nodeDesc[FaultID.IntersectionType] = 'intersection types and type literals'; LinterConfig.nodeDesc[FaultID.ObjectTypeLiteral] = 'Object type literals'; LinterConfig.nodeDesc[FaultID.AddWithWrongType] = 'binary "+" with wrong operand'; @@ -100,7 +97,6 @@ export class LinterConfig { LinterConfig.nodeDesc[FaultID.ImportAssignment] = 'Import assignments (import = ..)'; LinterConfig.nodeDesc[FaultID.PropertyRuntimeCheck] = 'Property-based runtime checks'; LinterConfig.nodeDesc[FaultID.GenericCallNoTypeArgs] = 'Generic calls without type arguments'; - LinterConfig.nodeDesc[FaultID.StringLiteralType] = 'string literal type'; LinterConfig.nodeDesc[FaultID.InterfaceOptionalProp] = 'Interface optional property'; LinterConfig.nodeDesc[FaultID.ParameterProperties] = 'Parameter properties in constructor'; LinterConfig.nodeDesc[FaultID.InstanceofUnsupported] = 'Left-hand side of "instanceof" is wrong'; diff --git a/linter/test/conditional_types.ts.relax.json b/linter/test/conditional_types.ts.relax.json index 7286adfa57fdebaaaa15798fe3df603b1f2f0f0f..29d3d7e69204c72cb9b416fa76547c9bd156c9f5 100644 --- a/linter/test/conditional_types.ts.relax.json +++ b/linter/test/conditional_types.ts.relax.json @@ -29,21 +29,11 @@ "column": 17, "problem": "ConditionalType" }, - { - "line": 31, - "column": 25, - "problem": "UnionType" - }, { "line": 31, "column": 44, "problem": "ConditionalType" }, - { - "line": 34, - "column": 32, - "problem": "UnionType" - }, { "line": 41, "column": 21, @@ -64,11 +54,6 @@ "column": 54, "problem": "IndexedAccessType" }, - { - "line": 41, - "column": 56, - "problem": "StringLiteralType" - }, { "line": 45, "column": 1, diff --git a/linter/test/conditional_types.ts.strict.json b/linter/test/conditional_types.ts.strict.json index 63b5467d0b28ca33b6b3c7c1f7324115c455565c..8b6684c72ba9434ea6bac6f7450c2f72a076c709 100644 --- a/linter/test/conditional_types.ts.strict.json +++ b/linter/test/conditional_types.ts.strict.json @@ -29,21 +29,11 @@ "column": 17, "problem": "ConditionalType" }, - { - "line": 31, - "column": 25, - "problem": "UnionType" - }, { "line": 31, "column": 44, "problem": "ConditionalType" }, - { - "line": 34, - "column": 32, - "problem": "UnionType" - }, { "line": 35, "column": 3, @@ -84,11 +74,6 @@ "column": 54, "problem": "IndexedAccessType" }, - { - "line": 41, - "column": 56, - "problem": "StringLiteralType" - }, { "line": 45, "column": 1, diff --git a/linter/test/func_def_type_params.ts b/linter/test/func_def_type_params.ts deleted file mode 100644 index cd566f26e6d5364f5c58b53cae32a23fab1f79bf..0000000000000000000000000000000000000000 --- a/linter/test/func_def_type_params.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -function identity(arg: T): T { - return arg; -} - -function foo() { - return 3; -} diff --git a/linter/test/func_def_type_params.ts.autofix.skip b/linter/test/func_def_type_params.ts.autofix.skip deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/linter/test/func_def_type_params.ts.relax.json b/linter/test/func_def_type_params.ts.relax.json deleted file mode 100644 index b06227021f092f20110cdafb2a6d660605c2ff96..0000000000000000000000000000000000000000 --- a/linter/test/func_def_type_params.ts.relax.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "copyright": [ - "Copyright (c) 2022-2023 Huawei Device Co., Ltd.", - "Licensed under the Apache License, Version 2.0 (the 'License');", - "you may not use this file except in compliance with the License.", - "You may obtain a copy of the License at", - "", - "http://www.apache.org/licenses/LICENSE-2.0", - "", - "Unless required by applicable law or agreed to in writing, software", - "distributed under the License is distributed on an 'AS IS' BASIS,", - "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", - "See the License for the specific language governing permissions and", - "limitations under the License." - ], - "nodes": [] -} \ No newline at end of file diff --git a/linter/test/func_def_type_params.ts.strict.json b/linter/test/func_def_type_params.ts.strict.json deleted file mode 100644 index 8af86718a3c7b5b71e4422f75d2d6a116a3b0021..0000000000000000000000000000000000000000 --- a/linter/test/func_def_type_params.ts.strict.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "copyright": [ - "Copyright (c) 2022-2023 Huawei Device Co., Ltd.", - "Licensed under the Apache License, Version 2.0 (the 'License');", - "you may not use this file except in compliance with the License.", - "You may obtain a copy of the License at", - "", - "http://www.apache.org/licenses/LICENSE-2.0", - "", - "Unless required by applicable law or agreed to in writing, software", - "distributed under the License is distributed on an 'AS IS' BASIS,", - "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", - "See the License for the specific language governing permissions and", - "limitations under the License." - ], - "nodes": [ - { - "line": 20, - "column": 14, - "problem": "TypeParameterWithDefaultValue" - }, - { - "line": 20, - "column": 26, - "problem": "TypeParameterWithDefaultValue" - } - ] -} \ No newline at end of file diff --git a/linter/test/function_overload.ts.relax.json b/linter/test/function_overload.ts.relax.json index 0190255aefb71bf5e379d2ba55c4eea57bb4b95f..f74d0944e52a8b400daf3996c094b34d83349722 100644 --- a/linter/test/function_overload.ts.relax.json +++ b/linter/test/function_overload.ts.relax.json @@ -14,11 +14,6 @@ "limitations under the License." ], "nodes": [ - { - "line": 30, - "column": 16, - "problem": "UnionType" - }, { "line": 37, "column": 19, @@ -33,11 +28,6 @@ "line": 38, "column": 9, "problem": "TypeOfExpression" - }, - { - "line": 89, - "column": 28, - "problem": "UnionType" } ] } \ No newline at end of file diff --git a/linter/test/function_overload.ts.strict.json b/linter/test/function_overload.ts.strict.json index 84db578671ccca793ea1f00c18908af621b81e5a..bdc89b83e1315bb8e23d8e1b4c40cadf741b5f20 100644 --- a/linter/test/function_overload.ts.strict.json +++ b/linter/test/function_overload.ts.strict.json @@ -24,11 +24,6 @@ "column": 53, "problem": "FuncOptionalParams" }, - { - "line": 30, - "column": 16, - "problem": "UnionType" - }, { "line": 37, "column": 19, @@ -44,11 +39,6 @@ "column": 9, "problem": "TypeOfExpression" }, - { - "line": 89, - "column": 28, - "problem": "UnionType" - }, { "line": 96, "column": 3, diff --git a/linter/test/functions.ts.autofix.json b/linter/test/functions.ts.autofix.json index 0203027637d0952494e15a3bd92afba79a1edbbb..2b92b7a07a1fed325660d364b18e61acaa19cbcd 100755 --- a/linter/test/functions.ts.autofix.json +++ b/linter/test/functions.ts.autofix.json @@ -38,12 +38,6 @@ "problem": "YieldExpression", "autofixable": false }, - { - "line": 41, - "column": 30, - "problem": "TypeParameterWithDefaultValue", - "autofixable": false - }, { "line": 47, "column": 17, diff --git a/linter/test/functions.ts.strict.json b/linter/test/functions.ts.strict.json index f2f22b4e36e7b2758474e16a8267b19f33104e93..8eef30a9cabfa3cad1618008273fd72d45d68c06 100644 --- a/linter/test/functions.ts.strict.json +++ b/linter/test/functions.ts.strict.json @@ -34,11 +34,6 @@ "column": 7, "problem": "YieldExpression" }, - { - "line": 41, - "column": 30, - "problem": "TypeParameterWithDefaultValue" - }, { "line": 47, "column": 17, diff --git a/linter/test/mapped_types.ts.relax.json b/linter/test/mapped_types.ts.relax.json index 8eb41fb847c986e7ed00897216dccab99d43f726..d75b28d905b0ed56b25121654065cd1d297a937a 100644 --- a/linter/test/mapped_types.ts.relax.json +++ b/linter/test/mapped_types.ts.relax.json @@ -129,11 +129,6 @@ "column": 7, "problem": "ObjectTypeLiteral" }, - { - "line": 64, - "column": 17, - "problem": "StringLiteralType" - }, { "line": 65, "column": 9, diff --git a/linter/test/mapped_types.ts.strict.json b/linter/test/mapped_types.ts.strict.json index 8eb41fb847c986e7ed00897216dccab99d43f726..d75b28d905b0ed56b25121654065cd1d297a937a 100644 --- a/linter/test/mapped_types.ts.strict.json +++ b/linter/test/mapped_types.ts.strict.json @@ -129,11 +129,6 @@ "column": 7, "problem": "ObjectTypeLiteral" }, - { - "line": 64, - "column": 17, - "problem": "StringLiteralType" - }, { "line": 65, "column": 9, diff --git a/linter/test/string_literal_type.ts b/linter/test/string_literal_type.ts deleted file mode 100644 index c9cf38fcce51f1d9ac741dd74bb9bbf7ea7b1d68..0000000000000000000000000000000000000000 --- a/linter/test/string_literal_type.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -type Easing = 'ease-in' | 'ease-out' | 'ease-in-out'; - -function foo(arg: Easing) { - console.log(arg); -} - -foo('ease-in'); -foo('ease-out'); -foo('ease-in-out'); diff --git a/linter/test/string_literal_type.ts.autofix.skip b/linter/test/string_literal_type.ts.autofix.skip deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/linter/test/string_literal_type.ts.relax.json b/linter/test/string_literal_type.ts.relax.json deleted file mode 100644 index 394b20a391e0c1e683fa468497cb698a20952361..0000000000000000000000000000000000000000 --- a/linter/test/string_literal_type.ts.relax.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "copyright": [ - "Copyright (c) 2023-2023 Huawei Device Co., Ltd.", - "Licensed under the Apache License, Version 2.0 (the 'License');", - "you may not use this file except in compliance with the License.", - "You may obtain a copy of the License at", - "", - "http://www.apache.org/licenses/LICENSE-2.0", - "", - "Unless required by applicable law or agreed to in writing, software", - "distributed under the License is distributed on an 'AS IS' BASIS,", - "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", - "See the License for the specific language governing permissions and", - "limitations under the License." - ], - "nodes": [ - { - "line": 16, - "column": 15, - "problem": "UnionType" - }, - { - "line": 16, - "column": 15, - "problem": "StringLiteralType" - }, - { - "line": 16, - "column": 27, - "problem": "StringLiteralType" - }, - { - "line": 16, - "column": 40, - "problem": "StringLiteralType" - } - ] -} \ No newline at end of file diff --git a/linter/test/string_literal_type.ts.strict.json b/linter/test/string_literal_type.ts.strict.json deleted file mode 100644 index 394b20a391e0c1e683fa468497cb698a20952361..0000000000000000000000000000000000000000 --- a/linter/test/string_literal_type.ts.strict.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "copyright": [ - "Copyright (c) 2023-2023 Huawei Device Co., Ltd.", - "Licensed under the Apache License, Version 2.0 (the 'License');", - "you may not use this file except in compliance with the License.", - "You may obtain a copy of the License at", - "", - "http://www.apache.org/licenses/LICENSE-2.0", - "", - "Unless required by applicable law or agreed to in writing, software", - "distributed under the License is distributed on an 'AS IS' BASIS,", - "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", - "See the License for the specific language governing permissions and", - "limitations under the License." - ], - "nodes": [ - { - "line": 16, - "column": 15, - "problem": "UnionType" - }, - { - "line": 16, - "column": 15, - "problem": "StringLiteralType" - }, - { - "line": 16, - "column": 27, - "problem": "StringLiteralType" - }, - { - "line": 16, - "column": 40, - "problem": "StringLiteralType" - } - ] -} \ No newline at end of file diff --git a/linter/test/type_declarations.ts.relax.json b/linter/test/type_declarations.ts.relax.json index ecffd9ca74f4aa03ae341669395e6c533d5f0232..7f956103dcd456ff2feefaa94cb44bf7a971dbb1 100644 --- a/linter/test/type_declarations.ts.relax.json +++ b/linter/test/type_declarations.ts.relax.json @@ -54,11 +54,6 @@ "column": 14, "problem": "InOperator" }, - { - "line": 38, - "column": 15, - "problem": "UnionType" - }, { "line": 41, "column": 18, diff --git a/linter/test/type_declarations.ts.strict.json b/linter/test/type_declarations.ts.strict.json index 4ad80138c21aea7cbf8a73590d0da243f133c68c..7a45ff1c601f0d86b3177bb36434d7f37b37b67e 100644 --- a/linter/test/type_declarations.ts.strict.json +++ b/linter/test/type_declarations.ts.strict.json @@ -54,11 +54,6 @@ "column": 14, "problem": "InOperator" }, - { - "line": 38, - "column": 15, - "problem": "UnionType" - }, { "line": 41, "column": 18, diff --git a/linter/test/types.ts.relax.json b/linter/test/types.ts.relax.json index 25963d64645ed05351984454f7f2444f6c795d0a..3828cc7f3aacf47644fa1866b7d8fc1246c64e3b 100644 --- a/linter/test/types.ts.relax.json +++ b/linter/test/types.ts.relax.json @@ -64,41 +64,16 @@ "column": 15, "problem": "IndexedAccessType" }, - { - "line": 34, - "column": 21, - "problem": "StringLiteralType" - }, - { - "line": 36, - "column": 20, - "problem": "UnionType" - }, { "line": 36, "column": 24, "problem": "UnknownType" }, - { - "line": 37, - "column": 16, - "problem": "UnionType" - }, { "line": 37, "column": 20, "problem": "AnyType" }, - { - "line": 38, - "column": 14, - "problem": "UnionType" - }, - { - "line": 39, - "column": 19, - "problem": "UnionType" - }, { "line": 41, "column": 17, @@ -194,11 +169,6 @@ "column": 35, "problem": "ObjectTypeLiteral" }, - { - "line": 112, - "column": 40, - "problem": "StringLiteralType" - }, { "line": 116, "column": 9, diff --git a/linter/test/types.ts.strict.json b/linter/test/types.ts.strict.json index 4316cc603b949043e0f669f3e8bb94d1b61730bd..76e84260eb35f687dc2652b287578b3b1191b088 100644 --- a/linter/test/types.ts.strict.json +++ b/linter/test/types.ts.strict.json @@ -64,41 +64,16 @@ "column": 15, "problem": "IndexedAccessType" }, - { - "line": 34, - "column": 21, - "problem": "StringLiteralType" - }, - { - "line": 36, - "column": 20, - "problem": "UnionType" - }, { "line": 36, "column": 24, "problem": "UnknownType" }, - { - "line": 37, - "column": 16, - "problem": "UnionType" - }, { "line": 37, "column": 20, "problem": "AnyType" }, - { - "line": 38, - "column": 14, - "problem": "UnionType" - }, - { - "line": 39, - "column": 19, - "problem": "UnionType" - }, { "line": 41, "column": 17, @@ -224,11 +199,6 @@ "column": 35, "problem": "ObjectTypeLiteral" }, - { - "line": 112, - "column": 40, - "problem": "StringLiteralType" - }, { "line": 116, "column": 9, diff --git a/linter/test/utility_types.ts.relax.json b/linter/test/utility_types.ts.relax.json index 2ca8589725dd64de6c85810cffb02814637e7b29..8d907aa616681949309757aa21c63c5518a34369 100644 --- a/linter/test/utility_types.ts.relax.json +++ b/linter/test/utility_types.ts.relax.json @@ -29,11 +29,6 @@ "column": 12, "problem": "UtilityType" }, - { - "line": 21, - "column": 20, - "problem": "UnionType" - }, { "line": 30, "column": 51, @@ -89,26 +84,6 @@ "column": 32, "problem": "ObjectLiteralNoContextType" }, - { - "line": 72, - "column": 18, - "problem": "UnionType" - }, - { - "line": 72, - "column": 18, - "problem": "StringLiteralType" - }, - { - "line": 72, - "column": 28, - "problem": "StringLiteralType" - }, - { - "line": 72, - "column": 38, - "problem": "StringLiteralType" - }, { "line": 74, "column": 15, @@ -124,21 +99,6 @@ "column": 22, "problem": "UtilityType" }, - { - "line": 90, - "column": 33, - "problem": "UnionType" - }, - { - "line": 90, - "column": 33, - "problem": "StringLiteralType" - }, - { - "line": 90, - "column": 43, - "problem": "StringLiteralType" - }, { "line": 92, "column": 29, @@ -149,11 +109,6 @@ "column": 22, "problem": "UtilityType" }, - { - "line": 108, - "column": 33, - "problem": "StringLiteralType" - }, { "line": 110, "column": 29, @@ -164,21 +119,6 @@ "column": 19, "problem": "UtilityType" }, - { - "line": 118, - "column": 30, - "problem": "UnionType" - }, - { - "line": 118, - "column": 30, - "problem": "StringLiteralType" - }, - { - "line": 118, - "column": 44, - "problem": "StringLiteralType" - }, { "line": 120, "column": 30, @@ -189,151 +129,36 @@ "column": 13, "problem": "UtilityType" }, - { - "line": 129, - "column": 21, - "problem": "UnionType" - }, - { - "line": 129, - "column": 21, - "problem": "StringLiteralType" - }, - { - "line": 129, - "column": 27, - "problem": "StringLiteralType" - }, - { - "line": 129, - "column": 33, - "problem": "StringLiteralType" - }, - { - "line": 129, - "column": 38, - "problem": "StringLiteralType" - }, { "line": 131, "column": 13, "problem": "UtilityType" }, - { - "line": 131, - "column": 21, - "problem": "UnionType" - }, - { - "line": 131, - "column": 21, - "problem": "StringLiteralType" - }, - { - "line": 131, - "column": 27, - "problem": "StringLiteralType" - }, - { - "line": 131, - "column": 33, - "problem": "StringLiteralType" - }, - { - "line": 131, - "column": 38, - "problem": "UnionType" - }, - { - "line": 131, - "column": 38, - "problem": "StringLiteralType" - }, - { - "line": 131, - "column": 44, - "problem": "StringLiteralType" - }, { "line": 133, "column": 13, "problem": "UtilityType" }, - { - "line": 133, - "column": 21, - "problem": "UnionType" - }, { "line": 137, "column": 13, "problem": "UtilityType" }, - { - "line": 137, - "column": 21, - "problem": "UnionType" - }, - { - "line": 137, - "column": 21, - "problem": "StringLiteralType" - }, - { - "line": 137, - "column": 27, - "problem": "StringLiteralType" - }, - { - "line": 137, - "column": 33, - "problem": "StringLiteralType" - }, - { - "line": 137, - "column": 38, - "problem": "UnionType" - }, - { - "line": 137, - "column": 38, - "problem": "StringLiteralType" - }, - { - "line": 137, - "column": 44, - "problem": "StringLiteralType" - }, { "line": 139, "column": 13, "problem": "UtilityType" }, - { - "line": 139, - "column": 21, - "problem": "UnionType" - }, { "line": 143, "column": 13, "problem": "UtilityType" }, - { - "line": 143, - "column": 25, - "problem": "UnionType" - }, { "line": 145, "column": 13, "problem": "UtilityType" }, - { - "line": 145, - "column": 25, - "problem": "UnionType" - }, { "line": 145, "column": 43, @@ -579,11 +404,6 @@ "column": 14, "problem": "ObjectLiteralNoContextType" }, - { - "line": 257, - "column": 19, - "problem": "StringLiteralType" - }, { "line": 258, "column": 25, @@ -594,16 +414,6 @@ "column": 50, "problem": "UtilityType" }, - { - "line": 261, - "column": 31, - "problem": "StringLiteralType" - }, - { - "line": 265, - "column": 19, - "problem": "StringLiteralType" - }, { "line": 266, "column": 24, @@ -614,26 +424,11 @@ "column": 50, "problem": "UtilityType" }, - { - "line": 269, - "column": 31, - "problem": "StringLiteralType" - }, - { - "line": 273, - "column": 28, - "problem": "StringLiteralType" - }, { "line": 274, "column": 19, "problem": "UtilityType" }, - { - "line": 278, - "column": 28, - "problem": "StringLiteralType" - }, { "line": 279, "column": 32, diff --git a/linter/test/utility_types.ts.strict.json b/linter/test/utility_types.ts.strict.json index f1146cbcce45cb3b5d99a43e83d3fd20099ad70b..eec607dd493b9ca1d8b630d4c27df206848d9a05 100644 --- a/linter/test/utility_types.ts.strict.json +++ b/linter/test/utility_types.ts.strict.json @@ -29,11 +29,6 @@ "column": 12, "problem": "UtilityType" }, - { - "line": 21, - "column": 20, - "problem": "UnionType" - }, { "line": 30, "column": 3, @@ -94,26 +89,6 @@ "column": 32, "problem": "ObjectLiteralNoContextType" }, - { - "line": 72, - "column": 18, - "problem": "UnionType" - }, - { - "line": 72, - "column": 18, - "problem": "StringLiteralType" - }, - { - "line": 72, - "column": 28, - "problem": "StringLiteralType" - }, - { - "line": 72, - "column": 38, - "problem": "StringLiteralType" - }, { "line": 74, "column": 15, @@ -129,21 +104,6 @@ "column": 22, "problem": "UtilityType" }, - { - "line": 90, - "column": 33, - "problem": "UnionType" - }, - { - "line": 90, - "column": 33, - "problem": "StringLiteralType" - }, - { - "line": 90, - "column": 43, - "problem": "StringLiteralType" - }, { "line": 92, "column": 29, @@ -154,11 +114,6 @@ "column": 22, "problem": "UtilityType" }, - { - "line": 108, - "column": 33, - "problem": "StringLiteralType" - }, { "line": 110, "column": 29, @@ -169,21 +124,6 @@ "column": 19, "problem": "UtilityType" }, - { - "line": 118, - "column": 30, - "problem": "UnionType" - }, - { - "line": 118, - "column": 30, - "problem": "StringLiteralType" - }, - { - "line": 118, - "column": 44, - "problem": "StringLiteralType" - }, { "line": 120, "column": 30, @@ -194,151 +134,36 @@ "column": 13, "problem": "UtilityType" }, - { - "line": 129, - "column": 21, - "problem": "UnionType" - }, - { - "line": 129, - "column": 21, - "problem": "StringLiteralType" - }, - { - "line": 129, - "column": 27, - "problem": "StringLiteralType" - }, - { - "line": 129, - "column": 33, - "problem": "StringLiteralType" - }, - { - "line": 129, - "column": 38, - "problem": "StringLiteralType" - }, { "line": 131, "column": 13, "problem": "UtilityType" }, - { - "line": 131, - "column": 21, - "problem": "UnionType" - }, - { - "line": 131, - "column": 21, - "problem": "StringLiteralType" - }, - { - "line": 131, - "column": 27, - "problem": "StringLiteralType" - }, - { - "line": 131, - "column": 33, - "problem": "StringLiteralType" - }, - { - "line": 131, - "column": 38, - "problem": "UnionType" - }, - { - "line": 131, - "column": 38, - "problem": "StringLiteralType" - }, - { - "line": 131, - "column": 44, - "problem": "StringLiteralType" - }, { "line": 133, "column": 13, "problem": "UtilityType" }, - { - "line": 133, - "column": 21, - "problem": "UnionType" - }, { "line": 137, "column": 13, "problem": "UtilityType" }, - { - "line": 137, - "column": 21, - "problem": "UnionType" - }, - { - "line": 137, - "column": 21, - "problem": "StringLiteralType" - }, - { - "line": 137, - "column": 27, - "problem": "StringLiteralType" - }, - { - "line": 137, - "column": 33, - "problem": "StringLiteralType" - }, - { - "line": 137, - "column": 38, - "problem": "UnionType" - }, - { - "line": 137, - "column": 38, - "problem": "StringLiteralType" - }, - { - "line": 137, - "column": 44, - "problem": "StringLiteralType" - }, { "line": 139, "column": 13, "problem": "UtilityType" }, - { - "line": 139, - "column": 21, - "problem": "UnionType" - }, { "line": 143, "column": 13, "problem": "UtilityType" }, - { - "line": 143, - "column": 25, - "problem": "UnionType" - }, { "line": 145, "column": 13, "problem": "UtilityType" }, - { - "line": 145, - "column": 25, - "problem": "UnionType" - }, { "line": 145, "column": 43, @@ -624,11 +449,6 @@ "column": 14, "problem": "ObjectLiteralNoContextType" }, - { - "line": 257, - "column": 19, - "problem": "StringLiteralType" - }, { "line": 258, "column": 25, @@ -639,16 +459,6 @@ "column": 50, "problem": "UtilityType" }, - { - "line": 261, - "column": 31, - "problem": "StringLiteralType" - }, - { - "line": 265, - "column": 19, - "problem": "StringLiteralType" - }, { "line": 266, "column": 24, @@ -659,26 +469,11 @@ "column": 50, "problem": "UtilityType" }, - { - "line": 269, - "column": 31, - "problem": "StringLiteralType" - }, - { - "line": 273, - "column": 28, - "problem": "StringLiteralType" - }, { "line": 274, "column": 19, "problem": "UtilityType" }, - { - "line": 278, - "column": 28, - "problem": "StringLiteralType" - }, { "line": 279, "column": 32,