UNPKG

@injectable-ts/core

Version:

Purely-functional strictly-typed IoC/DI for TypeScript

15 lines (14 loc) 710 B
import { DependencyWithName, InjectableWithName } from './injectable'; export declare const TOKEN_ACCESSOR_KEY = "@injectable-ts/core//TOKEN_ACCESSOR"; export interface TokenAccessor { <Name extends PropertyKey, Dependencies extends Record<Name, unknown>>(dependencies: Dependencies, name: Name): Dependencies[Name]; } export interface TokenInjectable<Name, Type> { readonly name: Name; readonly type: Type; readonly optional: false; readonly children: readonly [ DependencyWithName<typeof TOKEN_ACCESSOR_KEY, TokenAccessor, []> ]; } export declare function token<Name extends PropertyKey>(name: Name): <Type = never>() => InjectableWithName<TokenInjectable<Name, Type>, Type>;