Skip to content

[DO NOT MERGE] test: regenerate bindings with rescript-bindgen #168 (@tag variants) - #138

Closed
jagguji wants to merge 1 commit into
mainfrom
try/bindgen-168
Closed

[DO NOT MERGE] test: regenerate bindings with rescript-bindgen #168 (@tag variants)#138
jagguji wants to merge 1 commit into
mainfrom
try/bindgen-168

Conversation

@jagguji

@jagguji jagguji commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

⚠️ DO NOT MERGE. A test build for juspay/rescript-bindgen#168, which is still open. package.json deliberately still pins bindgen 1.3.0, so src/ here cannot be reproduced from the pinned generator — merging would break this repo's "same blend version always produces byte-identical bindings" guarantee. Real adoption is a separate package.json bump PR once #168 ships.

Regenerated against the pkg.pr.new build of rescript-bindgen#168, which maps a nested discriminated union to a @tag variant instead of a flattened record.

Which build produced this

resolved:       https://pkg.pr.new/@juspay/rescript-bindgen@168
version string: 1.3.0
extract.mjs:    908a40b9cd780091

The version string is not proof — a pkg.pr.new build reports the version it branched from, so node_modules reads 1.3.0 either way. The resolved URL and hash are what identify it. (An earlier local attempt silently used a stale preview whose hash was 137c08b0…; same version string, different code.)

The diff — 4 files, +28/−41

DataTableTypes.rowAnimationConfig — record → @tag variant:

@tag("transitionType")
type rowAnimationConfig =
  | @as("bezier") Bezier({enterDuration: float, enterOffset: float, duration: float, bezier: (float, float, float, float)})
  | @as("spring") Spring({enterDuration: float, enterOffset: float, stiffness: float, damping: float, mass: float})

MenuV2Types.menuV2FlatRow — 6 %identity externals and 3 per-arm records → one matchable variant, retiring 3 ⚪ loose type_: string fields. Reading an arm was previously an unchecked cast; it is now compiler-verified.

BlendDesignSystemBindings.flattenMenuV2Groups returns the variant. Shared types 3360 → 3356.

Verification

check result
npm run generate exit 0
components 226 · ✅ 219 usable · 🔍 7 review · 🛑 0 broken — identical to baseline
npm run build 432 modules compile

Both arms construct, and the runtime object is flat with the real tag — exactly what the library reads:

{ transitionType: "bezier", enterDuration: 0.32, enterOffset: 12, duration: 0.4,
  bezier: [0.32, 0.72, 0, 1] }

Pattern matching compiles to a bare tag check, no wrapper:

if (cfg.transitionType === "bezier") { ... }

The #134 crash shape now fails to compile:

let bad: DataTableTypes.rowAnimationConfig = Bezier({ enterDuration: 0.32, enterOffset: 12.0 })
                                             ^
Some required record fields are missing: duration bezier.

That is the binding half of #134 closed at compile time, rather than relying on the runtime guard in juspay/blend-design-system#1653.

Migration notes for testing

This is a breaking change for existing consumers of both types.

rowAnimationConfig was a record; it is now a variant:

// before
{enterDuration: 0.32, enterOffset: 12.0, transitionType: Bezier}
// after
Bezier({enterDuration: 0.32, enterOffset: 12.0, duration: 0.4, bezier: (0.32, 0.72, 0.0, 1.0)})

MenuV2Types.MenuV2FlatRow.t and its from*/as* externals are gone — replace the casts with a switch.

One ergonomic wrinkle worth knowing: pattern matching needs the type in scope, or the constructors don't resolve:

let describe = (cfg: DataTableTypes.rowAnimationConfig) =>
  switch cfg {
  | Bezier({duration}) => ...
  | Spring({stiffness}) => ...
  }

Without the annotation you get "The variant constructor Bezier can't be found." Normal ReScript behaviour for a variant declared in another module, but it will be the first thing anyone hits.

Known issue in the candidate, not surfaced here

rescript-bindgen#168 has an open blocker: a self-referential discriminated union (type T = {kind:'leaf',…} | {kind:'branch', children: T[]}) recurses without bound and the component is dropped from the output entirely. blend has recursive types (MenuItemType.subMenu) and discriminated unions (MenuV2FlatRow) but never both in one type, so this regeneration cannot surface it. A green result here is not evidence that bug is fixed.

