Answer the question
In order to leave comments, you need to log in
Default parameters in a method when passing an object?
[ADD_ITEMS](state, data: {items: object, addToTop?: boolean}) : void{
[ADD_ITEMS](state, items: object, addToTop?: boolean) : void{
[ADD_ITEMS](state, data: {items: object, addToTop?: boolean}) : void{
let items = data.items ?? {};
let addToTop = data.addToTop ?? false;
Answer the question
In order to leave comments, you need to log in
However, when passed by an object, the default parameters cannot be networked.who told you that?
[ADD_ITEMS](state, {items = {}, addToTop = false}: {items?: object; addToTop?: boolean} = {}): void {
// ...
},
https://www.typescriptlang.org/play?#code/MYewdgzg...Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question