News for hackers. Stuff that matters.
Re:How I Program in 2024 by kmoser on Monday August 05, 2024 @12:16AM (#41158151)
The flip side of this "burden" is that it prevents you from returning an arbitrary data structure that is not expected by the caller and may cause errors further down the call stack if you return the wrong type. The whole point of static typing in the first place is to eliminate this kind of footgun.
Re:How I Program in 2024 by fendy3002 on Monday August 05, 2024 @02:23AM (#41158582)
have you tried typescript? the code above will make the function declaration become like this:

function foo (): {data: MyCustomObject, message: string}

so foo().data and foo().message is a valid object, while foo().bar will throw build error