typescript - 我对 TypeScript 还很陌生,遇到了一个错误:Unexpected token 'export'
问题描述
我一直在搜索互联网,但无济于事。
我的代码:
export const MESSAGES = {
TEST: {
ONE: 'Hello, world!'
}
}
配置:
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"strict": true
}
}
编辑:我需要一个 JavaScript 文件。
解决方案
export
关键字是 es6 模块语法,所以commonjs
改为esnext
.
{
"compilerOptions": {
"target": "es6",
"module": "esnext",
"strict": true
}
}
推荐阅读
- javascript - 使用 jsplumb 连接两个 div
- ruby-on-rails - Rails 验证:只有 N 条记录可以为真
- ios - 使用 Instruments 监控 AVPlayer 的网络数据使用情况
- javascript - 在reactjs中的渲染函数内更新数组时渲染视图
- scala - 无法在 Spark Sql 的 OutputMetrics 中获取 RecordsWritten
- bash - 脚本内的 KSH88 变量
- php - jQuery自动完成,通过选择建议选项填充多个字段
- python - 请求beautifulsoup 解析来自选择标签的值
- android - 带有阴影和箭头的自定义微调器
- react-native - 如何在排毒测试代码中选择位于另一个视图(视图上的按钮)但可见的视图(FlatList)?