'readonly-array' regression for array literals in 5.0.0
See original GitHub issueGiven the following mutable types SomeArray
/SomeType
, tslint-immutable 5.0.0 emits readonly-array
also in the assignment sites (with array literals), but only in the SomeType
(with an object literal) scenario. See the comments in my code snippet.
tslint-immutable 4.9.1 didn’t do this which was correct IMO (because SomeType is declared as mutable, which is even library code in my real case).
type SomeArray = Array<string>; // tslint:disable-line:readonly-array
interface SomeType {
readonly array: Array<string>; // tslint:disable-line:readonly-array
readonly nested: {
readonly array: Array<string>; // tslint:disable-line:readonly-array
};
}
//
// no error in tslint-immutable 4.9.1/5.0.0
const arr: SomeArray = [""];
const o: SomeType = {
// no error in tslint-immutable 4.9.1; but emits 'readonly-array' in 5.0.0:
array: [""],
nested: {
// no error in tslint-immutable 4.9.1; but emits 'readonly-array' in 5.0.0:
array: [""],
},
};
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:7 (3 by maintainers)
Top Results From Across the Web
How do I declare a read-only array tuple in TypeScript?
We can declare a typed tuple in TypeScript, for example, with the type annotation [string, number] . This means an array of 2...
Read more >Read-Only Array and Tuple Types in TypeScript - Marius Schulz
#Read-Only Array Types in TypeScript ... The intersperse function accepts an array of elements of some type T and a separator value of...
Read more >@typescript-eslint/eslint-plugin-tslint | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >Default to ReadonlyArray #32467 - microsoft/TypeScript - GitHub
By default type for array is inferred as Array . It would be better to default to a more strict ReadonlyArray and if...
Read more >Performance Improvements in .NET 6 - .NET Blog
Take a rip-roarin' tour through hundreds of PRs worth of performance improvements for .NET 6.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ulrichb @astorije I think this should be fixed in 5.0.1. Let me know if there are still regression for any cases.
@phil-lgr Thanks for testing 😃