我已经使用JSPM和SystemJS设置了我的Angular2项目。我尝试在我的boot.ts
文件中导入RxJS
和几个运算符,但是我的导入不会被转储到boot.js
输出中。所以为什么tsc(Typescript编译器)忽略RxJS导入?
// boot.ts
import {Observable} from 'rxjs/Observable'
import 'rxjs/add/operator/debounceTime'
...
如下概括:https://github.com/ReactiveX/RxJS#es6-via-npm最终成为
// boot.js
System.register(['rxjs/add/operator/debounceTime', ...
tsc
(试图与1.7.5和1.8.0):
// 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"
]
}
我在想什么???
UPDATE
打字稿只会emit
进口如果在后面的代码中使用。我只需要额外的操作员来收听可以观察到的Angular2 control
的valueChanges
。但是,如果Observable
类的rxjs
缺失,则不能修补其他运营商。让你有种需要通过导入这样的强制打字稿到emit
的System.register
为Observable
:
// boot.ts
import 'rxjs/Observable'
import 'rxjs/add/operator/debounceTime'
...
一切归功于@RyanCavanaugh谁指出我到正确的方向。
请参阅https://github.com/Microsoft/TypeScript/wiki/FAQ#why-are-imports-being-elided-in-my-emit –
感谢您的快速回复'import'rxjs/Observable''完成了这项工作。 – TylerDurden