Types

@system-inc/base-foundation · 515c140 · 4 symbols

The scope of the dependency container.

  • @global — the global scope container. Should only be used for stateless (static) registrations. Examples: providers, configuration.
  • @worker — the worker scope container, for worker-specific registrations. Examples: durable objects, scheduled jobs.
  • @request — the request scope container, for request-specific registrations. Examples: resolvers, context, rpc, http, user account.
  • @scheduled — the scheduled scope container, for scheduled-specific registrations; similar to the request scope.
  • @queue — the queue scope container, for queue-specific registrations; similar to the request scope.
  • @websocket — the websocket scope container, for websocket-specific registrations; similar to the request scope.
BaseInjectionContainerScope: "@global" | "@worker" | "@request" | "@scheduled" | "@queue" | "@websocket"

View source ↗

The set of token shapes accepted by Base's typed injection decorators (@Inject, @Provider, @InjectAll, @InjectAllOptional, etc.).

Bare strings and symbols are intentionally excluded — every DI token must carry static type information either through a class constructor (resolves to the instance type), a TypedInjectionKey<T>, or a TypedBinding subclass (e.g. DurableObjectBinding<T>).

If you need to interop with tsyringe at the raw container level (container.register('SomeString', ...)), that path stays open — just call .toString() on a TypedInjectionKey / TypedBinding to get the underlying string token.

BaseInjectionToken: Constructor<T> | TypedInjectionKey<T> | TypedBinding

View source ↗

Branded MethodDecorator that declares the TypeScript type the decorated method is expected to return.

Used by @Provider to express its registration contract: the value the method produces is what gets stored under the DI token. The base/provider-return-matches-token lint rule reads __expectedReturnType off the decorator's call return type and verifies the method's declared return type is assignable to it.

The phantom field is never read at runtime — TypeScript erases it, so a TypedMethodDecorator<T> is structurally identical to a MethodDecorator once compiled.

Example:

export function Provider<T>(
    token: BaseInjectionToken<T>,
): TypedMethodDecorator<T | ObjectFactory<T> | undefined> {
    // ...
}
TypedMethodDecorator: MethodDecorator & { __expectedReturnType?: TExpectedReturn }

View source ↗

Branded ParameterDecorator that declares the TypeScript type the decorated parameter is expected to resolve to.

Used by typed injection decorators (@Inject, @InjectRepository, @InjectDurableObjectProvider, etc.) to express their resolution contract in the type system. The base/inject-type-matches-parameter lint rule reads __resolvedType off the decorator's call return type and verifies the parameter's TypeScript type is assignable from it.

The phantom field is never read at runtime — TypeScript erases it, so a TypedParameterDecorator<T> is structurally identical to a ParameterDecorator once compiled.

Example:

export function InjectRepository<T>(
    entity: Constructor<T>,
): TypedParameterDecorator<OrmRepository<T>> {
    // ...
    return inject(...) as TypedParameterDecorator<OrmRepository<T>>;
}
TypedParameterDecorator: ParameterDecorator & { __resolvedType?: TResolved }

View source ↗

Types • Documentation • Base