rescript-compiler icon indicating copy to clipboard operation
rescript-compiler copied to clipboard

[PoC] support inline/nested records inside of externals

Open zth opened this issue 4 months ago • 4 comments

Closes https://github.com/rescript-lang/rescript/issues/7386

Mostly a PoC for now, to see if it was possible to just extend the current mechanisms to this. Feedback appreciated. There are still issues to solve, but this serves as a base for discussion/experimentation.

Support inline record definitions in externals:

@module("node:fs")
external readFileSync: (
  string,
  ~options: {
    encoding?: [#utf8 | #ascii | #base64],
    flag?: string,
    misc?: {
      mode?: int,
    },
  },
) => option<{filename: string, size: string}> = "fs.readFileSync"

zth avatar Aug 22 '25 20:08 zth

cc @nojaf

zth avatar Aug 22 '25 20:08 zth

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript-lang/rescript@7791
@rescript/darwin-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-arm64@7791
@rescript/darwin-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-x64@7791
@rescript/linux-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-arm64@7791
@rescript/linux-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-x64@7791
@rescript/win32-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/win32-x64@7791

commit: 9eaa9be

pkg-pr-new[bot] avatar Aug 22 '25 20:08 pkg-pr-new[bot]

This would make writing bindings so much easier!!

tsnobip avatar Aug 24 '25 09:08 tsnobip

Beautiful! Ship it!

nojaf avatar Aug 25 '25 07:08 nojaf