From c1ec2a34b4e36f69e2dca9611dde7bf1b0f6375a Mon Sep 17 00:00:00 2001 From: Andreas Coroiu Date: Thu, 20 Feb 2025 13:55:06 +0100 Subject: [PATCH] chore: improve using-required docs --- .../src/platform/misc/using-required.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/libs/common/src/platform/misc/using-required.ts b/libs/common/src/platform/misc/using-required.ts index f641b9f312f..3e341e28e76 100644 --- a/libs/common/src/platform/misc/using-required.ts +++ b/libs/common/src/platform/misc/using-required.ts @@ -1,9 +1,24 @@ export type Disposable = { [Symbol.dispose]: () => void }; /** - * Types implementing this type must be used together with the `using` keyword + * Types implementing this type must be used together with the `using` keyword, + * a rule which is enforced by the linter. * - * @example using ref = rc.take(); + * @deprecated At this time only Chrome supports the `using` keyword. + * Wait for other browsers to catch up before using this type. + * @example + * ``` + * class Resource implements UsingRequired { + * [Symbol.dispose]() { + * // free the resource + * } + * } + * + * function useResource() { + * using resource = new Resource(); + * // resource is disposed when the block ends + * } + * ``` */ // We want to use `interface` here because it creates a separate type. // Type aliasing would not expose `UsingRequired` to the linter.