# Creating a type map on the front end

**URL:** <https://forum.canton.network/t/creating-a-type-map-on-the-front-end/7196>\
**Category:** App Development\
**Tags:** daml, react-ui, types, typescript, json-api, frontend, react\
**Created:** [April 4, 2024, 3:02pm UTC](https://forum.canton.network/t/creating-a-type-map-on-the-front-end/7196 "2024-04-04T15:02:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joao\_Freitas](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/joao_freitas/32/3352_2.png) [@Joao\_Freitas](https://forum.canton.network/u/Joao_Freitas)\
**Post date:** [April 4, 2024, 3:02pm UTC](https://forum.canton.network/t/creating-a-type-map-on-the-front-end/7196/1 "2024-04-04T15:02:33Z")

</div>

Hi 🙂

on my frontend code i have a choice that i need to exercise that has one argument that is of a type Map.  
I am making use of @daml/types at version 2.8.0  
My code is similar to the following short example:

```haskell
import * as damlTypes from "@daml/types"

const ledger = useLedger();

function handleExercise(value: string) {

 let myMap = damlTypes.emptyMap<string, string>()
 myMap.set("myKey", value);

ledger.exercise(MyChoice, contractId, { config:myMap })
}

```

This code works - by this i mean that the Typescript doesn’t complain of the type check on the argument- , but the set property of empytMap is not setting the key or the value on the Map created. The type of the config property on the argument is the following `Map<string, string>`

Any help on how to create a `Map<string, string>` would be appreciated.  
Thank you in advance.

---

<div class="post-metadata">

**Author:** ![WallaceKelly](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/wallacekelly/32/5046_2.png) [@WallaceKelly](https://forum.canton.network/u/WallaceKelly)\
**Post date:** [April 4, 2024, 3:18pm UTC](https://forum.canton.network/t/creating-a-type-map-on-the-front-end/7196/2 "2024-04-04T15:18:11Z")

</div>

Any chance it is just a typo?

```haskell
 let myMap = damlTypes.emptyMap<string, string>()
 maMap.set("myKey", value);

```

Compare `myMap` and `maMap`?

---

<div class="post-metadata">

**Author:** ![Joao\_Freitas](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/joao_freitas/32/3352_2.png) [@Joao\_Freitas](https://forum.canton.network/u/Joao_Freitas)\
**Post date:** [April 4, 2024, 3:25pm UTC](https://forum.canton.network/t/creating-a-type-map-on-the-front-end/7196/3 "2024-04-04T15:25:05Z")

</div>

No, the typo just exists on the example i gave on the question i made. I will edit it.

![Screenshot 2024-04-04 at 17.25.58](https://canada1.discourse-cdn.com/flex028/uploads/daml/original/2X/2/24d14c3d9b885ba48226815b62e3af99e1f6b3ff.png)

---

<div class="post-metadata">

**Author:** ![Joao\_Freitas](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/joao_freitas/32/3352_2.png) [@Joao\_Freitas](https://forum.canton.network/u/Joao_Freitas)\
**Post date:** [April 4, 2024, 3:40pm UTC](https://forum.canton.network/t/creating-a-type-map-on-the-front-end/7196/4 "2024-04-04T15:40:25Z")

</div>

Ok, after performing one change, I chained everything in one line (composition) it solved the issue 🙂

 ![Screenshot 2024-04-04 at 17.40.06](https://canada1.discourse-cdn.com/flex028/uploads/daml/original/2X/4/4f0a92198c59f2f5c31684a5cb5950cf905228ee.png)

---

<div class="post-metadata">

**Author:** ![Stephen](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/stephen/32/102_2.png) [@Stephen](https://forum.canton.network/u/Stephen)\
**Post date:** [April 4, 2024, 5:21pm UTC](https://forum.canton.network/t/creating-a-type-map-on-the-front-end/7196/5 "2024-04-04T17:21:26Z")

</div>

Indeed, `set` does not mutate its receiver map, it always returns a new map; the same is true of all the other methods, similar to how working with maps works in Daml proper.
