Fix forwardRef no-props + CSSProperties/ReactNode widening (co-install @types/react)#6
Merged
Merged
Conversation
…eact.* types resolve Component packages do `import React from "react"` and type props via `React.ForwardRefExoticComponent<P>`, `React.CSSProperties`, `React.ReactNode`, etc. The scratch installer only fetched the target package (react is a peer dep), so `@types/react` was absent and every `React.*` type collapsed to `any`/`unknown`: forwardRef components extracted ZERO props (whole components emitted empty), and `CSSProperties`/`ReactNode` widened to a `string` placeholder. Co-install `react react-dom @types/react @types/react-dom` in the same scratch `npm install` command. Verified end-to-end: - react-responsive-modal: 0 props (skipped "no-props") → 26 props, compiles clean. - react-day-picker: 0 usable / 2 broken → 27 components, 27 usable, 0 broken (style → JsxDOM.style, modifiersStyles → Dict.t<JsxDOM.style>, footer → React.element).
jagguji
added a commit
that referenced
this pull request
Jun 9, 2026
Adds per-PR/commit **preview builds of the tool itself** via [pkg.pr.new](https://pkg.pr.new), mirroring blend's [#1358](juspay/blend-design-system#1358) but adapted for this repo (npm, single package, no build step). ## What it does A new `preview` job in `ci.yml` (gated on the smoke + golden tests passing) runs `npx pkg-pr-new publish` on every PR and every push to `main`. The bot posts a sticky PR comment with an install URL: ```bash npm i https://pkg.pr.new/@juspay/rescript-bindgen@<sha> ``` ## Why Right now, testing an unreleased fix means using local source or `npm link`. With previews, anyone can `npm i` the **exact build** of a PR/commit into another project and run `npx rescript-bindgen …` — no clone, no link, no waiting for a real release. (This is exactly the gap we hit testing the @types/react fix.) Previews live on pkg.pr.new's domain (not npmjs.org), are commit-pinned and ephemeral, and **don't** touch `latest`/`beta`. ## Setup The [pkg-pr-new GitHub App](https://github.com/apps/pkg-pr-new) is already installed on the repo (no token to manage). `PUBLISHING.md` documents the preview flow. ## Notes - Packs per the package's existing `files` allowlist (src/, types.d.ts, README, …), so the preview ships the working CLI. - No build step needed (pure ESM). - Branched off the latest `main` (includes #4/#5/#6); tests green.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug (one root cause, three symptoms)
Component packages do
import React from "react"and type their props viaReact.ForwardRefExoticComponent<P>,React.CSSProperties,React.ReactNode,React.MouseEvent, … But the scratch installer only fetched the target package —reactis a peer dependency, so@types/reactwas never installed. EveryReact.*type then collapsed toany/unknown, causing:Modal: React.ForwardRefExoticComponent<ModalProps & RefAttributes>resolved toForwardRefExoticComponent<any>(no call signatures, no recoverable type args), so the whole component emitted empty (Modal(no-props)). Same for@smastrom/react-rating.React.CSSProperties→ brokenstringinstead ofJsxDOM.style.React.ReactNode→ brokenstringinstead ofReact.element.The fix
Co-install React's type definitions in the same scratch
npm installcommand:(
resolve.mjs.) One line; no API change.Verified end-to-end
react-responsive-modalModal(no-props)(skipped)react-day-pickerstyle → JsxDOM.style,modifiersStyles → Dict.t<JsxDOM.style>,footer → React.elementNo regression:
npm test(smoke + 13 golden) andnpm run test:compilegreen. (Goldens use inline stubs, so they don't exercise the scratch installer — this path is verified via the real packages above.)