thoughtbot / superglue

A productive library for Classic Rails, React and Redux
https://thoughtbot.github.io/superglue/
MIT License
327 stars 8 forks source link

Add type annotations to `lib/utils/immutability.tsx` #79

Open jho406 opened 1 week ago

jho406 commented 1 week ago

Context

Continuing with the typescript conversation. immutability.tsx is a set of functions that are lightweight helpers that were imported from Scour.js. They're used to mutate objects using keypaths like foo.bar.posts.id=1.body.

Issue

We have the following eslint warnings:

    7:15  warning  Argument 'message' should be typed  @typescript-eslint/explicit-module-boundary-types
   13:1   warning  Missing return type on function     @typescript-eslint/explicit-module-boundary-types
   13:16  warning  Argument 'obj' should be typed      @typescript-eslint/explicit-module-boundary-types
   13:21  warning  Argument 'path' should be typed     @typescript-eslint/explicit-module-boundary-types
  118:1   warning  Missing return type on function     @typescript-eslint/explicit-module-boundary-types
  118:16  warning  Argument 'object' should be typed   @typescript-eslint/explicit-module-boundary-types
  118:24  warning  Argument 'keypath' should be typed  @typescript-eslint/explicit-module-boundary-types
  118:33  warning  Argument 'value' should be typed    @typescript-eslint/explicit-module-boundary-types

I'm not sure how to type this well, but we can start by just treating the keypath arguments as ordinary strings.

jho406 commented 1 day ago

Picking this up