4 ms·
Nice, so this is the equivalent of `with` and context mangers in Python. I like it. I generally avoid new TS features (apart from typing that gets compiled awa
by samwillis 3y ago
Nice, so this is the equivalent of `with` and context mangers in Python. I like it.
I generally avoid new TS features (apart from typing that gets compiled away) until it looks like they are going to make their way into JavaScript, anyone know if thats being considered?
--
Edit: Yes it's being considered, looks likely, but not decided - https://github.com/tc39/proposal-explicit-resource-management#meeting-notes https://github.com/tc39/proposal-explicit-resource-managemen...
- epolanski 3y agoTypeScript only implements JS features that make it to Stage 3, the only exception being decorators in the past which never went beyond Stage 2 in their previous form.
- WorldMaker 3y agoThose first draft decorators never made it past Stage 1. That's also why Typescript required a compile-time flag that began with `--experimental` before you could use them. It's amazing how many projects put an `--experimental` flag into Production code. (Thanks, Angular.)
- whostolemyhat 3y agoThe article mentions that this proposal is in stage 3 for Javascript, so will probably be refined a bit more https://tc39.es/process-document/ https://tc39.es/process-document/
- RyanCavanaugh 3y agoThings rarely change at all once they're at stage 3. That's why TS waits until that stage before implementing. There might be a minor tweak in some edge cases but stage 3 is usually "done".
- zokier 3y ago> Nice, so this is the equivalent of `with` and context mangers in Python. Well, half of it at least :) Python has both enter and exit, while this proposal only has the exit half.
- masklinn 3y agoTBF the `__enter__` hook is not the most useful.
- pwdisswordfishc 3y agoMore importantly, it does not allow distinguishing between successful completion and a thrown exception. Which may or may not be such a great feature in the first place, but still.
- junon 3y agoWhich is funny since Javascript had `with` before (that did something completely different) that was overly abused and thus removed.
- manojlds 3y agoIt's essentially that but from C# https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/using https://learn.microsoft.com/en-us/dotnet/csharp/language-ref...