question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'readonly-array' regression for array literals in 5.0.0

See original GitHub issue

Given 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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
jonaskellocommented, Dec 14, 2018

@ulrichb @astorije I think this should be fixed in 5.0.1. Let me know if there are still regression for any cases.

0reactions
jonaskellocommented, Jan 4, 2019

@phil-lgr Thanks for testing 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found