BMW.tsで次のように定義されたBMWという名前のクラスがあります。
///<reference path="../Thing.ts"/>
module Entities.Cars {
import e = Entities;
export class BMW extends Vehicle {
public series: string;
constructor ( model : string, series : string) {
super("BMW", model)
this.series = series;
}
drive() {
alert("driving a bimmer is a different kind of feeling");
}
toString() : string
{
return this.getName() + " " + this.series + " " + this.getType();
}
}
}
別のファイルThing.tsには、VehicleクラスとThingクラスが次のように定義されています。
module Entities {
// Class
export class Thing {
private _name: string;
private _type: string;
// Constructor
constructor (public name: string, public type: string) {
this._name = name;
this._type = type;
}
getName(): string { return this._name; }
setName(name: string) { this._name = name; }
getType(): string { return this._type; }
setType(name: string) {
this._type = name;
}
toString() : string
{
return "Entities.Thing";
}
}
export class Vehicle extends Thing {
public cargoCapacity: number;
public fuelType: string;
public owner: string;
constructor (make: string, model : string) {
super(make, model)
}
drive() {
}
toString(): string {
return "Entities.Vehicle";
}
}
}
ThingファイルとBMWTypeScriptファイルを参照した後、次のコードを実行しようとすると、次のようになります。
var car = new Entities.Cars.BMW("335i", "E90");
car.drive();
「MicrosoftJScriptランタイムエラー:プロパティ'BMW'の値を取得できません:オブジェクトがnullまたは未定義です」というエラーで例外が発生します。BMW用に生成されたJavascriptにエラーがあります。上記のスニペットの何が問題になっていますか?