Reputation: 21
I have created a npm project, in which I am using typescript configuration (tsconfig.json).
In one .ts file, I have code such as below:
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 has module system as "commonjs".
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "commonjs",
"moduleResolution": "node"
.....
The above code works with "commonjs" module loader.
However, I want the module loader to be "es2015".
Changing the module system to "es2015", gives below error in Visual Studio Code on the export = function loginToLCSteps()
line:
Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. ts(1203)
The above code works on few of my peer machines.
I installed latest version of node, npm, Typescript however no success.
Upvotes: 2
Views: 8323
Reputation: 29
I'm a bit late, but maybe this can solve the problem:
export default ()= function loginToLCSteps() {
instead of
export = function loginToLCSteps() {
or
export default {}= () ={
or
export loginToLCSteps = () =>{
Upvotes: 0