Tag Archives: Typescript files

HOW DO I IMPORT OTHER TYPESCRIPT FILES?

How do I import other Typescript files?

We can use the reference tag to get the external inference of the file
Ex. 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”);
}
}

import animals = require(“animals”)

module AnimalPanel {

var animal = new animals.Elephant();
animal.name();
}