Dictionary types are declared as Map<K,V> when they should be Record<K,V> · Issue #166 · elringus/bootsharp · GitHub
Skip to content

Dictionary types are declared as Map<K,V> when they should be Record<K,V> #166

Description

@desplesda

The documentation says that Dictionary objects are serialized as plain objects, because ES Maps can't be serialised. This is what happens at runtime (dictionaries are indeed serialised as plain objects), but the generated bindings declare the type of Dictionary object as a Map, when it actually isn't:

This means that if you're using the value in TypeScript, you need to manually tell the compiler that it's actually a different type (such as by going const xReal = x as unknown as Record<string,T>;)

Is this behaviour what was intended? If not, would declaring the type as a Record be more correct?

 return $"Record<{Convert(keyType)}, {Convert(valueType)}>"; 

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions