static-injector
Version:
Angular 依赖注入独立版本;Angular dependency injection standalone version
39 lines (38 loc) • 1.25 kB
TypeScript
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
/**
* TODO(incremental-hydration): Remove this file entirely once PromiseWithResolvers lands in stable
* node / TS.
*/
export interface PromiseWithResolvers<T> {
promise: Promise<T>;
resolve: (value: T | PromiseLike<T>) => void;
reject: (reason?: any) => void;
}
export interface PromiseConstructor {
/**
* Creates a new Promise and returns it in an object, along with its resolve and reject functions.
* @returns An object with the properties `promise`, `resolve`, and `reject`.
*
* ```ts
* const { promise, resolve, reject } = Promise.withResolvers<T>();
* ```
*/
withResolvers<T>(): PromiseWithResolvers<T>;
}
/**
* Replace with `Promise.withResolvers()` once it's available.
* NET September 2026
*
* See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers.
*/
export declare function promiseWithResolvers<T>(): {
promise: Promise<T>;
resolve: (value: T | PromiseLike<T>) => void;
reject: (reason?: any) => void;
};