# Creation of a map with a set inside throws error because Daml Set does not match Javascript type

**URL:** <https://forum.canton.network/t/creation-of-a-map-with-a-set-inside-throws-error-because-daml-set-does-not-match-javascript-type/7225>\
**Category:** App Development\
**Tags:** daml, types, typescript, frontend, react, daml-finance\
**Created:** [May 3, 2024, 10:08am UTC](https://forum.canton.network/t/creation-of-a-map-with-a-set-inside-throws-error-because-daml-set-does-not-match-javascript-type/7225 "2024-05-03T10:08:29Z")\
**Posts on this page:** 2\
**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:** [May 3, 2024, 10:08am UTC](https://forum.canton.network/t/creation-of-a-map-with-a-set-inside-throws-error-because-daml-set-does-not-match-javascript-type/7225/1 "2024-05-03T10:08:29Z")

</div>

Hi all 🙂

I am facing an issue when trying to exercise a choice. My choice as an argument containing a field called warantObservers.

This field has the following type on the choice:

```haskell
type PartiesMap = Map Text Parties

where Parties = Set Party

```

on the FE it appears to me like this:

```haskell
warrantObservers: damlTypes.Map<string, Set<string>>

```

I am currently trying to pass it like this, but without success:

```haskell
damlTypes.emptyMap<string, Set<string>>().set("public", new Set(publicParty));

```

I do understand that the error is because the native TS set type is different from the one of DA.Types. My question. here is how can i can i recreate DA.Types Set on my side to exercise this choice?

I did check this part of your code [DA SET Types](https://github.com/digital-asset/daml/blob/a232bafd42232e8caeab1973c4349b8b8564ae42/compiler/damlc/daml-stdlib-src/DA/Set/Types.daml#L12), but i couldn’t fully understand how to recreate this on typescript.

Any help would be appreciated.  
Thanks and have a nice day 🙂

---

<div class="post-metadata">

**Author:** ![Gary\_Verhaegen](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/gary_verhaegen/32/81_2.png) [@Gary\_Verhaegen](https://forum.canton.network/u/Gary_Verhaegen)\
**Post date:** [May 3, 2024, 10:46am UTC](https://forum.canton.network/t/creation-of-a-map-with-a-set-inside-throws-error-because-daml-set-does-not-match-javascript-type/7225/2 "2024-05-03T10:46:26Z")

</div>

Hi @Joao_Freitas,

It’s been about two years since I last touched the TS side of our stack, so please bear with me as I try to remember things. Ramblings ahead.

What exactly do you mean by:

> [@Joao\_Freitas](#):
>
> on the FE it appears to me like this:
> 
> ```haskell
> warrantObservers: damlTypes.Map<string, Set<string>>
> 
> ```

I’m failing to reproduce that. Building a simple project, I have this Daml code:

```haskell
module User where

import DA.Map (Map)
import DA.Set (Set)

template User with
    username: Party
  where
    signatory username
    nonconsuming choice Test: () with
        argument: Map Text (Set Party)
      controller username
      do
        return ()

```

which generate a `module.d.ts` for that class that includes:

```typescript
import * as pkg97b883cd8a2b7f49f90d5d39c981cf6e110cf1f1c64427a28a6d58ec88c43657 from '@daml.js/97b883cd8a2b7f49f90d5d39c981cf6e110cf1f1c64427a28a6d58ec88c43657';
[...]
export declare type Test = {
  argument: damlTypes.Map<string, pkg97b883cd8a2b7f49f90d5d39c981cf6e110cf1f1c64427a28a6d58ec88c43657.DA.Set.Types.Set<damlTypes.Party>>;
};

```

which seems to suggest it should appear to you in the frontend as

```typescript
damlTypes.Map<string, pkg97b883cd8a2b7f49f90d5d39c981cf6e110cf1f1c64427a28a6d58ec88c43657.DA.Set.Types.Set<damlTypes.Party>>

```

rather than

```typescript
damlTypes.Map<string, Set<string>>

```

Digging further, if I look at the generated code for `97b883cd8a2b7f49f90...`, I eventually find this:

```typescript
export declare type Set<k> = {
  map: damlTypes.Map<k, {}>;
};

```

which seems to suggest you should be able to send your data in the form of:

```typescript
damlTypes.emptyMap<string,damlTypes.Map<damlTypes.Party, []>().set("public", damlTypes.emptyMap<damlTypes.Party, []>().set(publicParty, []));

```

My TypeScript is way too rusty at this point to remember which of those type annotations can be elided, but hopefully this helps you move a bit further.
