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

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>