I'm trying to run a command with spawn from cross-spawn package, to install some dependencies with npm programmatically, these dependencies can be both rollup packages, or webpack packages, depending on the value of the variable bundler
spawn.sync(
'npm',
[
'add',
'-D',
'svelte',
bundler === 'rollup' ? ...rollupPackages : ...webpackPackages
],
{ cwd: projectPath }
)
But typescript compiler is complaining, more specifically on the spread operator of rollupPackages with the following message:
Expression expected. ts(1109)