From 5e65515e7542eb20494352e73a3a8b1725011e7d Mon Sep 17 00:00:00 2001 From: Enes Uygur Date: Sun, 15 Nov 2026 23:38:22 +0300 Subject: [PATCH] fix #2156 arrow-reverse marker types --- src/marker.d.ts | 10 ++++++---- test/marker.test-d.ts | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 test/marker.test-d.ts diff --git a/src/marker.d.ts b/src/marker.d.ts index 3a2cc7071a..e75552bf1b 100644 --- a/src/marker.d.ts +++ b/src/marker.d.ts @@ -65,7 +65,8 @@ export interface MarkerOptions { * The marker for any middle (interior) points of a line segment. If the line * segment only has a start and end point, this option has no effect. One of: * - * - a marker name such as *arrow* or *circle* + * - a marker name such as *arrow* or *circle* (but not *arrow-reverse*, + * which only differs from *arrow* when used as **markerStart**) * * *none* (default) - no marker * * true - alias for *circle-fill* * * false or null - alias for *none* @@ -75,12 +76,13 @@ export interface MarkerOptions { * *context* including the current document; they must return an SVG marker * element. */ - markerMid?: Marker | "none" | boolean | null; + markerMid?: Exclude | "none" | boolean | null; /** * The marker for the ending point of a line segment; one of: * - * - a marker name such as *arrow* or *circle* + * - a marker name such as *arrow* or *circle* (but not *arrow-reverse*, + * which only differs from *arrow* when used as **markerStart**) * * *none* (default) - no marker * * true - alias for *circle-fill* * * false or null - alias for *none* @@ -90,5 +92,5 @@ export interface MarkerOptions { * *context* including the current document; they must return an SVG marker * element. */ - markerEnd?: Marker | "none" | boolean | null; + markerEnd?: Exclude | "none" | boolean | null; } diff --git a/test/marker.test-d.ts b/test/marker.test-d.ts new file mode 100644 index 0000000000..6f4cba3aa4 --- /dev/null +++ b/test/marker.test-d.ts @@ -0,0 +1,19 @@ +/* eslint-disable @typescript-eslint/ban-ts-comment */ + +import {it} from "vitest"; +import * as Plot from "@observablehq/plot"; + +it("arrow-reverse is a valid marker and markerStart", () => { + Plot.link([], {marker: "arrow-reverse"}); + Plot.link([], {markerStart: "arrow-reverse"}); + Plot.line([], {marker: "arrow-reverse", markerEnd: "arrow"}); +}); + +it("arrow-reverse is not a valid markerMid or markerEnd", () => { + // @ts-expect-error + Plot.link([], {markerMid: "arrow-reverse"}); + // @ts-expect-error + Plot.link([], {markerEnd: "arrow-reverse"}); + // @ts-expect-error + Plot.line([], {markerEnd: "arrow-reverse"}); +});