Note that there are some explanatory texts on larger screens.

plurals
  1. POTypeScript internal module usage
    primarykey
    data
    text
    <p>I have a class named BMW defined in BMW.ts as follows: </p> <pre><code>///&lt;reference path="../Thing.ts"/&gt; 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(); } } } </code></pre> <p>In another file Thing.ts, I have Vehicle and Thing classes defined as follows:</p> <pre><code>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"; } } } </code></pre> <p>When I attempt to execute the following code after referencing Thing and BMW TypeScript files:</p> <pre><code>var car = new Entities.Cars.BMW("335i", "E90"); car.drive(); </code></pre> <p>I get an exception with the following error " Microsoft JScript runtime error: Unable to get value of the property 'BMW': object is null or undefined". The generated Javascript for BMW has an error. What is wrong with my above snippet?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload