加载 Typescript 定义文件时应该使用 ES6 导入还是引用路径?

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

加载Typescript(1.6 以上)定义文件时,是否优先使用ES6 导入或引用路径注释?

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

import * as jasmine from './jasmine'

对比

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

@Yudhistira Arya,从@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.

当您的应用程序不使用 node.js 或 require.js 时,您可以使用引用标记 - 这写在 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

此外,您可以找到一些信息

如果你使用最新的tslint standard configuration (tslint:latest),那么会报:

<reference> is not allowed, use imports

所以推荐使用ES6风格的导入(source)。