As I understand it, the platform uses closure compiler to transpile code. And closure compiler officially supports ECMAScript 6 since 2015. But lightning-cli is configured to not allow version 6 or higher inside lightning components. Although, it is allowed to use it outside of component.
The question is:
Will we be allowed to use some ES2015 features at some point in the future?
Answer
It is possible to use some features of ECMAScript 6 in lightning components, here are some of the ones that I am aware of:
- ES6 Promises
- BlockScope Variables (Let and Const)
- Template literals
- Classes
- Arrow functions
- Default Parameters
- Destructuring
Documentation links for the aformentioned ES6 Features (if any):
Ideas for ES6 Features on the success community:
- Arrow functions, let, and const in Lightning Components (although already supported)
- ES6 Lambda support in Lightning component controllers
- Enable Lightning Component Developers to Use TypeScript and EcmaScript 6 (Several if not most of these features are already supported)
Unfortunately, there doesnt seem to be any official documentation on ES6 Supported features
Attribution
Source : Link , Question Author : Mr Smith , Answer Author : glls