Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable support for spread operator feature in Visual Studio Code?

I have .js file running in Visual Studio Code 1.4.0

But when I do this

var test = state.selectedStorage.storageItems.map(i => {
          if(i.id != action.payload) return i;
          return {
              ...i,
              qty: i.qty - 1
          }
      });

I get an underline under the 3 dots(property assignment expected). When I try to do an npm start I get

 Unexpected token (134:18) 

this is my webpack.config.js

module.exports = {
  devtool: 'inline-source-map',
  entry: "./app/index.js",
  output: {
    path: __dirname + '/dist',
    filename: "bundle.js"
  },
  devServer: {
    contentBase: "./app",
    inline: true,
    port: 3333
  },
  module: {
    loaders: [
      {
        test: /\.jsx?$/,
        loader: 'babel-loader',
        exclude: /node_modules/,
        query: {
          presets: ['es2015', 'react']
        }
      },
      {
        test: /\.scss$/,
        loaders: ['style', 'css', 'sass']
      },
      {
        test: /\.woff($|\?)|\.woff2($|\?)|\.ttf($|\?)|\.eot($|\?)|\.svg($|\?)/,
        loader: 'url-loader'
      }
    ]
  },
   externals: {
    jquery: 'jQuery'
  },
} 
like image 972
chobo2 Avatar asked Dec 05 '25 18:12

chobo2


1 Answers

The Object rest/spread operator is not a part of ES2015. It is however supported by babel using the required plugin.

like image 59
Amit Avatar answered Dec 08 '25 12:12

Amit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!