Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type error for ActionCreator<boolean> with beta typescript-fsa #40

Open
nbgraham opened this issue Nov 24, 2020 · 1 comment
Open

Type error for ActionCreator<boolean> with beta typescript-fsa #40

nbgraham opened this issue Nov 24, 2020 · 1 comment

Comments

@nbgraham
Copy link

May be a moot point because it only happens with the beta

Reproduced:
https://codesandbox.io/s/modest-bird-8shhj

Argument of type '{ (payload: boolean, meta?: { [key: string]: any; } | null | undefined): Action<boolean>; type: string; match: (action: AnyAction) => action is Action<boolean>; }' is not assignable to parameter of type '{ (payload: false, meta?: { [key: string]: any; } | null | undefined): Action<false>; type: string; match: (action: AnyAction) => action is Action<false>; }'.
  Types of property 'match' are incompatible.
    Type '(action: AnyAction) => action is Action<boolean>' is not assignable to type '(action: AnyAction) => action is Action<false>'.
      Type predicate 'action is Action<boolean>' is not assignable to 'action is Action<false>'.
        Type 'Action<boolean>' is not assignable to type 'Action<false>'.
          Type 'boolean' is not assignable to type 'false'.ts(2345)

Seems to happen because of this part of the ActionCreator definition in the beta typescript-fsa

 & (Payload extends void ? {
    /**
     * Creates action with given payload and metadata.
     *
     * @param payload Action payload.
     * @param meta Action metadata. Merged with `commonMeta` of Action Creator.
     */
    (payload?: Payload, meta?: Meta): Action<Payload>;
} : {});

I reproduced in the Typescript playground and then fixed it by removing that clause

@dphilipson
Copy link
Owner

Thanks for the report. I'll take a look at this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants