Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24744] iOS: Error when using ES6 arrow function

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionWon't Do
Resolution Date2019-07-18T14:34:44.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
LabelsES6, titanium
ReporterBrenton House
AssigneeUnknown
Created2017-05-23T17:06:26.000+0000
Updated2019-07-18T14:34:44.000+0000

Description

When I have the following code in my controller:
// Some comments here
var toggleRight = e => {

	$.rightmenu.zIndex = 500;
	$.content.animate({
		duration: 500,
		left:     0,
	});
};
I get this runtime error in iOS: {noformat} [ERROR] message = "Unexpected token ')'"; {noformat} Android works as expected.

Comments

  1. Sharif AbuDarda 2017-05-23

    Please share a full reproducible code/project for us to test the issue. Thanks.
  2. Brenton House 2017-05-23

    Steps to reproduce: 1. Create new Titanium project using CLI 2. Open index.js and replace the following:
       function doClick(e) {
       	alert($.label.text);
       }
       
    with this code:
       const doClick = e => {
       	alert($.label.text);
       };
       
    3. Run the app: appc ti build --platform ios --target simulator --log-level trace
  3. Christopher Williams 2017-05-23

  4. Brenton House 2017-05-23

    Thanks [~cwilliams]! I've been going back and forth changing settings trying to recreate that I forgot to switch that back. I did set jscore to true and now I get this error: {noformat} [ERROR] message = "Cannot access uninitialized variable."; {noformat} (if I use 'var' instead of 'const' it works fine)
  5. Alan Hutton 2019-07-18

    Closing per developer comments,

JSON Source