# Daml Set corresponding Javascript type?

**URL:** <https://forum.canton.network/t/daml-set-corresponding-javascript-type/4156>\
**Category:** App Development\
**Created:** [March 19, 2022, 1:46am UTC](https://forum.canton.network/t/daml-set-corresponding-javascript-type/4156 "2022-03-19T01:46:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Max](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/max/32/2128_2.png) [@Max](https://forum.canton.network/u/Max)\
**Post date:** [March 19, 2022, 1:46am UTC](https://forum.canton.network/t/daml-set-corresponding-javascript-type/4156/1 "2022-03-19T01:46:25Z")

</div>

Hi Guys,  
I have a daml template that takes in an argument of type Set, the template looks like below. It’s the last field, observers

```haskell
template Asset with
    assetType : AssetType
    -- The asset owner
    owner : Party
    -- The amount of the asset
    amount : Decimal
    observers : Set Party

```

When using the Daml/ react library, What javascript datastructure do I pass in?  
I’ve tried passing in an an array of partyId, eg `[party]`, Not quite sure what I need to pass in.  
also tried to use the `DA.set`, but I get the second image’s error, not sure what to pass in here.  
 ![Screenshot 2022-03-18 at 6.36.18 PM](https://canada1.discourse-cdn.com/flex028/uploads/daml/original/2X/9/925089826f1aff777c0f8b4c514ca36d16712c56.png)  
 ![Screenshot 2022-03-18 at 6.45.20 PM](https://canada1.discourse-cdn.com/flex028/uploads/daml/original/2X/8/80a30de4bc169d0d2d29ffdf2e3590641e56fd2f.png)

---

<div class="post-metadata">

**Author:** ![Leonid\_Rozenberg](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/leonid_rozenberg/32/48_2.png) [@Leonid\_Rozenberg](https://forum.canton.network/u/Leonid_Rozenberg)\
**Post date:** [March 19, 2022, 3:16pm UTC](https://forum.canton.network/t/daml-set-corresponding-javascript-type/4156/2 "2022-03-19T15:16:37Z")

</div>

@Max A `Set k` is just a `Map k ()` , so per the encoding of [GenMap](https://docs.daml.com/json-api/lf-value-specification.html#genmap)’s I think you want to pass in `[(party1, {}), (party2, {}) ...]`

---

<div class="post-metadata">

**Author:** ![huw](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/huw/32/2343_2.png) [@huw](https://forum.canton.network/u/huw)\
**Post date:** [July 8, 2022, 7:06am UTC](https://forum.canton.network/t/daml-set-corresponding-javascript-type/4156/4 "2022-07-08T07:06:11Z")

</div>

Hey guys. I’m struggling to create an instance of `Map<Party, {}>` in sdk 1.17.1 using typescript. Not sure if the type has changed since when this question was posted. Hopefully I’m missing something simple:

```typescript
import { Map, Party } from "@daml/types";

const x: Map<Party, {}> = [['a', {}], ['b', {}]];

```

Getting this error:  
`Type '(string | {})[][]' is missing the following properties from type 'Map<string, {}>': get, has, set, delete, entriesArray`

---

<div class="post-metadata">

**Author:** ![cocreature](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/cocreature/32/36_2.png) [@cocreature](https://forum.canton.network/u/cocreature)\
**Post date:** [July 8, 2022, 7:32am UTC](https://forum.canton.network/t/daml-set-corresponding-javascript-type/4156/5 "2022-07-08T07:32:09Z")

</div>

Leo showed the encoding on the JSON API. Because that encoding is slightly awkward, the typescript libraries provide a native [Map type](https://docs.daml.com/app-dev/bindings-ts/daml-types/interfaces/Map.html). Start with [emptyMap](https://docs.daml.com/app-dev/bindings-ts/daml-types/modules.html#emptyMap) and then insert via `set`.

---

<div class="post-metadata">

**Author:** ![huw](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/huw/32/2343_2.png) [@huw](https://forum.canton.network/u/huw)\
**Post date:** [July 10, 2022, 11:31pm UTC](https://forum.canton.network/t/daml-set-corresponding-javascript-type/4156/6 "2022-07-10T23:31:06Z")

</div>

`Set`s and `Map`s in typescript have been bugging me for a while. Good to know this!
