| 151 | opts?: Partial<Omit<BindInjectablePropertyOpts<T>, "token">> |
| 152 | ): any; |
| 153 | export function Inject<T = any>( |
| 154 | token?: TokenProvider<T> | (() => TokenProvider<T>), |
| 155 | opts: TransformInjectedProviderCB<T> | Partial<Omit<BindInjectablePropertyOpts<T>, "token">> = {} |
| 156 | ) { |
| 157 | opts = typeof opts === "function" ? {transform: opts} : opts; |
| 158 | |
| 159 | return (target: Object, propertyKey: string | symbol | undefined, index?: number) => { |
| 160 | const bindingType = decoratorTypeOf([target, propertyKey, index]); |
| 161 | |
| 162 | switch (bindingType) { |
| 163 | case DecoratorTypes.PARAM_CTOR: |
| 164 | if (token) { |
| 165 | setToken(token, {target, propertyKey, parameterIndex: index!}); |
| 166 | } |
| 167 | break; |
| 168 | case DecoratorTypes.PROP: |
| 169 | bindInjectableProperty(target, propertyKey!, {...opts, token}); |
| 170 | } |
| 171 | }; |
| 172 | } |