Basics

Challenges

Classes

Cookies

Debugging

Events

External Files

Flow Control

Forms

Functions

Html Elements

Installation

Interfaces

Keywords

Modules

Namespaces

Operators

Reference Files

String

Types

TypeScript - import relative vs non-relative

http://www.typescriptlang.org/docs/handbook/modules.html

In order to understand how TypeScript resolves the location of the modules you want to import, you need to understand the difference between relative imports and non-relative imports.

As a general rule of thumb, you should refer to your own modules with relative references and 3rd party modules with non-relative references.

 

Relative References


// off of the root
import { Foo } from '/foo.ts';

// in the current folder
import { Foo } from './foo.ts';

// up two folders above and then in a 'folder' folder name
import { Foo } from '../../folder/foo.ts';

 

Non-Relative References

Non-relative references are nearly identical except for the fact they do not include any references to the folder structure before the module name.


// notice that these don't include any paths.
import * as $ from 'jquery';
import * as lodash from 'lodash';
import { Developer } from 'person.ts';