tslint-immutable icon indicating copy to clipboard operation
tslint-immutable copied to clipboard

`"readonly-array": [true, "ignore-local"]` should not affect interface definitions

Open geon opened this issue 7 years ago • 0 comments

The point of "ignore-local" is that you still have a pure function, even if you have local state. But in readonly-array, even local interface definitions are ignored, even if they will be exposed by returning them.

Example:

function foo () {
  interface Foo {
    foo: Array<string>
  }

  const bar: Foo = {
    foo: []
  };

  // bar.foo is mutable here, which makes sense.
  bar.foo.push("");

  return bar;
}

const oops = foo();

// ...but it is also mutable here, which is dangerous.
oops.foo.push("");

geon avatar Aug 01 '18 10:08 geon