Named destructed arguments

Nowadays it's really common to use object destruction for params (eg. React component props) and it's quite the default in a lot of cases. I keep finding myself in situations, where at the end I also need the props object as a whole, either for debugging purposes or passing forward. What happens next is that I move my destruction into the function body so I have both.

function Foo ({ x, y, y}) {}

// =>

function Foo (props) {
    const { x, y, y} = props
}

It's just minor annoyance, but still, it'd be nice to be able to simplify this by using "named destruction", something like:

function Foo (props { x, y, z }) {
   console.log(props, x, y, z)
}

Hi @wintercounter

Some similar ideas if you hadn't come across them:

Thanks! I tried to search before posting, but not exactly the naming I was searching for :) While I see these proposals solving my idea, I really don't like any of those syntaxes for this exact purpose.

The dead proposal GitHub - gilbert/es-explicit-this: Explicit this naming in ECMAScript functions has the same syntax though it only for the special case of this param (and disallow this usage in the function body).

function fullName(this {firstName, lastName}) { // destructuring
  return `${firstName} ${lastName}`
}

I believe that's the same syntax I proposed. Obviously I'm on board with the proposal then. Should we write it up formally?

Somehow I missed the last thread linked. Yes, yours is the same as mine.