Skip to content

fix(RuleY): widen data generic to accept raw values#572

Open
ljodea wants to merge 3 commits into
mainfrom
fix/issue-41-ruley-datarow
Open

fix(RuleY): widen data generic to accept raw values#572
ljodea wants to merge 3 commits into
mainfrom
fix/issue-41-ruley-datarow

Conversation

@ljodea

@ljodea ljodea commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Closes #41

RuleY declared Datum = DataRecord but docs/runtime use <RuleY data={[0]} /> and the component cast data as DataRow[] before recordizeY. The public generic didn't match what recordize marks accept.

  • Widen to Datum extends DataRecord | RawValue, pass data directly (no cast)
  • Add scoped svelte-check + source contract tests so this stays honest
  • One-line RuleX generic alignment so Box.svelte's dynamic RuleMark union still type-checks

PR #48 only changed prop types on marks; it didn't fix the generic boundary.

ljodea added 3 commits June 25, 2026 23:39
Add tsconfig.check.json with svelteplot path aliases and ambient stubs
so package-level svelte-check can gate type regressions without the
300+ errors from the full test suite. Wire into root pnpm check.
Assert RuleY.svelte declares the widened Datum generic and passes data
to recordizeY without a DataRow cast. Fails on main until the fix lands.
Declare Datum extends DataRecord | RawValue so the public API matches
what recordizeY accepts; pass data directly without as DataRow[].

Align RuleX generic constraint so Box.svelte's dynamic RuleMark union
type-checks under the new scoped svelte-check gate.

Closes #41
@netlify

netlify Bot commented Jun 26, 2026

Copy link
Copy Markdown

Deploy Preview for svelteplot ready!

Name Link
🔨 Latest commit d280837
🔍 Latest deploy log https://app.netlify.com/projects/svelteplot/deploys/6a3e052dc0715600086289c3
😎 Deploy Preview https://deploy-preview-572--svelteplot.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@ljodea ljodea requested a review from gka June 26, 2026 04:53

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d280837b22

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Renders horizontal rule lines at specified y positions with customizable horizontal range
-->
<script lang="ts" generics="Datum = DataRecord">
<script lang="ts" generics="Datum extends DataRecord | RawValue = DataRecord | RawValue">

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve raw datums for explicit y accessors

With this widened generic, calls such as <RuleY data={[5]} y={(d) => d} /> now type-check with d as the raw number. However recordizeY only creates RAW_VALUE wrappers when y == null; when an explicit y callback is present it indexes the primitive as an object, so the callback receives the wrapper record instead of 5 and produces an invalid channel value. Either preserve raw datums even when explicit channels are supplied or keep the raw-value contract limited to the no-y shorthand.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair catch on recordizeY behavior, but out of scope for this PR.

The raw shorthand this fixes is the documented no-y form (<RuleY data={[50, 100, 150]} />). Combining a raw value array with an explicit y accessor was already handled the same way on main (RuleY still cast to DataRow[] before recordizeY); this diff only changes the declared generic and removes that cast.

recordizeY only wraps primitives when y == null by design — that is shared transform logic, not something RuleY's generic widening introduced. Tightening or fixing that path (raw data + explicit channel) belongs in a follow-up on recordizeY/recordizeX, not in the #41 type-honesty fix.

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.

data should be typed as DataRow[] instead of DataRecord[]

1 participant