Skip to content

fix(types): Accept attribute paths in plotly_relayout, relayout, restyle, and update - #8126

Open
camdecoster wants to merge 3 commits into
mainfrom
cam/8047/relayout-update-types
Open

camdecoster wants to merge 3 commits into
mainfrom
cam/8047/relayout-update-types

Conversation

@camdecoster

@camdecoster camdecoster commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Description

Update types to accept attribute paths in plotly_relayout, relayout, restyle, and update.

Closes #8047.

Changes

  • Update types
  • Add type tests
  • Add test step in CI

Testing

  • Be on main
  • Save the following in the root project folder as test.ts:
import * as Plotly from './lib/index';

declare const gd: HTMLElement;

Plotly.relayout(gd, { 'xaxis.autorange': true });
Plotly.relayout(gd, 'xaxis.range[0]', 5);
Plotly.restyle(gd, { 'marker.color': 'red' });

// @ts-expect-error a typo must still fail
Plotly.relayout(gd, { titl: 'abc' });
  • Run the following command:
    npx tsc --noEmit --ignoreConfig --strict --module preserve --moduleResolution bundler --skipLibCheck test.ts
    
  • Note that there are errors (though these are valid calls)
  • Switch to this branch
  • Run the command again
  • Note that there are no errors
  • Check the CI results for test-types

Notes

  • The escape hatch of an attribute path string being any is a compromise so that we don't have to generate a list of any possible path string
  • The already accepted keys will still work

@camdecoster
camdecoster marked this pull request as ready for review October 15, 2026 23:39
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.

[BUG]: Typing issue in relayout()

1 participant