3 ms·
TSC should fail the build if it doesn't have the destruction interface, the scope is the scope the variable is initialized in/under. It's very similar to C#'s
by tracker1 3y ago
TSC should fail the build if it doesn't have the destruction interface, the scope is the scope the variable is initialized in/under. It's very similar to C#'s usage of using.
Edit: It's also a pending Stage 3 proposal for EcmaScript.
https://github.com/tc39/proposal-explicit-resource-management https://github.com/tc39/proposal-explicit-resource-managemen...
- circuit10 3y agoI think they’re worried about the opposite, forgetting to put using when you needed it
- tracker1 3y agoGiven my experience with TS, would assume the opposite is also true. Will likely lint for manual call or for using.
- Kuraj 3y ago> Will likely lint for manual call or for using. That's a safe bet. TypeScript's ability to detect problems in the code seems superior than what Visual Studio ships with for C# - for example it doesn't warn about forgetting to `await` a method call.
- sippeangelo 3y agoBut if the opposite was true, why do I have to specify it at all? Why can’t it free on scope exit like any other language, with “let”?
- tracker1 3y agoBecause it will run in JS and you can do stuff like return something with a lifetime to be scoped at a higher level. Is there too declare intent. Typescript is just really advanced linting.