@inversifyjs/common
Version:
InversifyJs common utils
30 lines (23 loc) • 1.14 kB
TypeScript
declare function isPromise<T>(object: unknown): object is Promise<T>;
type Either<TLeft, TRight> = Left<TLeft> | Right<TRight>;
interface BaseEither<T> {
value: T;
}
interface Left<T> extends BaseEither<T> {
isRight: false;
}
interface Right<T> extends BaseEither<T> {
isRight: true;
}
type Newable<TInstance = unknown, TArgs extends unknown[] = any[]> = new (...args: TArgs) => TInstance;
type ServiceIdentifier<TInstance = unknown> = string | symbol | Newable<TInstance> | Function;
declare function stringifyServiceIdentifier(serviceIdentifier: ServiceIdentifier): string;
declare const islazyServiceIdentifierSymbol: unique symbol;
declare class LazyServiceIdentifier<TInstance = unknown> {
#private;
[islazyServiceIdentifierSymbol]: true;
constructor(buildServiceId: () => ServiceIdentifier<TInstance>);
static is<TInstance = unknown>(value: unknown): value is LazyServiceIdentifier<TInstance>;
unwrap(): ServiceIdentifier<TInstance>;
}
export { type BaseEither, type Either, LazyServiceIdentifier, type Left, type Newable, type Right, type ServiceIdentifier, isPromise, stringifyServiceIdentifier };