Angular 2 - Typescript: TS2322: Type 'Subscription' is not assignable to type 'Observable<MouseEvent>'

一世执手 提交于 2019-12-06 00:04:17

The error is in click-outside.directive.ts. Observable.subscribe returns a Subscription (in ngOnInit), not another Observable. Thus, the type of private globalClick should be Subscription.

It works when types are removed, and as plunker doesn't show type errors it worked, but when compiling with tsc it will error out as you're trying to assign a Subscription object to an Observable.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!