diff --git a/src/marks/tip.d.ts b/src/marks/tip.d.ts index 7faf45b759..6dfa5842d4 100644 --- a/src/marks/tip.d.ts +++ b/src/marks/tip.d.ts @@ -3,7 +3,7 @@ import type {Data, FrameAnchor, MarkOptions, RenderableMark} from "../mark.js"; import type {TextStyles} from "./text.js"; /** Options for the tip mark. */ -export interface TipOptions extends MarkOptions, TextStyles { +export interface TipOptions extends Omit, TextStyles { /** * The horizontal position channel specifying the tip’s anchor, typically * bound to the *x* scale. diff --git a/test/options.test-d.ts b/test/options.test-d.ts index f4a0068c38..767624d60f 100644 --- a/test/options.test-d.ts +++ b/test/options.test-d.ts @@ -2,6 +2,7 @@ import {it} from "vitest"; import {valueof} from "../src/options.js"; +import * as Plot from "../src/index.js"; it("a function is not a valid input data", () => { // @ts-expect-error @@ -22,3 +23,19 @@ it("a bigint is not a valid value", () => { // @ts-expect-error valueof(null, 2n); }); + +it("tip options do not allow nested tips", () => { + // @ts-expect-error tips cannot create another tip + Plot.dot([1, 2], {tip: {tip: {}}}); + // @ts-expect-error the tip mark ignores its own tip option + Plot.tip([1, 2], {tip: true}); + // @ts-expect-error the Tip constructor has the same options as the factory + new Plot.Tip([1, 2], {tip: {}}); +}); + +it("tip options retain shared mark and text styling", () => { + Plot.dot([1, 2], {tip: {anchor: "top", fill: "white", fontSize: 14, textPadding: 4}}); + Plot.dot([1, 2], {tip: true}); + Plot.tip([1, 2], {anchor: "top", fill: "white", fontSize: 14, textPadding: 4}); + new Plot.Tip([1, 2], {frameAnchor: "top", format: ".1f"}); +});