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] Support fixing readonly modifier (TS 3.4) #428

Closed
bradzacher opened this issue Apr 13, 2019 · 3 comments · Fixed by #429
Closed

[array-type] Support fixing readonly modifier (TS 3.4) #428

bradzacher opened this issue Apr 13, 2019 · 3 comments · Fixed by #429
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@bradzacher
Copy link
Member

bradzacher commented Apr 13, 2019

Repro

// "typescript/array-type": ["error", "generic"]
const x : readonly number[] = [1];
// fixes to
const x : ReadonlyArray<number> = [1];


// "typescript/array-type": ["error", "array"]
const x : ReadonlyArray<number> = [1]; // should error, but doesn't
// fixes to
const x : readonly number[] = [1];

Versions

package version
@typescript-eslint/eslint-plugin 1.6.0
@typescript-eslint/parser 1.6.0
TypeScript 3.4.3
ESLint 5.16.0
node 10
@bradzacher bradzacher added bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin labels Apr 13, 2019
@a-tarasyuk
Copy link
Contributor

@bradzacher @JamesHenry I'm working on migration TypeScript repository from TSLint to ESLint and noticed that TSLint/array-type works differently than @typescript-eslint/array-type. TSLint/array-type doesn't handle ReadonlyArray., @typescript-eslint/array-type adds a bunch of changes which we want to avoid for now. What do you think about using ReadonlyArray (can be the default) as an option in order to allow to handle ReadonlyArray and Array separately?

@bradzacher
Copy link
Member Author

I'm not sure if I understand what you mean..
Do you mean you don't want to use readonly T[] and want to instead use ReadonlyArray<T>?

If what I'm saying is correct - then please open a new feature request issue and we can address it appropriately.


TSLint/array-type doesn't handle ReadonlyArray

That's only because nobody has added support for it.

@a-tarasyuk
Copy link
Contributor

Do you mean you don't want to use readonly T[] and want to instead use ReadonlyArray?

It is correct.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants