TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

TypeScript 5.2 Beta

42 pointsby DanRosenwasseralmost 2 years ago

4 comments

steve_adams_86almost 2 years ago
I had mixed feelings about using, but I’m into it now. I like seeing familiar conventions from other languages I’ve come to love, and it seems like the implementation will likely deliver the same QOL benefits I’m familiar with.<p>On that note, I know it’s contentious, but I’d love to see pattern matching baked in like we have it in Rust (or similar). I’ve come to love ts-pattern so much, and I’m constantly wishing it was part of TypeScript&#x2F;JavaScript.
评论 #36550627 未加载
bern4444almost 2 years ago
I can&#x27;t help but think this is a clunkier than necessary. With function composition and the try&#x2F;finally approach described we can get the same thing:<p><pre><code> const doSomeWork = () =&gt; { &#x2F;&#x2F; some computation here. } const withCleanup = (fn, cleanupFn) =&gt; { let x; try { x = fn() } finally { cleanupFn() } return x; }; const someCleanupFn = () =&gt; { &#x2F;&#x2F; remove that file or whatever... }; const doSomeWorkAndCleanup = withCleanup(doSomeWork, someCleanupFn); </code></pre> This also provides lots of nice ways to understand what that cleanup behavior was to the caller. We could return an array of the original function return value and the result of the cleanup function. Maybe this reveals a potential new monadic structure that would be useful...<p>I agree doing this in OO, like what&#x27;s shown in the page&#x27;s examples, without the execution environment&#x27;s support is tricky... I&#x27;d rather see though a new class to handle this rather than adding this behavior by adding a special method - it seems to put us back in the direction of having lifecycle methods like what React supports in class components that the community has totally moved away from.<p>I think I don&#x27;t like that triggering the `dispose` method only takes place when the keyword `using` is present. It&#x27;d be much cleaner that it is always invoked on any object whose extends `Disposable`. Unless I have that behavior wrong...
评论 #36548577 未加载
jondwillisalmost 2 years ago
This [Symbol.dispose]() stuff is not intuitive to me. What are the brackets for? Is this an object property? Seems like a bad analogue to Swift’s defer and deinit keywords&#x2F;methods.
评论 #36544064 未加载
评论 #36545002 未加载
评论 #36544028 未加载
Dudester230602almost 2 years ago
Sometimes I sneeze, and within that time alone, Microsoft releases a few new versions of TypeScript.
评论 #36544070 未加载