I have gotten the next bunch of code.
const func: ( newState: { newState: number }) => void = ({ newState: newState }) => {
console.log(newState);
}
For me, particularly interesting is the ({ newState: newState })
how is it work?
Why can I write newState: newState
in this situation, and no compilation errors?
const func: ( labeledParameter: { newState: number }) => void = ({ newState: test }) => {
console.log(test);
}
func({newState: 12});
It's because the first newState is a label put on the parameters give to the function -> i renamed it labeledParameter in my sample
the object
{ newState: newState }
is an object with a property newState and as value a number
to call the function you should use
func({newState: 12});