Trying to understand why I get loads of typescript TS2322 errors when I migrated from 4 to 5. I've installed a new ng project using angular cli
Angular CLI: 1.5.5
Node: 8.9.1
OS: darwin x64
Angular: 5.0.4
Package JSON is as standard, here is a snippet.
"core-js": "^2.4.1",
"rxjs": "^5.5.2",
"zone.js": "^0.8.14"
"@angular/core": "^5.0.0",
"tslint": "~5.7.0",
"typescript": "~2.4.2"
Here is my component that I am testing:
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import {Observable} from 'rxjs/Rx';
@Component({
selector: 'app-sidebar',
templateUrl: './sidebar.component.html',
styleUrls: ['./sidebar.component.scss']
})
export class SidebarComponent implements OnInit {
show_dropdown$: Observable<boolean>;
@ViewChild('el_dropdown_button') el_dropdown_button: ElementRef;
constructor() { }
ngOnInit() {
// show dropdowng ser
this.show_dropdown$ = Observable
.merge(
// on down arrow click
Observable
.fromEvent(this.el_dropdown_button.nativeElement, 'click')
.scan((value) => !value, false)
.startWith(false),
// on input click -> true
Observable
.fromEvent(this.el_filter_input.nativeElement, 'click')
.mapTo(true),
)
.startWith(false);
}
}
My IDE highlights this.show_dropdown$ with an error saying that:
error TS2322: Type 'Observable' is not assignable to type 'Observable'. Type 'boolean | {}' is not assignable to type 'boolean'. Type '{}' is not assignable to type 'boolean'.
Any suggestion about the new typescript 2.4.2 or 2.6?
(click)=method($event), especially if the implementation is using Observables all the same?