定位ECMAScript模块时无法使用导出分配

时间:2019-04-16 05:55:19

标签: typescript ecmascript-6 commonjs

我创建了一个npm项目,其中正在使用打字稿配置(tsconfig.json)。

在一个.ts文件中,我有如下代码:

export = function loginToLCSteps() {
    this.setDefaultTimeout(30 * 1000);
    let stage = serenity.callToStageFor({
        actor: (name) => Actor.named('James').whoCan(BrowseTheWeb.using(protractor.browser))
    });

    this.Given(/^that Doctor is on Login screen$/, function () {
        return stage.theActorCalled('James').attemptsTo(
            AccessLifecare.called()
        );
    });

    this.When(/^he enters credentials and click on Login button$/, function () {
        return stage.theActorCalled('James').attemptsTo(
            Login.called()
          );
      });

      this.Then(/^he should be navigate to Role and Care Unit selection screen$/, function () {
        return stage.theActorCalled('James').attemptsTo(
            Wait.until(SelectRoleAndUnitPage.selectRoleAndUnitLabel, Is.visible()),
        );
      });
};

tsconfig.json的模块系统为“ commonjs”。

"compilerOptions": { "baseUrl": "./", "outDir": "./dist/out-tsc", "sourceMap": true, "declaration": false, "module": "commonjs", "moduleResolution": "node" .....

上面的代码与“ commonjs ”模块加载器一起使用。 但是,我希望模块加载器为“ es2015 ”。 将模块系统更改为“ es2015 ”,在export = function loginToLCSteps()行的Visual Studio代码中给出以下错误:

定位ECMAScript模块时,不能使用导出分配。考虑使用“导出默认值”或其他模块格式代替。 ts(1203)

上面的代码在我的一些对等机器上都可以使用。

我安装了最新版本的节点npm,Typescript,但是没有成功。

0 个答案:

没有答案