Skip to content

fix #2156 arrow-reverse marker types - #2480

Open
Enesuygurs wants to merge 1 commit into
observablehq:mainfrom
Enesuygurs:fix/marker-arrow-reverse-types
Open

Enesuygurs wants to merge 1 commit into
observablehq:mainfrom
Enesuygurs:fix/marker-arrow-reverse-types

Conversation

@Enesuygurs

Copy link
Copy Markdown

Fixes #2156

The arrow-reverse marker uses orient="auto-start-reverse", which only flips the arrowhead when it is placed at the start of a path. As a mid or end marker it draws exactly the same thing as arrow, so markerEnd: "arrow-reverse" looks like it has no effect, yet the TypeScript types accept it for markerMid and markerEnd.

As suggested in the issue (and agreed in the comments), this excludes "arrow-reverse" from the markerMid and markerEnd types and mentions it in their doc comments. marker and markerStart still accept it, so marker: "arrow-reverse" keeps working for drawing <---> with a single option. This is a types-only change; runtime behavior is unchanged.

I added test/marker.test-d.ts with type tests that check arrow-reverse is still accepted for marker and markerStart and rejected for markerMid and markerEnd. The test fails on main and passes with this change. pnpm run lint, pnpm run tsc and prettier are clean.

This branch has not been deployed

No deployments
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.

invalid markerEnd option for link/arrow

1 participant