1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-11 05:53:42 +00:00

chore: improve using-required docs

This commit is contained in:
Andreas Coroiu
2025-02-20 13:55:06 +01:00
parent ca76b5a17c
commit c1ec2a34b4

View File

@@ -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.