Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Several TS/JS basic types are not defined (like ArrayLike or Iterable) #386

Open
2 of 4 tasks
Booksbaum opened this issue Mar 10, 2021 · 0 comments
Open
2 of 4 tasks

Comments

@Booksbaum
Copy link
Contributor

Booksbaum commented Mar 10, 2021

There are several basic TypeScript (or JS) interfaces and types. Some are already handled and translated into suitable F# types, like Error (-> Exception) or Array (-> IList<'T>):

ts2fable/src/transform.fs

Lines 1337 to 1348 in 32a1a94

let abbrevTypes =
[
"Array", "type Array<'T> = System.Collections.Generic.IList<'T>"
"ReadonlyArray", "type ReadonlyArray<'T> = System.Collections.Generic.IReadOnlyList<'T>"
"ReadonlySet", "type ReadonlySet<'T> = Set<'T>"
"ReadonlyMap", "type ReadonlyMap<'K, 'V> = Map<'K, 'V>"
"RegExp", "type RegExp = System.Text.RegularExpressions.Regex"
"Error", "type Error = System.Exception"
"Function", "type Function = System.Action"
"Symbol", "type Symbol = obj"
"TemplateStringsArray", "type TemplateStringsArray = System.Collections.Generic.IReadOnlyList<string>"
] |> Map.ofList

But there are several more such types or interfaces that are commonly used, but not handled by ts2fable. I stumbled across these:

  • ArrayLike -> System.Collections.Generic.IList<'T> (-> same as Array)
  • PromiseLike -> Fable.Core.JS.Promise<'T>
  • Iterable -> System.Collections.Generic.IEnumerable<'T> ? are these two compatible?
  • Iterator & IterableIterator -> ? I don't think System.Collections.Generic.IEnumerator<'T> is compatible to any of them?
Booksbaum added a commit to Booksbaum/ts2fable that referenced this issue Mar 10, 2021
`ArrayLike` -> `System.Collections.Generic.IList<'T>`
`PromiseLike` -> `Fable.Core.JS.Promise<'T>`
Booksbaum added a commit that referenced this issue Mar 10, 2021
`ArrayLike` -> `System.Collections.Generic.IList<'T>`
`PromiseLike` -> `Fable.Core.JS.Promise<'T>`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant