Skip to content

Mutation definition with parameter destructuring in chapter 5 #13

@clockwiser

Description

@clockwiser

In chapter 5, there is a mutation definition like below.

mutations: {
addToHistory(state: { history: HistoryEntry[] }, entry: HistoryEntry) {
state.history.push(entry)
},

What is this "state: { history: HistoryEntry[] } "?
Searched around but couldn't find any reliable explanation.

There is parameter destructuring explained here.
https://www.typescriptlang.org/docs/handbook/2/functions.html#parameter-destructuring
But it is not the same beast.

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