循環依存性が原因であると私は思う問題があります。いくつかの広範な研究の後、私は解決策を見つけることができませんでした。この問題に関連しているようです:TypeScriptのTypeError: b is undefined in __extendsですが、それは私を助けませんでした。Angular 2とSystemJSの循環依存性
this plunkerで問題を簡素化できました。
A
- クラス
F
から継承A
- クラス
B
の配列を含むクラスA
、、、作成することができ、工場:は基本的に3つのクラスがあります
A
またはB
値によって異なる
T彼は動的であることができる(各A
はパラメータであり、配列でもよい)パラメータリストを扱い、B
はA
の特殊化でファイルを処理することを目的としています。私は工場を削除しようとしたが、唯一A
とB
で、私はまだ同じエラーを取得:
TypeError: b is undefined Error loading http://localhost:3000/app/main.js
ここa.ts
import { F } from './f';
export class A {
children: A[]
constructor(hasChildren: boolean = false) {
if (hasChildren) {
for (var i = 0 ; i < 10 ; ++i) {
let isB = (Math.random() * 2) > 1;
this.children.push(F.createObject(isB))
}
}
}
}
b.tsのコードである
import { A } from './a';
export class B extends A {
}
およびf.ts
import { A } from './a'
import { B } from './b'
export class F {
static createObject(isB: boolean): A {
if (isB) {
return new B
} else {
return new A
}
}
}
エラーメッセージに示された 'B'を含む行ですか? –
javascriptコンソールで実際にクラスの名前が 'toto'と' tata'の場合、エラーメッセージは 'TypeError:bは未定義です http:// localhost:3000/app/main.js'をロードする際のエラー – Sunder
Plunkerリンクは機能しません私。 –