Type-only imports break Angular's Dependency Injection

480 views Asked by At

Angular DI system does not respect TypeScript 3.8 type-only imports.

import type { ChangeDetectorRef } from '@angular/core';

...

@Component({
    templateUrl: './popup.component.html',
    changeDetection: ChangeDetectionStrategy.OnPush
})
export class Component implements OnInit {
  constructor(
    private readonly changeDetectorRef: ChangeDetectorRef    // ERROR: Consider changing the type-only import to a regular import, or use the @Inject decorator to specify an injection token
  ) {}
}

Is there any possibility how to use type-only imports in Angular?

0

There are 0 answers