Skip to content

Commit ede80c1

Browse files
Don't use spread operator when pushing arrays onto other arrays.
Spreading emits as ".push.apply(reciver, values)". This pushes every elements in values onto the stack before calling the function. This can easily stack overflow if the amount of values is high (i hit this with ~10k values on my own system).
1 parent 6db4faf commit ede80c1

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/services/services.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,11 +1789,6 @@ namespace ts {
17891789
sourceFile.moduleName = moduleName;
17901790
}
17911791

1792-
// Store syntactic diagnostics
1793-
if (diagnostics && sourceFile.parseDiagnostics) {
1794-
diagnostics.push(...sourceFile.parseDiagnostics);
1795-
}
1796-
17971792
let newLine = getNewLineCharacter(options);
17981793

17991794
// Output
@@ -1815,9 +1810,8 @@ namespace ts {
18151810

18161811
var program = createProgram([inputFileName], options, compilerHost);
18171812

1818-
if (diagnostics) {
1819-
diagnostics.push(...program.getCompilerOptionsDiagnostics());
1820-
}
1813+
addRange(/*to*/ diagnostics, /*from*/ sourceFile.parseDiagnostics);
1814+
addRange(/*to*/ diagnostics, /*from*/ program.getCompilerOptionsDiagnostics());
18211815

18221816
// Emit
18231817
program.emit();
@@ -4188,7 +4182,7 @@ namespace ts {
41884182
var result: DefinitionInfo[] = [];
41894183
forEach((<UnionType>type).types, t => {
41904184
if (t.symbol) {
4191-
result.push(...getDefinitionFromSymbol(t.symbol, node));
4185+
addRange(/*to*/ result, /*from*/ getDefinitionFromSymbol(t.symbol, node));
41924186
}
41934187
});
41944188
return result;

0 commit comments

Comments
 (0)