Skip to content

refactor(internals): Rev3 type narrowing for onMount hooks#3311

Open
dmaskasky wants to merge 1 commit intopmndrs:breaking/building-blocks-in-paramsfrom
dmaskasky:internals/bb-rev3-type-guards
Open

refactor(internals): Rev3 type narrowing for onMount hooks#3311
dmaskasky wants to merge 1 commit intopmndrs:breaking/building-blocks-in-paramsfrom
dmaskasky:internals/bb-rev3-type-guards

Conversation

@dmaskasky
Copy link
Copy Markdown
Collaborator

@dmaskasky dmaskasky commented Apr 21, 2026

Summary

Type-only / helper improvements for Rev3 building blocks. hasOnInit is not in this PR. BUILDING_BLOCK_ensureAtomState still calls atomOnInit?.(buildingBlocks, store, atom) on every new atom state (same as the upstream base).

Changes

  • import type for Atom / WritableAtom; add ExtractAtomArgs / ExtractAtomResult from ./typeUtils.ts.
  • Replace WritableAtomWithOnMount with WithOnMount and use WritableAtom<…> & WithOnMount<…> on AtomOnMount.
  • Add ActuallyWritableAtom and narrow isActuallyWritableAtom via typeof write === 'function'.
  • Generic hasOnMount using ExtractAtomArgs / ExtractAtomResult.
  • Small hasInitialValue / isAtomStateInitialized tweaks.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
jotai Ready Ready Preview, Comment Apr 21, 2026 6:51pm

Request Review

@codesandbox-ci
Copy link
Copy Markdown

codesandbox-ci Bot commented Apr 21, 2026

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 21, 2026

More templates

npm i https://pkg.pr.new/jotai@3311

commit: 493bc50

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 21, 2026

LiveCodes Preview in LiveCodes

Latest commit: 493bc50
Last updated: Apr 23, 2026 12:37am (UTC)

Playground Link
React demo https://livecodes.io?x=id/BC7QK34DW

See documentations for usage instructions.

@dmaskasky dmaskasky force-pushed the internals/bb-rev3-type-guards branch from 68ceb04 to 493bc50 Compare April 21, 2026 18:51
@dai-shi dai-shi added this to the v2.20.0 milestone Apr 21, 2026
@dai-shi dai-shi deleted the branch pmndrs:breaking/building-blocks-in-params April 22, 2026 23:56
@dai-shi dai-shi closed this Apr 22, 2026
@dai-shi dai-shi reopened this Apr 23, 2026
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