eslint-plugin-total-functions
eslint-plugin-total-functions copied to clipboard
[no-unsafe-readonly-mutable-assignment]: problem with [Symbol.iterator]
It seems that this rule does not work correctly with [Symbol.iterator]. I'm trying to cast a readonly array to a readonly Iterable, but I get an error: "Using a readonly type to initialize a mutable type can lead to unexpected mutation in the readonly value."
const arr : readonly number[] = [];
const it1 : Iterable<number> = arr; // error!
const it2 : Readonly<Iterable<number>> = arr; // error!
So what should I do about it?
Well, the problem is even worse. We can't even do this:
const arr : readonly number[] = [];
const obj : {} = arr; // error!
Fixed in v6.6.1