System TypeをSystem Typeとして使用しているタイプコピーアプリケーションにRxJS 5をインポートしようとしています。それはほとんどありますが、私はSystem.jsからtypescriptへのRxJSのインポート
import * as Rx from "path/to/rxjs/Rx";
を行う際のRxオブジェクトは、直接受信のモジュールの内容が含まれていますが、モジュールの内容が含まれています「デフォルト」という名前のプロパティを持っていません。
Rx.Observable.of(1,2,3) ... //does not work, Rx.Observable is undefined
Rx.default.Observable.of(1,2,3) ... //DOES work, and contains the module contents as expected
私のTSconfigは、次のようになります。
{
"compilerOptions": {
"module": "system",
"allowSyntheticDefaultImports" : true,
"allowJs" : true,
"noImplicitAny": true,
"removeComments": false,
"preserveConstEnums": true,
"baseUrl" : "./",
"sourceMap": true,
"target": "es6",
"lib" : ["dom","es6","dom.iterable","scripthost","es2015","es2016"],
"strict": true,
"forceConsistentCasingInFileNames": true,
"outFile" : "./js/out.js"
},
"files": [
"main.ts"
]
}
そしてsystem.jsの私の呼び出しは次のようになります。
System.config({
"baseURL" : "/",
packages: {
'../node_modules/rxjs': {
defaultExtension: 'js',
}
}
});
System.import("./js/out.js")
.then(() => {
console.log("js loaded");
System.import("main");
})
.catch((err)=> {
console.error("Error: " + err);
});
これは私がsystem.jsに渡す必要のある構成変数だと思われますが、モジュール間システムのインポートに関するドキュメントは初心者にとってはあまり役に立ちません。私は既に../node_modules/rxjsのパッケージタイプを 'cjs'に設定しようとしましたが、同じ結果があります。
他にも:JavaScriptのための5つの異なるモジュールシステム(AT LEAST!)はまったく狂っています。そして、私はJavaのジグソーパズルが悪いと思った。