Вместо
[...new Set([...[], ...(typeof a === 'string' ? [a] : a))]
возьмите, смотрите круглые, квадратные, круглые и ограничительные скобки в конце.
[...new Set([...[], ...(typeof a === 'string' ? [a] : a)])]
// ^
let a = 'abcdefg'
console.log([...new Set([...[], ...(typeof a === 'string' ? [a] : a)])]);