3 ms·
> The "JS solution" for example is not a solution, but only a convention: the actual interface is just expecting an object, Well if it uses de-structuring synt
by thelazydogsback 7y ago
> The "JS solution" for example is not a solution, but only a convention: the actual interface is just expecting an object,
Well if it uses de-structuring syntax, then it can be type-checked.
- tomjakubowski 7y agoDe-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]) }
- thelazydogsback 7y agoSure, if you want to get all interfacy - but pretty soon it'll be Java :)
- davedx 7y agoHah 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.
- RobertKerans 7y agoIt 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.