News for hackers. Stuff that matters.
Re:Java record pattern matching in JDK 19 by dwaite on Saturday May 14, 2022 @02:53PM (#31381113)
Some of this is a consequence of how typescript works - it carries any structural constraints it can find forward in an advisory capacity, because it is somewhat decoupled from the quite-dynamic runtime behavior of the javascript engine.

It isn't even block-based scoping in the flow analysis above - if in your block there was the code foo = 1; the typescript engine would then expect that foo will behave like a Number at runtime.

I haven't dived in deep enough, but I suspect foo could even have different structural type information within the same expression, e.g. a ternary (typeof foo === 'string') ? something(foo) : somethingelse(foo)

Re:Java record pattern matching in JDK 19 by ygra on Monday May 16, 2022 @01:20AM (#31393864)
It's expression-based as well This doesn't only apply to conditional expressions, but also things like typeof foo === 'string' && ...