Skip to content

[array-type] ReadonlyArray is regarded as Array #4080

@koooge

Description

@koooge

Hi there,
ReadonlyArray is regarded as Array in array-type rule. Similarly, readonly T[] is regarded to be the same as T[].

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

Here is an example of 'array'.

{
  "rules": {
    '@typescript-eslint/array-type': ['error', {
      default: 'array',
      readonly: 'array', // 'array' | 'generic' | 'array-simple'
    }],
  }
}
const foo: ReadonlyArray<string> = [];

Expected Result

4:12  error  Array type using 'ReadonlyArray<string>' is forbidden. Use 'readonly string[]' instead  @typescript-eslint/array-type

Actual Result

4:12  error  Array type using 'Array<string>' is forbidden. Use 'string[]' instead  @typescript-eslint/array-type

Additional Info
#4066

Versions

package version
@typescript-eslint/eslint-plugin 5.2.0
@typescript-eslint/parser 5.2.0
TypeScript 4.4.4
ESLint 8.1.0
node 16.13.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomerspackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy