تخطَّ إلى المحتوى

Disposable Not Disposed (ARCH3080)

هذا المحتوى غير متوفر بلغتك بعد.

Key typescript.performance.disposable-not-disposed · Severity error · Category performance

Creating a resource that must be closed and never releasing it leaks the resource; the object should be scoped-cleaned with using or try/finally.

function process(path: string): void {
const handle = openResource(path);
handle.write("data");
// handle is never closed
}
function process(path: string): void {
using handle = openResource(path);
handle.write("data");
} // auto-disposed at end of scope

Bind resource-owning objects with using or try/finally so they are released at end of scope.