Skip to content

exclude tip from TipOptions (#2459) - #2462

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

exclude tip from TipOptions (#2459)#2462
cpruijsen wants to merge 1 commit into
observablehq:mainfrom
cpruijsen:fix/issue-2459

Conversation

@cpruijsen

Copy link
Copy Markdown

Fixes #2459.

MarkOptions.tip is typed as TipOptions, and TipOptions extended MarkOptions, so nested tip objects typechecked:

Plot.dot(penguins, {x: "culmen_length_mm", y: "culmen_depth_mm", tip: {tip: {tip: {}}}})

The tip mark cannot have a nested tip. The constructor already forces tip: false when options.tip is truthy. This change makes TipOptions extend Omit<MarkOptions, "tip"> so the types match that.

Decision

  • Chose: drop tip from TipOptions itself.
  • Alternative: keep TipOptions extends MarkOptions and omit tip only on the object type of MarkOptions.tip.
  • Reasoning: this is what [Types] Wrong recursion in Mark’s _tip_ option #2459 asked for, and it matches how Plot.tip() behaves at runtime. RasterOptions already uses Omit<MarkOptions, …> for options a mark cannot use.
  • Happy to switch to the narrower Omit on MarkOptions.tip if you would rather leave Plot.tip(data, { tip: false }) typechecking as a no-op.

No runtime or docs change; the tip-mark docs never listed a tip option on Plot.tip().

Test plan

  • Plot.dot([], { tip: { tip: true } }) is a type error
  • Plot.tip([], { tip: true }) is a type error
  • Plot.dot([], { tip: true }) still typechecks
  • Plot.dot([], { tip: { anchor: "top", pointer: "xy" } }) still typechecks
  • Plot.tip([], { x: 0, y: 0, anchor: "top" }) still typechecks

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.

[Types] Wrong recursion in Mark’s _tip_ option

1 participant