Closed
Description
TypeScript Version: 2.1.1 / nightly (2.2.0-dev.201xxxxx)
Code
const a = [];
const x: number[] | undefined = undefined;
a.push(...x);
Expected behavior:
Always throws 'TypeError: x is not iterable', regardless of the '--target'.
Actual behavior:
For '--target es5', no error is thrown. This is because the spread is transformed into a call to '.apply()', which accepts 'undefined'.
(I stumbled on this when compiling tsc with '--target es2015', which revealed that the compiler had a minor dependency on the noncompliant spread behavior.)