Skip to content

upgrade: match package upgrade for Solid 2.0#913

Open
davedbase wants to merge 2 commits into
solidjs-community:nextfrom
davedbase:update/v2/match
Open

upgrade: match package upgrade for Solid 2.0#913
davedbase wants to merge 2 commits into
solidjs-community:nextfrom
davedbase:update/v2/match

Conversation

@davedbase
Copy link
Copy Markdown
Member

@davedbase davedbase commented May 22, 2026

Solid 2.0 migration

Dependencies (package.json)

  • solid-js bumped from ^1.9.72.0.0-beta.13
  • @solidjs/web: 2.0.0-beta.13 added as both a peer and dev dependency

Source (src/index.ts)

  • JSX types moved from solid-js (no longer exported there) to @solidjs/web

Tests (test/index.test.tsx)

  • Added s.flush() after every setValue() call before reading reactive output. Solid 2.0 batches all signal writes by default — without an explicit flush the memo still sees the stale value at read time.

Correctness fix: stable accessor in MatchTag

Previously, MatchTag allocated a new () => props.on closure on every recomputation of the outer memo and passed it directly to the matched case handler:

// before — new function reference every render
return createMemo(() => props.case[kind()]?.(() => props.on) ?? props.fallback);

The accessor is now lifted to a stable variable defined once per component instance:

const value = () => props.on;   // same reference across all recomputations
const kind  = createMemo(() => props.on?.[props.tag ?? "type"]);
return createMemo(() => props.case[kind()]?.(value) ?? props.fallback);

Any case handler that stores or compares the accessor reference (e.g. in a createEffect dependency, a WeakMap keyed on the function, or a memoized child component) now behaves correctly.


Type improvement: PropertyKeystring | number

All four MatchTag overloads and both MatchValue overloads previously constrained discriminant values with PropertyKey (string | number | symbol). symbol was excluded in practice because it cannot be expressed as a key in an inline case object literal — TypeScript would reject { [mySymbol]: handler } at the call site. The old constraint silently accepted type signatures that could never produce a valid case object, pushing the error into the mapped type where it is difficult to read.

Narrowing to string | number moves the error to the tag field itself and makes the constraint honest. A comment in the source explains the reasoning:

// Tag values are constrained to string | number rather than PropertyKey because symbol keys
// cannot be expressed in inline object literals, making symbol-tagged unions impossible to
// match in practice. The narrower constraint surfaces the error at the tag field rather than
// inside the mapped type where it is harder to diagnose.

Documentation

  • partial prop: documented on every overload (/** Type-only — no runtime effect. … */) and in the README. partial solely switches the case mapped type between required and optional keys — it has no runtime behaviour.
  • MatchField: marked @deprecated in source (/** @deprecated Use {@link MatchTag} instead. */) and given a deprecation notice in the README.
  • README.md: partial-matching notes updated for both MatchTag and MatchValue; MatchField section added.
  • CHANGELOG.md: created.
  • .changeset/match-solid2-migration.md: created (major bump).

Breaking changes for downstream consumers

Area Change
Peer deps solid-js ≥ 2.0.0-beta.13 and @solidjs/web ≥ 2.0.0-beta.13 now required
Types Discriminant fields constrained to string | number; symbol tags no longer accepted
Types MatchField is deprecated — no removal yet, but editors will warn

The public runtime API (MatchTag, MatchValue, props shape) is otherwise unchanged.

Summary by CodeRabbit

  • New Features

    • Added support for Solid.js v2.0 (beta.13).
  • Breaking Changes

    • Updated peer dependencies to require solid-js@^2.0.0-beta.13 and @solidjs/web@^2.0.0-beta.13.
    • JSX types now sourced from @solidjs/web per Solid 2.0 conventions.
  • Documentation

    • Clarified partial prop behavior and edge cases in README.
    • Added migration notes and CHANGELOG entry for v2.0 compatibility.
    • Marked MatchField as deprecated; use MatchTag instead.

Review Change Stack

@davedbase davedbase added this to the Solid 2.0 Migration milestone May 22, 2026
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 22, 2026

🦋 Changeset detected

Latest commit: 7f584f1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@solid-primitives/match Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 773a7025-decd-457e-b3d5-b336c79f282b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@davedbase davedbase marked this pull request as ready for review May 22, 2026 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant