title: Angular Typescript error trying to reference implemented class property
body: <p>I'm implementing Angular ErrorHandler class. </p>
  
  <p>In <code>app.module.ts</code> providers I have:</p>
  
  <pre><code>{ provide: ErrorHandler, useClass: GlobalErrorHandler },
  </code></pre>
  
  <p>Then in the implemented class, GlobalErrorHandler, I have:</p>
  
  <pre><code>@Injectable()
  export class GlobalErrorHandler implements ErrorHandler {
  
    public errorAdded$: EventEmitter&lt;string&gt;;
  
    constructor(private injector: Injector) {
      this.errorAdded$ = new EventEmitter();
    }
  </code></pre>
  
  <p>TypeScript complains when I try to reference the <code>errorAdded$</code> property from another service where it gets injected:</p>
  
  <pre><code>@Injectable()
  export class AlertService {
     private subject = new Subject&lt;Alert&gt;();
     private keepAfterRouteChange = false;
  
     constructor(private router: Router, private errorService: ErrorHandler) {
         errorService.errorAdded$.subscribe((error) =&gt; this.error(error));
      }
      //...
    }
  </code></pre>
  
  <p>If I try to inject GlobalErrorHandler I get an error. </p>
  
  <p>What should I do to reference <code>errorAdded$</code> properly (properties on the GlobalErrorHandler class when it is injected into other classes?)</p>