(name: string)
| 63 | } |
| 64 | |
| 65 | export function createDecorator<T>(name: string): ServiceIdentifier<T> { |
| 66 | const existing = _util.serviceIds.get(name); |
| 67 | if (existing) { |
| 68 | return existing as ServiceIdentifier<T>; |
| 69 | } |
| 70 | |
| 71 | const id = function serviceDecorator( |
| 72 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 73 | target: any, |
| 74 | _key: string | symbol | undefined, |
| 75 | index: number, |
| 76 | ): void { |
| 77 | if (arguments.length !== 3) { |
| 78 | throw new Error( |
| 79 | '@IServiceName-decorator can only be used to decorate a parameter', |
| 80 | ); |
| 81 | } |
| 82 | storeServiceDependency(id, target, index); |
| 83 | } as unknown as ServiceIdentifier<T>; |
| 84 | |
| 85 | Object.defineProperty(id, 'toString', { |
| 86 | value: function toString(): string { |
| 87 | return name; |
| 88 | }, |
| 89 | enumerable: false, |
| 90 | writable: false, |
| 91 | configurable: false, |
| 92 | }); |
| 93 | |
| 94 | _util.serviceIds.set(name, id); |
| 95 | return id; |
| 96 | } |
| 97 | |
| 98 | export function refineServiceDecorator<T1, T extends T1>( |
| 99 | serviceIdentifier: ServiceIdentifier<T1>, |
no test coverage detected