@babel/plugin-transform-shorthand-properties
NOTE: This plugin is included in
@babel/preset-env
Example
In
JavaScript
var o = { a, b, c };
Out
JavaScript
var o = { a: a, b: b, c: c };
In
JavaScript
var cat = {
getName() {
return name;
},
};
Out
JavaScript
var cat = {
getName: function() {
return name;
},
};
Installation
- npm
- Yarn
npm install --save-dev @babel/plugin-transform-shorthand-properties
yarn add --dev @babel/plugin-transform-shorthand-properties
Usage
With a configuration file (Recommended)
babel.config.json
{
"plugins": ["@babel/plugin-transform-shorthand-properties"]
}
Via CLI
Shell
babel --plugins @babel/plugin-transform-shorthand-properties script.js
Via Node API
JavaScript
require("@babel/core").transformSync("code", {
plugins: ["@babel/plugin-transform-shorthand-properties"],
});