Skip to content

Remove Belt xxxUndefined API#8377

Open
cknitt wants to merge 1 commit intomasterfrom
remove-undefined
Open

Remove Belt xxxUndefined API#8377
cknitt wants to merge 1 commit intomasterfrom
remove-undefined

Conversation

@cknitt
Copy link
Copy Markdown
Member

@cknitt cknitt commented Apr 21, 2026

Summary

This PR removes the legacy Belt APIs that return Js.undefined and standardizes callers on the existing option-returning and OrThrow APIs instead.

It updates the public Belt runtime interfaces, removes the corresponding generated CJS/ESM exports, and refreshes affected tests and fixtures.

Motivation

  • This prepares the broader effort to get rid of the Js namespace altogether
  • undefined<'a> is likely a leftover from the early days before option<'a> compiled to undefined for None
  • These days, option<'a> should be used instead of undefined<'a>

Changes

  • Remove xxxUndefined helpers from Belt Array, Map, Set, MutableMap, MutableSet, MutableQueue, and MutableStack APIs
  • Remove the corresponding internal AVL tree/set helpers that only existed to support those public APIs
  • Add/use the OrThrow variant where needed (Belt.MutableStack.popOrThrow)
  • Update generated runtime artifacts under packages/@rescript/runtime/lib
  • Update affected runtime tests and fixture code to use option-returning replacements

Migration

Use the existing non-undefined APIs instead:

  • getUndefined -> get
  • minUndefined / maxUndefined -> minimum / maximum
  • minKeyUndefined / maxKeyUndefined -> minKey / maxKey
  • peekUndefined / popUndefined -> peek / pop
  • topUndefined / popUndefined on Belt.MutableStack -> top / pop
  • use *OrThrow when throwing behavior is desired

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 21, 2026

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript@8377

@rescript/darwin-arm64

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

@rescript/darwin-x64

npm i https://pkg.pr.new/@rescript/darwin-x64@8377

@rescript/linux-arm64

npm i https://pkg.pr.new/@rescript/linux-arm64@8377

@rescript/linux-x64

npm i https://pkg.pr.new/@rescript/linux-x64@8377

@rescript/runtime

npm i https://pkg.pr.new/@rescript/runtime@8377

@rescript/win32-x64

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

commit: ea0d555

@cknitt cknitt requested review from fhammerschmidt and zth April 21, 2026 07:35
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.

2 participants