TypeScript/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment4.js
Andrew Branch 083129f005
A union including non-iterable types is not iterable (#40350)
* WIP

* If method type derives solely from the global iterator or generator type, use its type arguments

* Add test for problem fixed as side effect
2020-09-11 09:31:22 -07:00

29 lines
783 B
TypeScript

//// [destructuringArrayBindingPatternAndAssignment4.ts]
// #35497
declare const data: number[] | null;
const [value] = data; // Error
//// [destructuringArrayBindingPatternAndAssignment4.js]
"use strict";
// #35497
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var _a = __read(data, 1), value = _a[0]; // Error