You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I understand it's not part of the F# core library and isn't covered in the docs either, but IReadOnlyDictionary and IDictionary are abstractions around types that are covered by Fale (Dictionary and Map) and are well integrated with F# using dict and readOnlyDict. In TypeScript, the types compile to any, which makes it impossible to use it under certain circumstances.
Repro code
openSystem.Collections.GenerictypeT={A:int }// Write code or load a sample from sidebarletdict=[(1,{A=1});(2,{A=1});(3,{A=1})]|> readOnlyDict
letgetValue(dict:IReadOnlyDictionary<int,T>)value =
dict[value].A
letvalue= getValue dict 1
However, return getItemFromDict(dict_1, value_1).A; is an error in TypeScript (TS2571: Object is of type unknown). I understand that IDictionary is more complicated because it has a bigger surface, but compiling IReadOnlyDicitionary to something similar to what IMap is in TypeScript should be possible, right?
The text was updated successfully, but these errors were encountered:
Thanks for opening this issue. I think this should be possible. We have those interfaces for Python (almost) so should be possible for TypeScript as well. Let me have a look ...
@dbrattli Hi, sorry for bothering again. Did you have any success, it's kind of a blocking issue for me at the moment. I'd be happy to help out as well if I can, but maybe you could give me a pointer on where to start?
Description
I understand it's not part of the F# core library and isn't covered in the docs either, but IReadOnlyDictionary and IDictionary are abstractions around types that are covered by Fale (Dictionary and Map) and are well integrated with F# using
dict
andreadOnlyDict
. In TypeScript, the types compile to any, which makes it impossible to use it under certain circumstances.Repro code
results in this TypeScript code:
However,
return getItemFromDict(dict_1, value_1).A;
is an error in TypeScript (TS2571: Object is of type unknown
). I understand thatIDictionary
is more complicated because it has a bigger surface, but compilingIReadOnlyDicitionary
to something similar to whatIMap
is in TypeScript should be possible, right?The text was updated successfully, but these errors were encountered: