简体   繁体   中英

ES6 not supported in Closure Compiler

I'm using Google Closure Compiler and I'm getting the following error:

ES6_FEATURE: this language feature is only supported in es6 mode: computed property. Use --language_in=ECMASCRIPT6 or ECMASCRIPT6_STRICT to enable ES6 features.

The line that triggers this error is this one:

var TheCellRef = LeadImport2ExcelLibrary['utils']['encode_cell']({ ['c']: C, ['r']: R });

Basically I'm passing an object that I'm creating on the same line. I know I could simply add the support for ES6 in the JavaScript source header but I was wondering why this error is coming up and how to fix it?

It's because you are using Computed Property Names in the literal object:

{ ['c']: C, ['r']: R }

An es5 compatible replacement might be:

var TheCellRef = LeadImport2ExcelLibrary['utils']['encode_cell']({ "c": C, "r": R });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM