import type { ClassType, InjectionToken } from '../token/injection-token.mjs' import { DIError } from '../errors/di-error.mjs' import { InjectableTokenMeta } from '../symbols/index.mjs' export function getInjectableToken( target: ClassType, ): R extends { create(...args: any[]): infer V } ? InjectionToken : InjectionToken { // @ts-expect-error We inject the token into the class itself const token = target[InjectableTokenMeta] as InjectionToken if (!token) { throw DIError.classNotInjectable(target.name) } // @ts-expect-error We detect factory or class return token }