tslint-immutable
tslint-immutable copied to clipboard
Mutable prefix for indexer interfaces
There is an escape hatch for mutable members of an interface by prefixing them. However this is not useful for indexer interfaces. So I propose to extend the prefix to apply to the interface name too. If the interface name starts with something that is in the ignore-prefix option then ignore it. This would mean that with this config:
"readonly-keyword": [true, {"ignore-prefix": "Mutable"}]
No member of this interface would not be checked:
interface MutableFoo {
[key: string]: string;
bar: number
}
Another idea would be to check the name of the indexer key for the prefix:
interface MutableFoo {
[mutableKey: string]: string; // This is ok because the key is prefixed with mutable
bar: number // This will give an error as there is no mutable prefix
}