🤖 Generated with Claude Code

Regenerated against the pkg.pr.new build of juspay/rescript-bindgen#168, which
maps a nested discriminated union to a `@tag` variant instead of a flattened
record.

  resolved:       https://pkg.pr.new/@juspay/rescript-bindgen@168
  version string: 1.3.0        (a pkg.pr.new build reports the version it
                                branched from — the URL and hash below are
                                what identify it)
  extract.mjs:    908a40b9cd780091

package.json is DELIBERATELY untouched: the candidate was installed with
--no-save, so this branch is purely regenerated src/. That also means it must
not be merged — src/ here cannot be reproduced from the pinned bindgen 1.3.0,
which would break the "same blend version always produces byte-identical
bindings" guarantee. A real adoption is a separate package.json bump PR once
#168 ships.

Changes (4 files, +28/-41):

  - DataTableTypes.rowAnimationConfig: record -> @tag variant. Closes the
    binding half of #134 — `Bezier` can no longer be built without its curve.
  - MenuV2Types.menuV2FlatRow: 6 `%identity` externals + 3 per-arm records
    -> one matchable variant; retires 3 `⚪ loose` `type_` fields.
  - BlendDesignSystemBindings.flattenMenuV2Groups: returns the variant.
  - 3360 -> 3356 shared types.

Verified locally: generate exit 0, 219/226 usable, 0 broken (buckets identical
to baseline), all 432 modules compile, and the #134 crash shape now fails to
compile with "Some required record fields are missing: duration bezier".

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@pkg-pr-new

pkg-pr-new Bot commented Aug 6, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@juspay/rescript-blend@138

commit: b5e7ea0

jagguji added a commit that referenced this pull request Aug 6, 2026
…ate (@tag variants) (#139)

* chore(deps): bump @juspay/rescript-bindgen to ^1.4.0-beta.0 + regenerate

1.4.0-beta.0 ships #167/#169: a nested discriminated union now maps to a
`@tag` variant instead of a flattened record.

  - DataTableTypes.rowAnimationConfig: record -> @tag variant. Closes the
    binding half of #134 — `Bezier` can no longer be
    constructed without its curve, so the DataTable crash is now a compile
    error rather than something the library's runtime guard has to absorb.
  - MenuV2Types.menuV2FlatRow: 6 `%identity` externals + 3 per-arm records
    -> one matchable variant; retires 3 `⚪ loose` `type_` fields. Reading an
    arm was an unchecked cast; it is now compiler-verified.
  - BlendDesignSystemBindings.flattenMenuV2Groups returns the variant.
  - 3360 -> 3356 shared types.

Buckets unchanged: 226 components, 219 usable, 7 review, 0 broken. All 305
modules compile. src/ is byte-identical to the pkg.pr.new build of #168 that
was tested in #138, so the published beta reproduces exactly what was reviewed.

BREAKING for consumers of both types — `rowAnimationConfig` is no longer a
record, and `MenuV2FlatRow.t` with its from*/as* externals is gone.

Known issue in this beta, NOT triggered by blend: a self-referential
discriminated union (`type T = {kind:'leaf',…} | {kind:'branch', children: T[]}`)
recurses without bound and the component is dropped from the output with only
an `extract-error` line. blend has recursive types (MenuItemType.subMenu) and
discriminated unions (MenuV2FlatRow) but never both in one type, so nothing
here is affected. Verified still present in 1.4.0-beta.0.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* chore: drop stray .claude worktree gitlink from the previous commit

`git add -A` in the bump commit swept in `.claude/worktrees/feat+figma-code-connect`
as an embedded-repository gitlink (mode 160000). That is local Claude Code
state, not repository content, and a gitlink is unusable to anyone cloning.

Net effect across the branch is nil — the squash merge sees only the intended
6 files.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
@jagguji

jagguji commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by #139, which merged the same regeneration via the published @juspay/rescript-bindgen@1.4.0-beta.0src/ there is byte-identical to this preview build. Shipped as 0.0.37-1 under next. This branch was never meant to merge (package.json here still pins bindgen 1.3.0, so its src/ is not reproducible from the pin).

@jagguji jagguji closed this Aug 6, 2026
@jagguji
jagguji deleted the try/bindgen-168 branch August 6, 2026 17:12
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.

1 participant