-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Function parameters with default value is not compiled properly to node environment #6139
Copy link
Copy link
Closed
Closed
Copy link
Labels
ExternalRelates to another program, environment, or user action which we cannot control.Relates to another program, environment, or user action which we cannot control.
Description
Hi,
i'm working on a node project and i recently modified my project to support the new feature of async/await 👍 .
as part of the modification i'v change the target to ES6 and added "strict mode" on the headers.
now i'm getting an error from node when trying to execute the project because of a compile error.
the exception is thrown while node try to parse a function that has a defined parameter with default value.
it's seems that the equal symbol is compiled with the default value but the node compiler don't understand it.
the function is:
/**
* Creating an Error Message for the response.
* @param error - the error to show
* @param statusCode - the status code.
* @returns {{statusCode: number, error: any}}
*/
public static CreateErrorResponse(error, statusCode = 0) {
return {
statusCode: statusCode,
error: error
};
}
the output of the compiler is:
static CreateErrorResponse(error, statusCode = 0) {
return {
statusCode: statusCode,
error: error
};
}
Exception:
/home/elior/dev/genesis/server/genesis-api-server/dist/server/utils.js:3
static CreateErrorResponse(error, statusCode = 0) {
^
SyntaxError: Unexpected token =
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:404:25)
at Object.Module._extensions..js (module.js:432:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/home/elior/dev/genesis/server/genesis-api-server/dist/server/actions/data-types/setDataType.js:15:15)
at Module._compile (module.js:425:26)
at Object.Module._extensions..js (module.js:432:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.api.actions.loadFile (/home/elior/dev/genesis/server/genesis-api-server/node_modules/actionhero/initializers/actions.js:75:26)
at /home/elior/dev/genesis/server/genesis-api-server/node_modules/actionhero/initializers/actions.js:104:21
my compile options:
"compilerOptions": {
"target": "ES6",
"module": "commonjs",
"moduleResolution": "node",
"isolatedModules": false,
"jsx": "react",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"declaration": false,
"noImplicitAny": false,
"removeComments": true,
"noLib": false,
"preserveConstEnums": true,
"suppressImplicitAnyIndexErrors": true,
"outDir": "../../dist/server/"
}
i have tried to search this on google but with no luck..
i'm using node v5.1.1
and typescript 1.7.3 to compile to code.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
ExternalRelates to another program, environment, or user action which we cannot control.Relates to another program, environment, or user action which we cannot control.