Skip to content

Remove Belt xxxUndefined API#8377

Merged
cknitt merged 1 commit into
masterfrom
remove-undefined
Apr 21, 2026
Merged

Remove Belt xxxUndefined API#8377
cknitt merged 1 commit into
masterfrom
remove-undefined

Conversation

@cknitt

@cknitt cknitt commented Apr 21, 2026

Copy link
Copy Markdown
Member

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

pkg-pr-new Bot commented Apr 21, 2026

Copy link
Copy Markdown

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
@cknitt cknitt merged commit bcc333c into master Apr 21, 2026
32 checks passed
@cknitt cknitt deleted the remove-undefined branch April 21, 2026 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants