pauldijou / redux-act

An opinionated lib to create actions and reducers for Redux

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[flow typing] custom .toString

Andarist opened this issue · comments

Does anyone know how to type this properly -

actionCreator.toString = () => type;
?

I've tried with various methods, but couldn't figure out how to type return value of createAction, maybe somebody here got better luck.

What's the problem compared to other functions? This one takes no arguments and returns a string.

I meant that there is a problem with typing return value of createAction and not actionCreator.toString.

It even is not be a problem when writing library definitions (like for flow-typed) as it can be typed as callable, but I have no idea how to type such thing in the source code itself when using flow

The issue im talking about can be observed here

It's nearly impossible to type it. Check the TypeScript definitions, there are several tricks to support to the best we can, having the same functions with dozen of possible types (with or without payload, with or without metadatas, no payload reducer, payload reducer with one, two, three, four, five or six arguments).

This lib wasn't designed to be typed at all. I would rather consider thinking of a better typed API on top of it.

I don't know Flow at all right now unfortunately...