Hacker News new | past | comments | ask | show | jobs | submit login

This is not TypeScript-specific, it’s a stage-3 ECMA-262 proposal.

https://github.com/tc39/proposal-explicit-resource-managemen...

It’s a shame the author insisted on it looking like C# and sabotaged attempts to combine disposal with destructuring.

Also, there is no move operator without futzing around with DisposableStack. Though that could be introduced later; it’s not a day-zero design issue.




> and sabotaged attempts to combine disposal with destructuring.

Can you explain by what you mean by this? What would "disposal combined with destructuring" look like?


From a brief search, it looks like the semantics around destructuring and what exactly gets disposed were causing confusion?

What's the not-C#-like method that would have allowed destructuring in a better way?


TFA mentions as much: TypeScript 5.2 will introduce a new keyword - 'using' - that you can use to dispose of anything with a Symbol.dispose function when it leaves scope. This is based on the TC39 proposal, which recently reached Stage 3, indicating that it is coming to JavaScript.


No, I am very familiar with JS and wasn't sure reading the article what bits were the new TC39 proposal and what bits were TS-specific. It seems, from having read it once quickly, that it's just TS adding support early to a feature that will come in JS, similar to how you could add support to async/await in your transpiler before they were commonplace by transforming them into promises back in the day. But that's definitely not a "TS new keyword".


Agreed with OP, the title is misleading. Typescript technically doesn't introduce any new runtime feature. This is basically a polyfill for an upcoming Javascript feature.


The overwhelming share of improvements made to Java, Javascript, Typescript etc over the past decade have been inspired by C#, so I can understand why the C# terminology was front of mind.

Can you elaborate more of what combining disposal and destructuring would look like?


I’m not sure Java has taken anything from C#. Most of its recent features have been taken from ML influences.


this happens a lot in tc39 proposals unfortunately.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: