I can't seem to get optional arguments works with destructured arguments in TypeScript.
The right code is generated for the argument, but Typescript doesn't seem to allow me to use the generated variables in my code, defeating the purpose.
Am I doing something wrong? Here is a reduction:
declare var lastDirectionWasDownish : boolean;
function goToNext(
{
root: Node = document.activeElement,
actLikeLastDirectionWasDownish:boolean = lastDirectionWasDownish
} = {}
) {
return root && actLikeLastDirectionWasDownish;
}
which compiles into
function goToNext(_a) {
var _b = _a === void 0 ? {} : _a, _c = _b.root, Node = _c === void 0 ? document.activeElement : _c, _d = _b.actLikeLastDirectionWasDownish, boolean = _d === void 0 ? lastDirectionWasDownish : _d;
return root && actLikeLastDirectionWasDownish;
}