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

feat: Add support for additional Fable.Core.JS types #172

Conversation

NatElkins
Copy link
Contributor

Fixes #170 . Adds a few more types from Fable.Core.JS.

I tried to add BigInt64Array but was getting some error. I think it has something to do with this code:

/// <summary>
/// Determine if the type is from the ES5 library
///
/// This is to detect native utility types usage
/// </summary>
/// <param name="symbolOpt"></param>
/// <returns>
/// <c>True</c> if the type is from the ES5 library otherwise <c>False</c>
/// </returns>
let isFromEs5Lib (symbolOpt: Ts.Symbol option) =
    match symbolOpt with
    | None -> false
    | Some symbol ->
        match symbol.declarations with
        | None ->
            // For some reason, I can't seem to resolve the actual symbol for some Es5 types
            // So, we make a naive fallback checking the name of the symbol
            [ "Iterable"; "IterableIterator" ] |> List.contains symbol.name
        | Some declarations ->
            match declarations[0].parent.kind with
            | Ts.SyntaxKind.SourceFile ->
                let sourceFile = declarations[0].parent :?> Ts.SourceFile

                sourceFile.fileName.EndsWith("lib/lib.es5.d.ts")

BigInt64Array is from ECMAScript 2020. I haven't actually figured out how to debug this project and it's not in the file I'm interested in converting (the VS Code index.d.ts) so for now I just decided to leave it out.

@NatElkins
Copy link
Contributor Author

In addition to BigInt64Array would be nice to add AsyncIterable.

@MangelMaxime
Copy link
Contributor

I haven't actually figured out how to debug this project

But this project, do you mean Glutinum? If yes, you can run ./build.sh test specs --generate-only --watch, and then in VSCode using Vitest extension you can run any test manually and in debug mode so the debugger can be attached.

@NatElkins
Copy link
Contributor Author

Yeah I actually figured it out, I was just confused initially because the Javascript Debug Terminal wasn't in the same place as when you had done your Amplifying F# session:

image

But it can be found in the terminal:

image

Anyway, I think the PR is fine as-is, assuming you don't have any issues with it.

@MangelMaxime
Copy link
Contributor

Yeah I actually figured it out, I was just confused initially because the Javascript Debug Terminal wasn't in the same place as when you had done your Amplifying F# session:

This is probably because I probably because I switched the test framework or something.

Anyway, I think the PR is fine as-is, assuming you don't have any issues with it.

Agree, will merge it later this week.

@MangelMaxime MangelMaxime merged commit 01fa782 into glutinum-org:main Dec 16, 2024
2 checks passed
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

Successfully merging this pull request may close these issues.

Uint32Array should be replaced with JS.Uint32Array
2 participants