Skip to content

Typings for attach fails if specify effect argument type #439

@PFight

Description

@PFight

What is the current behavior:

There exact sample from https://effector.dev/docs/api/effector/attach, but with one change - when calling createEffect I added type for effect argument:

         const original = createEffect<string, void>(params => {
            console.log('Original effect called with', params);
        });
        
        const data =createStore(8900);
        
        const created = attach({
            effect: original,
            source: data,
            mapParams: (params, data) => {
                console.log('Created effect called with', params, 'and data', data);
                return {wrapped: params, data};
            },
        });

TypeScript 3.8.0 compailns with error:

No overload matches this call.
  The last overload gave the following error.
    Argument of type '{ effect: Effect<string, void, Error>; source: Store<number>; mapParams: (params: unknown, data: number) => { wrapped: unknown; data: number; }; }' is not assignable to parameter of type '{ effect: Effect<string, void, Error>; }'.
      Object literal may only specify known properties, and 'source' does not exist in type '{ effect: Effect<string, void, Error>; }'.

Which versions of effector packages, and which browser and OS are affected by this issue? Did this work in previous versions of effector?:

"effector": "^21.7.5",
TypeScript 3.8.0

Maybe the last TypeScript will be ok, can't check right now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreeffector packagetypingsTypescript public type definitions issues

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions