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

Would it be preferable to use import comments or ES6 links when loading Typescript definition files (1.6 above)?

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

or

import * as jasmine from './jasmine'

vs.

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

+4
source share
2 answers

@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 modular constructs, and the constructs can be mixed and matched as desired.

, node.js require.js - typescript :

, node.js require.js,

,

+3

tslint (tslint: ), :

<reference> is not allowed, use imports

ES6 ().

+2

Source: https://habr.com/ru/post/1618793/


All Articles