Search code examples
typescripttypescript1.6

Should I use ES6 import or reference path when loading Typescript definition file?


Would it be preferred to use ES6 import or reference path comment when loading Typescript (1.6 above) definition files?

import {describe, it, expect, jasmine} from './jasmine'

or

import * as jasmine from './jasmine'

vs.

///<reference path="jasmine.d.ts"/>


Solution

  • @Yudhistira Arya, as you can see from @ahejlsberg ES6 Modules #2242 post

    It is recommended that TypeScript libraries and applications be updated to use the new syntax, but this is not a requirement. The new ES6 module syntax coexists with TypeScript's original internal and external module constructs and the constructs can be mixed and matched at will.

    You can use reference tag when your application does not use node.js or require.js - this is written in typescript handbook:

    Applications not using node.js or require.js do not need to use external modules and can best be organized using the internal module concept

    Also, some information you can find here