Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typescript 1.5,导入ES6模块_Typescript_Ecmascript 6 - Fatal编程技术网

Typescript 1.5,导入ES6模块

Typescript 1.5,导入ES6模块,typescript,ecmascript-6,Typescript,Ecmascript 6,我正在学习TypeScript 1.5,我想知道我可以导入一个外部ES6模块吗 我需要通过我的TS1.5代码()使用这个(公开ES6API) 以下是我尝试过的: import {rtts} from "../../node_modules/rtts_assert/es6/rtts_assert.es6"; import {rtts} from "../../node_modules/rtts_assert/es6/rtts_assert"; import * as rtts from "../.

我正在学习TypeScript 1.5,我想知道我可以导入一个外部ES6模块吗

我需要通过我的TS1.5代码()使用这个(公开ES6API)

以下是我尝试过的:

import {rtts} from "../../node_modules/rtts_assert/es6/rtts_assert.es6";
import {rtts} from "../../node_modules/rtts_assert/es6/rtts_assert";
import * as rtts from "../../node_modules/rtts_assert/es6/rtts_assert.es6";
import * as rtts from "../../node_modules/rtts_assert/es6/rtts_assert";
但是transpiler(TypeScript>ES5,带有CommonJS)没有找到这个模块


首先,使用相对路径从node_模块导入对我来说非常可疑。应该有更好的解决办法。(可能
从“rtts\u assert/es6/rtts\u assert.es6”
?)导入*为RTT)

其次,如果你想要ES5代码,那么你应该使用ES5模块。Chrome可以处理ES6模块,但如果您希望代码在IE9或类似版本中运行,则必须将ES6模块传输到ES5。如果导入模块,则其代码将按原样导入