From what I can gather your after where if you don't supply any params, stop = false is default, if you do select some params but leave out stop, stop is also false.
This is how I would do it ->
const myfunc = (p: {stop?: boolean} = { stop: false }) => {
// do stuff with "stop"
const {stop = false} = p;
console.log(stop);
}
myfunc({stop: false}); //stop = false
myfunc({stop: true}); //stop = true
myfunc({}); //stop = false
myfunc(); //stop = false
Adding extra params doesn't get any more complicated either.
const myfunc = (p: {stop?: boolean, start?: boolean} =
{ stop: false, start: false }) => {
// do stuff with "stop"
const {stop = false, start = false} = p;
console.log(stop, start);
}
myfunc({stop: false}); //false false
myfunc({stop: true, start: true}); //true true
myfunc({}); //false false
myfunc(); //false false
myfunc({start: true}); //false true
?myfunc({})and (2) allow no params object, i.e.myfunc(). This leads to the verbosity.{ stop = false }with just{ stop }when destructuring to save some space. But if your actual use case is an object with many more properties, I would not destructure and just use something likeoptions.stop.