I am just trying to get my head around TypeScript,
Say I have a module animals.ts
like this:
export module Animals {
export interface Animal {
name(): void;
}
export class Elephant implements Animal {
constructor() {
}
public name() {
console.log("Elephant");
}
}
export class Horse implements Animal {
constructor() {
}
public name() {
console.log("Horse");
}
}
}
And I want to use this module in another file animals_panel.ts
:
import animals = require("animals")
module AnimalPanel {
var animal = new animals.Animals.Elephant();
animal.name();
}
- It seems a bit weird to me that I have to use
animals.Animals.Elephant()
, I would have expectedAnimals.Elephant()
. Am I doing something wrong or is this the correct behaviour? - is it possible to import
import animals = require("animals")
inside theAnimalPanel
module (I get errors when I try to do this)?