Re:Be wary of functions which take several parameters of the...
by Too on Friday September 27, 2019 @10:46AM
(#21092551)
Typescript can specify required keys in a dictionary: function DrawRect(options: { at: Point2D, width: number, height:number}}
It will be checked compile time that all keys are provided (unless dict comes from serialized json or something).
Re:Be wary of functions which take several parameters of the...
by thom on Friday September 27, 2019 @04:43PM
(#21096092)
That's more verbose than just having arguments though, right?
Re:Be wary of functions which take several parameters of the...
by Too on Saturday September 28, 2019 @01:18AM
(#21098605)
Slightly more verbose but not much. Just having arguments takes you back to square one where you might mix up the order of width and height since nothing is forcing the caller to use named parameters. Perhaps it would be better to have some linter enforcing such things.
function DrawRect(options) {...
Unless you're immediately destructuring it or whatever. I don't think it's _that_ straightforward to compare the two, unless I'm thinking of the wrong languages here.