Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
3 tasks done
koooge opened this issue Nov 1, 2021 · 1 comment · Fixed by #4066
Closed
3 tasks done

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

koooge opened this issue Nov 1, 2021 · 1 comment · Fixed by #4066
Labels
bug Something isn't working good first issue Good for newcomers package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@koooge
Copy link
Contributor

koooge commented Nov 1, 2021

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
@koooge koooge added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Nov 1, 2021
@JoshuaKGoldberg JoshuaKGoldberg added accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working good first issue Good for newcomers and removed triage Waiting for maintainers to take a look labels Nov 1, 2021
@JoshuaKGoldberg
Copy link
Member

Ah that does make sense, thanks!

@armano2 armano2 self-assigned this Nov 19, 2021
@armano2 armano2 added good first issue Good for newcomers and removed accepting prs Go ahead, send a pull request that resolves this issue good first issue Good for newcomers labels Nov 19, 2021
@armano2 armano2 removed their assignment Nov 21, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working good first issue Good for newcomers package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
3 participants