- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.1k
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Milestone
Description
TS 1.7.0
This is valid ES6 from Mozilla but invalid TS:
function drawES6Chart({size = 'big', cords = { x: 0, y: 0 }, radius = 25} = {}) 
{
  console.log(size, cords, radius);
  // do some chart drawing
}
drawES6Chart({
  cords: { x: 18, y: 30 },
  radius: 30
});
To get it works, we must remove "= {}", so we can`t invoke function without arguments:
function drawES6Chart({size = 'big', cords = { x: 0, y: 0 }, radius = 25} ) 
{
  console.log(size, cords, radius);
  // do some chart drawing
}
drawES6Chart( { })  // ok
drawES6Chart()  // Error
But It works with array destructuring :
function drawES6Chart( [size = "big" ,cords = { x: 0, y: 0 }, radius = 25 ] = [] ) 
{
  console.log(size, cords, radius);
  // do some chart drawing
}
drawES6Chart([]); // Ok
drawES6Chart(); // Ok
I think empty object should work with default values:
var {size = 'big', cords = { x: 0, y: 0 } } = {} // Error
Should it work with no default values ?
var {p,q } = {} 
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
