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 @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?
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.
Do you mean you don't want to use readonly T[] and want to instead use ReadonlyArray
?
It is correct.
Most helpful comment
It is correct.