Recently, I encountered a peculiar problem with my Angular4
project, which is managed under Angular-CLI
and utilizes the RxJS
library. Upon updating the RxJS
library to version 5.5.2
, the project started experiencing issues with Observable
operators. The specific error messages displayed in Google Chrome
were as follows:
ERROR TypeError: this.apiService.request(...).switchMap is not a function
To address this issue, I am aware that it can be resolved by including the following import statement:
import 'rxjs/add/operator/switchMap';
However, the challenge lies with my IDE, namely Visual Studio Code
, as it fails to indicate which operator imports are missing. Currently, the only method I have found to detect these missing operators is by running the application and monitoring for errors in the browser using the Developer Console
. Consequently, I have two questions:
- Is there a more efficient way to identify missing operators within an updated project? Why does the build process not recognize the absence of certain operators?
- Can
Visual Studio Code
be configured to highlight such errors prior to code deployment, rather than discovering them post-push during browser testing? It appears that syntax completion in this IDE functions even with unimported operators, which seems incorrect.
For reference, here is the output from ng -v
:
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 1.5.3
Node: 6.11.2
OS: darwin x64
Angular: 4.4.6
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic
... platform-server, router, tsc-wrapped
@angular/cdk: 2.0.0-beta.12
@angular/cli: 1.5.3
@angular/flex-layout: 2.0.0-beta.8
@angular/material: 2.0.0-beta.12
@angular-devkit/build-optimizer: 0.0.33
@angular-devkit/core: 0.0.21
@angular-devkit/schematics: 0.0.37
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.3
@schematics/angular: 0.1.7
typescript: 2.3.4
webpack: 3.8.1
Additionally, the output from npm list --depth=0
is provided below:
...