Skip to content

allow null scale transform (#2451) - #2461

Open
cpruijsen wants to merge 1 commit into
observablehq:mainfrom
cpruijsen:fix/issue-2451
Open

allow null scale transform (#2451)#2461
cpruijsen wants to merge 1 commit into
observablehq:mainfrom
cpruijsen:fix/issue-2451

Conversation

@cpruijsen

Copy link
Copy Markdown

When scale.interval (or percent) is set, Plot applies an implicit scale transform. The documented way to keep interval domain alignment without that floor is transform: null (discussion 2450). Runtime already treats null as "no transform"; ScaleOptions.transform did not allow it, so the assignment failed under strictNullChecks.

This allows null on ScaleOptions.transform, matching other nullable scale options, and notes the escape hatch in the JSDoc and scale docs.

Decision: allow null on the existing option (same shape as type?: ScaleType | null). Alternative: a new interval flag meaning "align domain, don't floor values." Runtime already implements null, so widening the type is the smallest change.

A runtime unit test locks the existing transform: null + interval contract. A ts-morph test enables strictNullChecks (this repo's tsconfig does not) so the assignment is actually checked. Happy to drop the docs sentences or that type harness if you'd rather keep this types-only.

Fixes #2451
Related: #2423, discussion #2450

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.

Inconsistent type definition of _scale_._transform_

1 participant