# Parameter coercion

**URL:** <https://es.discourse.group/t/parameter-coercion/920>\
**Category:** 💡 Ideas\
**Created:** [August 12, 2021, 12:27am UTC](https://es.discourse.group/t/parameter-coercion/920 "2021-08-12T00:27:59Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![mmkal](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/mmkal/32/2650_2.png) [@mmkal](https://es.discourse.group/u/mmkal)\
**Post date:** [June 1, 2022, 11:06pm UTC](https://es.discourse.group/t/parameter-coercion/920/21 "2022-06-01T23:06:39Z")

</div>

On my team we bias heavily towards single parameter “options bag” functions - would the following count as destructuring or parameter coercion?

```javascript
function f({ age via assertNumber, name via assertString }) {
  //…
}

```

---

<div class="post-metadata">

**Author:** ![theScottyJam](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/thescottyjam/32/616_2.png) [@theScottyJam](https://es.discourse.group/u/theScottyJam)\
**Post date:** [June 2, 2022, 12:03am UTC](https://es.discourse.group/t/parameter-coercion/920/22 "2022-06-02T00:03:10Z")

</div>

In that example, you would be doing parameter coercion inside of destructuring, not on a function parameter directly.

I think this puts out a fair argument towards allowing `via` with destructuring. Many function definitions use option bags like that, and it would be nice if `via` can work on any parameter, whether or not it's in an options bag or not.

---

<div class="post-metadata">

**Author:** ![rdking](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/rdking/32/54_2.png) [@rdking](https://es.discourse.group/u/rdking)\
**Post date:** [June 2, 2022, 7:33pm UTC](https://es.discourse.group/t/parameter-coercion/920/23 "2022-06-02T19:33:12Z")

</div>

My objection and reasoning still stand, but there is a happy medium between the two: allowing parameter coercion as mutually exclusively with destructured renaming. I simply cannot find a non-confusing use of `{b: a via c}`.

[Previous page](https://es.discourse.group/t/parameter-coercion/920.md?page=1)
