Skip to content

[BUG]: Type definition uses regex as string literal type #8003

Closed

Description

@jendrikw

Description

The new type definitions sometimes contain string literals of regexes as types. This does not work as expected.

Steps to reproduce

https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBDAnmApnA3gGQIaIgVxgEEAPYAZwBo4iA7WiGbGYCWgXzgDMoIQ4ARGAA2jYYgB0AK3ICA3ACgFAExQBjYdiho1bcvGxlyALjg48hUhUWGKE8muzCU2WmoAW0OAF5BJeUqqGlo6egb0jMystKZ0DEwsbDYRCdEShtpcPn4ATAFAA

Notes

At least these types are affected (generated with grep -RF "'/^" plotly.js/):

plotly.js/src/types/generated/schema.d.ts:    anchor?: 'free' | '/^x([2-9]|[1-9][0-9]+)?( domain)?$/' | '/^y([2-9]|[1-9][0-9]+)?( domain)?$/';
plotly.js/src/types/generated/schema.d.ts:    matches?: '/^x([2-9]|[1-9][0-9]+)?( domain)?$/' | '/^y([2-9]|[1-9][0-9]+)?( domain)?$/';
plotly.js/src/types/generated/schema.d.ts:    overlaying?: 'free' | '/^x([2-9]|[1-9][0-9]+)?( domain)?$/' | '/^y([2-9]|[1-9][0-9]+)?( domain)?$/';
plotly.js/src/types/generated/schema.d.ts:    scaleanchor?: '/^x([2-9]|[1-9][0-9]+)?( domain)?$/' | '/^y([2-9]|[1-9][0-9]+)?( domain)?$/' | false;
plotly.js/src/types/generated/schema.d.ts:    axref?: 'pixel' | '/^x([2-9]|[1-9][0-9]+)?( domain)?$/';
plotly.js/src/types/generated/schema.d.ts:    ayref?: 'pixel' | '/^y([2-9]|[1-9][0-9]+)?( domain)?$/';
plotly.js/src/types/generated/schema.d.ts:    xref?: 'paper' | '/^x([2-9]|[1-9][0-9]+)?( domain)?$/';
plotly.js/src/types/generated/schema.d.ts:    yref?: 'paper' | '/^y([2-9]|[1-9][0-9]+)?( domain)?$/';
plotly.js/src/types/generated/schema.d.ts:    xref?: 'paper' | '/^x([2-9]|[1-9][0-9]+)?( domain)?$/';
plotly.js/src/types/generated/schema.d.ts:    yref?: 'paper' | '/^y([2-9]|[1-9][0-9]+)?( domain)?$/';
plotly.js/src/types/generated/schema.d.ts:    xref?: 'paper' | '/^x([2-9]|[1-9][0-9]+)?( domain)?$/';
plotly.js/src/types/generated/schema.d.ts:    yref?: 'paper' | '/^y([2-9]|[1-9][0-9]+)?( domain)?$/';
plotly.js/src/types/generated/schema.d.ts:    xref?: 'paper' | '/^x([2-9]|[1-9][0-9]+)?( domain)?$/' | ('paper' | '/^x([2-9]|[1-9][0-9]+)?( domain)?$/')[];
plotly.js/src/types/generated/schema.d.ts:    yref?: 'paper' | '/^y([2-9]|[1-9][0-9]+)?( domain)?$/' | ('paper' | '/^y([2-9]|[1-9][0-9]+)?( domain)?$/')[];

Some of these can be represented with template literal types: 'paper' | `x${number | ""}${" domain" | ""}`

Activity

  1. robertclaus commented on Sep 1, 2026

    @robertclaus

    Thanks for reporting this. A lot of the types are autogenerated, so likely an issue we can fix up in that code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2considered for next cyclebugsomething brokensize: 1

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions