What is the difference between the three ways of loading typescript module dependencies?

Nefarious picture Nefarious · Apr 8, 2015 · Viewed 13k times · Source

What is the difference between the following ways of loading typescript module dependencies?

/// <amd-dependency path="someFile"/>

/// <reference path="someFile.ts" />

import someFile = require("someFile");

Answer

basarat picture basarat · Apr 9, 2015

Covered here : https://typescript.codeplex.com/wikipage?title=Modules%20in%20TypeScript

Disclaimer : My strong opinions follow : https://www.youtube.com/watch?v=KDrWLMUY0R0&hd=1

import someFile = require("someFile");

This should be your main form of import. Use this for JS libraries import $ = require("jquery"); as well as its relative file variant for your own files import someFile = require("./someFile");

/// reference path="someFile.ts" /

use this only to import type information from .d.ts files and your very own globals.d.ts or vendors.d.ts or tsd.d.ts

amd-dependency path="someFile"

You don't need this unless you want to require stuff in CSS / images into your TS.