Skip to content

Q: createAction with payload typings #211

@donifer

Description

@donifer

I'm trying to type an action with something like:

const incrementBy = createAction<number>('INCREMENT_BY');

// TS complains as expected if I pass the wrong type
incrementBy('This is not a valid payload');

// However, TS likes both of these:
incrementBy(3);
incrementBy();

Why is the last one not an error? How can I type it in a way that payload is required?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions