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:
|
private string ConvertDictionary (Type type) |
|
{ |
|
var keyType = type.GenericTypeArguments[0]; |
|
var valueType = type.GenericTypeArguments[1]; |
|
return $"Map<{Convert(keyType)}, {Convert(valueType)}>"; |
|
} |
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)}>";
The documentation says that
Dictionaryobjects are serialized as plain objects, because ESMaps can't be serialised. This is what happens at runtime (dictionaries are indeed serialised as plain objects), but the generated bindings declare the type ofDictionaryobject as aMap, when it actually isn't:bootsharp/src/cs/Bootsharp.Publish/Common/TypeConverter/TypeConverter.cs
Lines 55 to 60 in 55a6e95
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
Recordbe more correct?