Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8668523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:14:03+00:00 2026-06-12T18:14:03+00:00

I have a class named BMW defined in BMW.ts as follows: ///<reference path=../Thing.ts/> module

  • 0

I have a class named BMW defined in BMW.ts as follows:

///<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();
         }
    }
}

In another file Thing.ts, I have Vehicle and Thing classes defined as follows:

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";
        }
    }
}

When I attempt to execute the following code after referencing Thing and BMW TypeScript files:

var car = new Entities.Cars.BMW("335i", "E90");
car.drive();

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T18:14:05+00:00Added an answer on June 12, 2026 at 6:14 pm

    There is nothing wrong with your code so it seems like your import order for the generated javascript files is wrong. The specification says the following:

    Initialization order of the source files that make up the global module ultimately depends on the order in which the generated JavaScript files are loaded at run-time (which, for example, may be controlled by tags that reference the generated JavaScript files).

    I have generated a file app.ts as follows:

    ///<reference path='Things.ts'/>
    ///<reference path='bmw/BMW.ts'/>
    var car = new Entities.Cars.BMW("335i", "E90");
    car.drive();
    

    At this point you have two options:

    1. Let the compiler determine the correct order for executing the files by generating a single output file

      tsc --out app.js app.ts

      Then you only have to source app.js.

    2. Specify the correct order manually. For me, the following is the only order that works without throwing errors.

      <html>
          <head>
              <script src="Things.js"></script>
              <script src="bmw/BMW.js"></script>
              <script src="app.js"></script>
          </head>
          <body>
          </body>
      </html>
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If you have a class named User and another class named Admin that extends
Inside a module I have a class named Process . module M Process= Class.new
I have a class named Channel with two methods defined: class Channel { void
I have a class named myClass. This class has TouchesMoved and TouchesBegan defined. This
I have a class named Foo that extends a class named Bar that extends
I have a class named xmlReader that have parse(String path) and parseXml(Document doc) methods.
i have class named Group i tried to test configuration: var cfg = new
I have a class named CropImageView which is extended from ImageView . but the
I have a Class named Question and a related Class named Answers. I want
I have a class named FirstViewController which is a subclass of UIViewController and I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.