jeffbski / redux-logic

Redux middleware for organizing all your business logic. Intercept actions and perform async processing.
MIT License
1.81k stars 107 forks source link

Error in StandardAction generic type definition ? #148

Open skurgansky-sugarcrm opened 5 years ago

skurgansky-sugarcrm commented 5 years ago

current type definitions version

export type Action<
  Type extends string = string,
  Payload extends Object = undefined,
  Meta extends Object = undefined
> =
  | ErroneousAction<Type, Meta>
  | (StandardAction<Type, Payload, Meta> & { error?: false });

error:

Argument of type 'ActionMeta<IReceiveContactPayload, IPersistMetadata>' is not assignable to parameter of type 'ArgumentAction<string, undefined, undefined>'.
  Type 'ActionMeta<IReceiveContactPayload, IPersistMetadata>' is not assignable to type 'ActionBasis<string> & Partial<ActionBasis<string> & { payload: object; } & { meta: object; } & { error?: false; }>'.
    Type 'ActionMeta<IReceiveContactPayload, IPersistMetadata>' is not assignable to type 'Partial<ActionBasis<string> & { payload: object; } & { meta: object; } & { error?: false; }>'.
      Types of property 'error' are incompatible.
        Type 'boolean' is not assignable to type 'false'.ts(2345)

i think it should be (StandardAction<Type, Payload, Meta> & { error?: boolean }); ?

skurgansky-sugarcrm commented 5 years ago

yeah. I use redux-actions latest version and i suppose they have conflict here.

skurgansky-sugarcrm commented 5 years ago

btw why payload have to be object in createLogic config ? seems wrong

emj365 commented 5 years ago

error is only true or undefined, that's the standard

skurgansky-sugarcrm commented 5 years ago

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/redux-actions/index.d.ts#L22 https://github.com/jeffbski/redux-logic/blob/master/definitions/action.d.ts#L43 https://github.com/jeffbski/redux-logic/blob/master/definitions/action.d.ts#L56

redux-logic have type conflict with redux-action

skurgansky-sugarcrm commented 5 years ago

ping

emj365 commented 5 years ago

redux-logic type more strict, like https://github.com/redux-utilities/flux-standard-action

skurgansky-sugarcrm commented 5 years ago

redux-logic type doesn't say & { error?: true } like its described in flux-standard-action (FSA)

The optional error property MAY be set to true if the action represents an error.

An action whose error is true is analogous to a rejected Promise. By convention, the payload SHOULD be an error object.

If error has any other value besides true, including undefined and null, the action MUST NOT be interpreted as an error.

It says & { error?: false } why ?