【发布时间】:2018-01-10 09:31:43
【问题描述】:
在我的tsconfig.json 中,当我将 compilerOptions.module 从“commonjs”更改为“es6”或“esnext”时,我的任何实例都会收到错误“SyntaxError: Unexpected token import”
import * as React from 'react'
感谢您的帮助
【问题讨论】:
-
浏览器为 Chrome 版本 59.0.3071.115(官方构建)(64 位)
-
你漏掉了浏览器name。
-
哦。固定的。这是浏览器(大声笑)
-
我笑得很开心。在 Chrome 中,我认为您必须打开 ES6 模块(实验性功能)。这是
chrome:flags的某个地方。老实说,当我们开始在工作中使用 TS 和 Babel 时,我并没有深入研究这个问题,因为我们必须针对 IE,它对 ES6 的支持很糟糕。
标签: javascript reactjs typescript