I am currently working on an Angular 2 project using WebStorm as my IDE.
Within one of my components, I am coding in TypeScript and utilizing the Observable
:
import { Observable } from "rxjs/Rx";
import 'rxjs/Rx';
@Component({...})
export class SearchComponent {
@ViewChild('input') input: ElementRef;
ngAfterViewInit() {
let inputElement = this.input.nativeElement;
let keyups = Observable.fromEvent(inputElement, 'keyup');
keyups.subscribe(data => console.log(data));
}
}
Although this code functions as intended (printing to the console when typing in the input field), there are issues flagged by WebStorm regarding the fromEvent
method ("Unresolved function or method").
Additonally, when attempting autocomplete on the Observable
class, most RxJS operators are not showing up. For example, only one method (withLatestFrom
) is suggested instead of a list including from
, fromCallback
, fromEvent
, fromPromise
...
How can I enable proper autocomplete/TypeScript support for observables within WebStorm?
I have experimented with different methods of importing Observable
and also followed recommendations from this article (such as adding
"files": ["node_modules/rxjs/Rx.KitchenSink.d.ts"]
to tsconfig.json
), but none have successfully resolved the issue.