问题
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"/>
回答1:
@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
回答2:
If you use the latest tslint standard configuration (tslint:latest), then it will report:
<reference> is not allowed, use imports
So it is recommended to use ES6-style imports (source).
来源:https://stackoverflow.com/questions/34119270/should-i-use-es6-import-or-reference-path-when-loading-typescript-definition-fil