Andrey (azangru) wrote,

Here was me happily using a type for a redux thunk action that I copy-pasted from somewhere many months ago:

The types passed to the ThunkAction generic type here aren't important. What is important is that I was using the ActionCreator type from the redux library. The reason this is important is that when, during refactoring, I changed the action creator so that instead of a single argument (x) it now requires two (x and y):

I fully expected typescript to complain in the places where someActionCreator was invoked with a single argument. When it didn't, I cussed, went to investigate, and found that the ActionCreator type is defined in the redux library as follows:

Bloody any! Now, I don't know whether there is a proper way to define the type of ActionCreator in typescript at all; but by using any we have just lost the information about how many and what kind of arguments someActionCreator will require.


P.S.: found the discussion of this problem in redux's github issues.

  • (no subject)

    There's a strange tendency out there for tech podcasters not to be good programmers themselves. There are exceptions, of course. The googlers at…

  • (no subject)

    Achievement unlocked: today, for the first time, I wrote an asynchronous iterator. Using an async generator (also for the first time; I never felt a…

  • (no subject)

    This is a good summation:

  • Post a new comment


    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.