// old (pre TS 3.4.0)
type Matrix<T> = ReadonlyArray<ReadonlyArray<T>>;
// new (TS 3.4.0)
type Matrix<T> = readonly (readonly T[])[];
// code snippet
with tslint.yaml configuration:
extends:
- tslint:recommended
which uses rule array-type with option array-simple.
TSLint fails to lint second line, but TypeScript enforces usage of "readonly" before simple array types. The following line would not pass TSC:
type Matrix<T> = readonly Array<readonly T[]>;
TSLint fails to lint second line.
TSLint lets pass the syntax as this is the only way to make complex array types read-only (without adding an intermetiate typedef for inner elements).
BTW even simpler example
type T1 = ReadonlyArray<number | string>;
type T2 = readonly (number | string)[]; // TSLint fails
TSLint is deprecated and no longer accepting pull requests other than security fixes. See #4534. โ ๏ธ
We recommend you instead use typescript-eslint to lint your TypeScript code with ESLint. โ
๐ It was a pleasure open sourcing with you!
๐ค Beep boop! ๐ TSLint is deprecated ๐ _(#4534)_ and you should switch to typescript-eslint! ๐ค
๐ This issue is being locked to prevent further unnecessary discussions. Thank you! ๐
Most helpful comment
BTW even simpler example