I recently integrated TypeScript into an aging angularjs project with the intent of eventually transitioning to Angular 2+. In my TypeScript code, I am eager to utilize rxjs observables; however, I have encountered some unexpected behavior during my attempts to do so. Interestingly, Visual Studio 2019 struggles to locate the typings, whereas Visual Studio Code has no issue.
Upon direct compilation using tsc, the build is successful, and running the code within Visual Studio 2019 functions as anticipated. But during code development, Visual Studio throws a "cannot find module 'rxjs'" error, failing to display any type information.
I installed rxjs via npm install rxjs --save
and verified the presence of typing files in the mode_modules/rxjs folder.
For reference, here is my current tsconfig:
{
"compilerOptions": {
"sourceMap": true,
"noImplicitAny": false,
"module": "es6",
"target": "es5",
"allowJs": true,
"lib": [ "dom", "es7" ],
"moduleResolution": "node"
},
"include": [
"app"
],
"exclude": ["**/lib"]
}
Additionally, my package.json dependencies include:
"dependencies": {
"@types/angular": "^1.7.0",
"natives": "^1.1.6",
"rxjs": "^6.5.5",
"rxjs-compat": "^6.5.5"
},
An alternative approach is to import rxjs directly from the directory:
import { Observable } from './../../../node_modules/rxjs/internal/Observable';
At this juncture, I am uncertain of the next steps to take and have invested significant time in scouring for a resolution.