Skip to content

Payload type unknown when defining optional property? #214

Closed
@mcchrish

Description

@mcchrish

This is for version 0.8.0.

const action = createAction<{ input?: string }>('ACTION')
type ActionType = ReturnType<typeof action> // ActionType.payload === unknown


const action = createAction<{ input?: string, input2: string }>('ACTION')
type ActionType = ReturnType<typeof action> // ActionType.payload === { input?: string | undefined; input2: string }

Somehow, if there is only one property and it's optional, it converts it type to unknown

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