Re:Be wary of functions which take several parameters of the...
by tomjakubowski on Thursday September 26, 2019 @09:59PM
(#21087715)
De-structuring syntax isn't required, this is just as easily type-checked:
interface CopyArgs {
src: string;
dst: string;
}
function copy(args: CopyArgs) {
exec(["cp", args.src, args.dst])
}
Re:Be wary of functions which take several parameters of the...
by thelazydogsback on Friday September 27, 2019 @12:13AM
(#21088342)
Sure, if you want to get all interfacy - but pretty soon it'll be Java :)
Re:Be wary of functions which take several parameters of the...
by davedx on Friday September 27, 2019 @07:16AM
(#21090613)
Hah I thought that initially, but TypeScript interfaces are simpler (and usually co-sited) compared to their OO cousins. I find them a pleasure to use.
Re:Be wary of functions which take several parameters of the...
by RobertKerans on Friday September 27, 2019 @01:52AM
(#21088851)
It can, manually (as it can for a non-destructured object), but it has no typing guarantees - the function will still happily be interpreted and run as long as _any_ object is given as an argument.
Well if it uses de-structuring syntax, then it can be type-checked.