6.x 错误中尚不支持装饰器
Decorators not supported yet in 6.x error
我正在尝试 运行 Jasmine 测试,同时使用 Babel 进行转译。
每次我尝试 运行 用 Aurelia.js 语法编写的测试时,我总是遇到不支持装饰器的错误(我的 Babel 版本是 6.3.15)
我的 .babelrc 文件中有以下内容:
.babelrc
{
"presets":["es2015", "stage-0", "stage-1"],
"plugins":["transform-class-properties", "transform-decorators"]
}
失败的片段是:
@inject(HttpClient)
export class Users {
heading = "test";
users = [];
Babel 肯定应该转换装饰器,因为其中一个预设包含它的插件吗?即使失败了,我的 transform-decorators 插件不会捕捉到它吗?另外,最初这是用 Babel 5.8.23 完成的,我仍然看到这个错误,所以我将包号更改为最新
确保您的 babel 选项包含以下内容:
optional: [
"es7.decorators",
...
]
它们应该在 config.js(对于 SystemJS)和 karma.conf.js(对于业力)中。
装饰器在 Babel 6 中被破坏了!
Here's babel 问题跟踪器中的问题。
基于 this reply 问题可能需要一段时间才能解决。
降级到 Babel 5 后,确保你的 babel 选项有 stage: 0
或 es7.decorators
选项。这里是您需要配置选项的地方:
我正在尝试 运行 Jasmine 测试,同时使用 Babel 进行转译。
每次我尝试 运行 用 Aurelia.js 语法编写的测试时,我总是遇到不支持装饰器的错误(我的 Babel 版本是 6.3.15)
我的 .babelrc 文件中有以下内容:
.babelrc
{
"presets":["es2015", "stage-0", "stage-1"],
"plugins":["transform-class-properties", "transform-decorators"]
}
失败的片段是:
@inject(HttpClient)
export class Users {
heading = "test";
users = [];
Babel 肯定应该转换装饰器,因为其中一个预设包含它的插件吗?即使失败了,我的 transform-decorators 插件不会捕捉到它吗?另外,最初这是用 Babel 5.8.23 完成的,我仍然看到这个错误,所以我将包号更改为最新
确保您的 babel 选项包含以下内容:
optional: [
"es7.decorators",
...
]
它们应该在 config.js(对于 SystemJS)和 karma.conf.js(对于业力)中。
装饰器在 Babel 6 中被破坏了!
Here's babel 问题跟踪器中的问题。
基于 this reply 问题可能需要一段时间才能解决。
降级到 Babel 5 后,确保你的 babel 选项有 stage: 0
或 es7.decorators
选项。这里是您需要配置选项的地方: