This suggestion propose adding support for the good known and familiar Dispose pattern (e.g. 'using' statement like we have in C#).
Since there's no class destructor in ts/js there's a need for a resource management (or cleanup) pattern in order to do smart/auto handling for releasing resources and cleanup our code.
This TS with USING statement:
export class MyDisposable {
public dispose() {
}
}
using(let x = new MyDisposable()) {
console.log("Hi");
}
should be transpiled into:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var MyDisposable = (function () {
function MyDisposable() {
}
MyDisposable.prototype.dispose = function () {
};
return MyDisposable;
}());
exports.MyDisposable = MyDisposable;
var x;
try {
x = new MyDisposable();
console.log("Hi");
}
finally {
if (typeof x !== "undefined") x.dispose();
}
This suggestion propose adding support for the good known and familiar Dispose pattern (e.g. 'using' statement like we have in C#).
Since there's no class destructor in ts/js there's a need for a resource management (or cleanup) pattern in order to do smart/auto handling for releasing resources and cleanup our code.
This TS with USING statement:
should be transpiled into: