optional
optional<
T>(token):OptionalDependency<T>
Defined in: packages/di-craft/src/core/provider/provider.ts:85
Marks a token as optional.
Optional dependencies resolve to undefined instead of throwing when no
provider exists in the container chain. They can be used in factory deps
or passed directly to container.get.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”Token<T>
Returns
Section titled “Returns”Example
Section titled “Example”const logger = container.get(optional(LOGGER));