kolodny / immutability-helper

mutate a copy of data without changing the original source
MIT License
5.17k stars 186 forks source link

typescript definition of array $push does not match javascript definition #114

Closed blushingpenguin closed 6 years ago

blushingpenguin commented 6 years ago

in index.d.ts ArraySpec has push taking a single array element:

type ArraySpec<T, C extends CustomCommands<object>> =
  | { $push: T }
  | { $unshift: T }
  | { $splice: Array<[number] | [number, number] | [number, number, T]> }
  | { [index: string]: Spec<T, C> }; // Note that this does not type check properly if index: number.

but in index.js invariantPushAndUnshift is called:

function invariantPushAndUnshift(value, spec, command) {
  invariant(
    Array.isArray(value),
    'update(): expected target of %s to be an array; got %s.',
    command,
    value
  );
kolodny commented 6 years ago

Closed via #113