I am dealing with multiple modules and I need to organize and categorize them into different arrays based on their types
const firstModules: any[] = [
Module1,
Module2,
Module3,
Module4
];
const secondModules: any[] = [
Module5,
Module6,
Module7,
Module8
]
When using spread operator, everything works fine
imports: [Module0, ...firstModules, ...secondModules]
However, if I try to use the concat method instead, the components do not work as expected:
imports: [Module0].concat(firstModules, secondModules)
What is the difference for the TypeScript compiler between these two methods? At a glance,
console.log([Module0, ...firstModules, ...secondModules]);
console.log([Module0].concat(firstModules, secondModules));
Both results may seem identical, but they behave differently in practice.