From 50e1f089be492830cf8294d5cc5ad4ffb476b016 Mon Sep 17 00:00:00 2001 From: nelsonic Date: Thu, 29 Sep 2016 12:43:57 +0100 Subject: [PATCH] attempting to use spread syntax for Objects throws error. see: https://github.com/dwyl/goodparts/issues/230 & https://github.com/google/closure-compiler/issues/2027#issuecomment-249021195 --- examples/object.assign.js | 2 +- examples/object_spread_syntax.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 examples/object_spread_syntax.js diff --git a/examples/object.assign.js b/examples/object.assign.js index c6e8c69..81705f7 100644 --- a/examples/object.assign.js +++ b/examples/object.assign.js @@ -12,5 +12,5 @@ var flags = { var out = compile(flags); var filename = __filename.replace('.js', '.compiled.js'); var toSource = require('tosource'); // this is not a Standard! Using just for illustration purposes! -require('fs').writeFileSync(filename, toSource(out.compiledCode)); +require('fs').writeFileSync(filename, toSource(out.compiledCode); console.info(out.compiledCode); // will print 'var x = 3;\n' diff --git a/examples/object_spread_syntax.js b/examples/object_spread_syntax.js new file mode 100644 index 0000000..fc4e1cb --- /dev/null +++ b/examples/object_spread_syntax.js @@ -0,0 +1,15 @@ +var src = { src: ` + var user = { name: 'Jack', email: 'jackiscuel@email.net' }; + var meta = { height: '185', eyes: 'blue', hair: 'blonde' }; + var social = { twitter: 'jackyboy', instagram: 'iamjack' }; + // and combine them into a _new_ object with spread syntax: + var jack = {...user, ...meta, ...social}; +`}; + +var compile = require('google-closure-compiler-js').compile; + +var flags = { + jsCode: [src], +}; +var out = compile(flags); +console.info(out);