I have successfully set up my Angular2 project using JSPM and SystemJS. I am attempting to import RxJS
and a few operators in my boot.ts
file, but for some reason, my import is not being transpiled into the final boot.js
output.
// boot.ts
import {Observable} from 'rxjs/Observable'
import 'rxjs/add/operator/debounceTime'
...
The code snippet above, as described on this page, results in:
// boot.js
System.register(['rxjs/add/operator/debounceTime', ...
After trying with both versions 1.7.5 and 1.8.0 of tsc
:
// tsconfig.json
{
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": true,
"noImplicitAny": false,
"module": "system",
"moduleResolution": "node",
"rootDir": "src",
"target": "es5"
}
, "exclude": [
"jspm_packages",
"node_modules",
"typings/main.d.ts",
"typings/main"
]
}
What could be causing this issue?
UPDATE
I have discovered that TypeScript will only emit
the import if it is actually used later in the code. It turns out that I just needed the additional operators to listen to a valueChanges
observable in an Angular2 control
. However, the extra operators cannot be patched if the Observable
class of rxjs
is missing. Therefore, I had to ensure that TypeScript would emit
the System.register
for Observable
by importing like so:
// boot.ts
import 'rxjs/Observable'
import 'rxjs/add/operator/debounceTime'
...
Credit goes to @RyanCavanaugh for guiding me in the right direction.