Consider the following decorator:
export function MyDecorator(constructor: new(someService: SomeService, ...args) => ISomeInterface) {
when incorporating it within an Angular component, I require the compiler to verify that the service injection is not omitted in the client code:
interface ISomeInterface {
someService: SomeService;
}
@MyDecorator
@Component(...)
export class MyComponent implements ISomeInterface {
constructor(
public someService: SomeService,
private router: Router,
private anotherService: AnotherService
...
While this approach functions correctly, it necessitates SomeService
to be listed as the first dependency. This can be inconvenient if there is another decorator with a similar requirement. Are there any suggestions on how to enforce this constraint without considering the "position"?