In the following code, I would like to arrange things so that the call to getResource in badFunction raises some kind of type checking error, because it leaks a resource that should have been captured with using. Is this possible?
function getResource(): Disposable {
console.log("Acquired resource!")
return {
[Symbol.dispose]: () => {
console.log("Freed resource")
}
}
}
function goodFunction() {
using resource = getResource()
// do work
// resource is disposed
}
function badFunction() {
const resource = getResource()
// do work
// resoruce leaks!
}