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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user