Re:TypeScript Is Surprisingly OK for Compilers
by yunohn on Friday August 18, 2023 @05:47AM
(#37173354)
Iām not clear on the benefits of this proposal over just using anonymous functions. Some of the examples just seem contrived.
And the React example makes no sense, you can use a ternary and it is even shorter.
``` return ( <nav> <Home /> {loggedIn ? <LogoutButton /> : <LoginButton /> } </nav> ) ```
Re:TypeScript Is Surprisingly OK for Compilers
by doctormanhatten on Friday August 18, 2023 @06:13AM
(#37173595)
Having written quite a lot of Reason react (similar in syntax to the proposed React example) - while in this particular case because the example is so simple the ternary looks nicer, its also nice to just have a longer expression block in the middle of your JSX when you're doing more complex things.
Re:TypeScript Is Surprisingly OK for Compilers
by baq on Friday August 18, 2023 @06:09AM
(#37173566)
for me the point is to be able to return from inside multiple expressions from the correct scope i.e. the root function without throwing.
Re:TypeScript Is Surprisingly OK for Compilers
by graftak on Friday August 18, 2023 @07:03AM
(#37173992)
What if you want a `switch` instead?
They're still waiting on the do expression proposal for that (https://github.com/tc39/proposal-do-expressions), which has been in the bikeshedding stage for the past five years.