(...specs: BindingSpec[])
| 65 | * configure the binding |
| 66 | */ |
| 67 | export function injectable(...specs: BindingSpec[]): ClassDecorator { |
| 68 | const templateFunctions = specs.map(t => { |
| 69 | if (typeof t === 'function') { |
| 70 | return t; |
| 71 | } else { |
| 72 | return asBindingTemplate(t); |
| 73 | } |
| 74 | }); |
| 75 | |
| 76 | return (target: Function) => { |
| 77 | const cls = target as Constructor<unknown>; |
| 78 | const spec: BindingMetadata = { |
| 79 | templates: [asClassOrProvider(cls), ...templateFunctions], |
| 80 | target: cls, |
| 81 | }; |
| 82 | |
| 83 | const decorator = InjectableDecoratorFactory.createDecorator( |
| 84 | BINDING_METADATA_KEY, |
| 85 | spec, |
| 86 | {decoratorName: '@injectable'}, |
| 87 | ); |
| 88 | decorator(target); |
| 89 | }; |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * A namespace to host shortcuts for `@injectable` |
no test coverage detected