3 ms·
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 furthe
by kmoser 2y ago
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.
- fendy3002 2y agohave 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