Closed
Description
TypeScript Version: 2.3.2
Code
// A *self-contained* demonstration of the problem follows...
function f({ a = false, b = '/' } = {}) {
}
f(true);
f('lol');
f(5);
Expected behavior:
The 3 calls to f
should fail at compile time.
Actual behavior:
The calls do not fail.
Comment:
I suppose that typescript consider that the argument to the function is an object. And thus the parameter available inside the function body will simply be this same object but with two extra properties a
and b
set to their default values.
It makes sense, but it seems completely counter-intuitive to the programmer expectations :)