TypeScript module resolution

The official TypeScript documentation about modules and module resolution already provide a great set of information, but here are my notes which sums up the most important know-hows.

TypeScript

Example

// ./animals.ts
export interface IAnimal {
	name: string,
	legs: number,
	sayHi?: any
}

export const elephant: IAnimal = { 
	name: "Dumbo",
	legs: 4,
	sayHi: function() {
		console.log("Toot!");
	}
}

export const cow: IAnimal = {
	name: "Emma",
	legs: 4,
	sayHi: function() {
		console.log("Boo!");
	}
}

const cat: IAnimal = {
	name: "Daisy",
	legs: 4,
	sayHi: function() {
		console.log("Meow!");
	}
}

export { cat };
// ./index.ts
import * as animals from "./animals";
import { cow } from "./animals";
import { cat as daisy } from "./animals";

var dumbo = animals.elephant;
dumbo.sayHi();

var emma = cow;
emma.sayHi();

var fifi: animals.IAnimal = {
	name: "fifi",
	legs: 4,
	sayHi: function() {
		console.log("Woof!");
	}
}
fifi.sayHi();

daisy.sayHi();