What are the benefits of creating an interface for an Angular service as opposed to simply exporting the service class and using that for type information?
For example:
class Dashboard {
constructor(ui: IUiService){}
}
vs
class Dashboard {
constructor(ui: UiService){}
}
Is there a performance advantage? What will happen if I opt to only use the service class for type information?
It may seem like extra effort without any clear advantages, unless you have multiple implementations of a service with a common base. Or in situations where you want to mock services in unit tests instead of utilizing them directly.
Edit: I am curious about how the TypeScript compiler handles imports that are solely used for type information. Will it instantiate a constructor or modify the require statement (ES6)? Would it create a new instance of the class?