# Extension For "As" Proposal

**URL:** <https://es.discourse.group/t/extension-for-as-proposal/907>\
**Category:** 💡 Ideas\
**Created:** [August 9, 2021, 1:48pm UTC](https://es.discourse.group/t/extension-for-as-proposal/907 "2021-08-09T13:48:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ethanlal04](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/ethanlal04/32/918_2.png) [@ethanlal04](https://es.discourse.group/u/ethanlal04)\
**Post date:** [August 9, 2021, 1:48pm UTC](https://es.discourse.group/t/extension-for-as-proposal/907/1 "2021-08-09T13:48:43Z")

</div>

I really love [this](https://es.discourse.group/t/destructuring-assign-selected-props-to-a-new-variable/118) idea by @yinon. He proposes that we could use an `as` keyword to merge the given props of an object into a new one.

```javascript
const { x, y } as coordinates = point;

```

Sadly, it's not showing any signs of progress. So I'd like to add some new use cases for that.

## Exports

It's not uncommon when we need to export some variables as a new object.

```javascript
let x = 0;
let y = 1;

export { x, y } as coordinates;

```

We can do it this way too. But it pollutes the namespace.

```javascript
export const coordinates = { x, y };

```

## Imports

We can import and encapsulate only what we need like this...

```javascript
import { createElement, FC, useState } as React from "react";

```

## Function Arguments

```javascript
function plot({ x, y } as coordinates) {
  // coordinates = { x, y }
}

```

Thank you 😀.

---

<div class="post-metadata">

**Author:** ![jithujoshyjy](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/jithujoshyjy/32/399_2.png) [@jithujoshyjy](https://es.discourse.group/u/jithujoshyjy)\
**Post date:** [August 9, 2021, 2:25pm UTC](https://es.discourse.group/t/extension-for-as-proposal/907/2 "2021-08-09T14:25:42Z")

</div>

Use of "as" patterns. Nice!  
will there be TS like `{ ...obj } as const`.  
😉 Anyway it looks good to me.  
EDIT:  
You might want to look at [mdn modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import) for currently supported as patterns.  
{ a as b, c as d } is currently supported! you might want to look into it!

---

<div class="post-metadata">

**Author:** ![ethanlal04](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/ethanlal04/32/918_2.png) [@ethanlal04](https://es.discourse.group/u/ethanlal04)\
**Post date:** [August 9, 2021, 2:42pm UTC](https://es.discourse.group/t/extension-for-as-proposal/907/3 "2021-08-09T14:42:13Z")

</div>

Thanks!

> [@jithujoshyjy](#):
>
> will there be TS like `{ ...obj } as const`.

I'd like to have that too. But `Object.freeze()` may make it look unnecessary. This syntax can also clash with Typescript's type assertions 🙁.
