GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(types): Accept attribute paths in plotly_relayout, relayout, restyle, and update by camdecoster · Pull Request #8126 · plotly/plotly.js

Conversation

@camdecoster

@camdecoster camdecoster commented Oct 15, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
camdecoster added 3 commits October 15, 2026 17:08
@camdecoster
fix(types): Accept attribute paths in plotly_relayout, relayout, rest…
16be55c
…yle, and update
@camdecoster
Add type tests locally, in CI
ecb5486
@camdecoster
Add draftlog
166aa66
@camdecoster
camdecoster marked this pull request as ready for review October 15, 2026 23:39
KoolADE85
KoolADE85 reviewed Oct 16, 2026
View reviewed changes
Comment thread .github/workflows/ci.yml
- name: Type-check TypeScript sources
run: npm run typecheck

test-types:

@KoolADE85 KoolADE85 Oct 16, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could we just add test-types as a second step in the typecheck job above? Is there a reason you want a second runner?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@camdecoster camdecoster Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to make it obvious what the failure is.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

KoolADE85 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread test/types/update_api.ts Outdated
/**
* Consumer-side checks for the `relayout`, `restyle` and `update` types.
*
* Nothing here runs. `npm run typecheck` compiles this file against the public entry point.

@KoolADE85 KoolADE85 Oct 16, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
* Nothing here runs. `npm run typecheck` compiles this file against the public entry point.
* Nothing here runs. `npm run test-types` compiles this file against the public entry point.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@camdecoster camdecoster Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. I missed this during a name change.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/types/core/events.d.ts Outdated
* autorange keys that flatten nested updates.
*/
export interface PlotRelayoutEvent extends Partial<Layout> {
export interface PlotRelayoutEvent extends LayoutUpdate {

@KoolADE85 KoolADE85 Oct 16, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type contains 6 hand-crafted keys (xaxis.range[0], etc.) but LayoutUpdate doesn't type these keys at all.
This starts to look like 2 sources of truth for these types. And already, the two definitions are drifting:
the hand-crafted keys here define values that are narrower than in LayoutUpdate. xaxis.range[0]?: number misses date axes with values like 2026-10-16.

What do you think about moving the hand-typed keys here into LayoutUpdate with the type widened to include date strings? That way there would be a single definition.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@camdecoster camdecoster Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These actually should have been deleted. LayoutUpdate should handle any of the attribute paths, so we don't need to specify individual ones here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/types/core/api.d.ts

@KoolADE85 KoolADE85 Oct 16, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The overloads you add here are good, but can still report "errors" on perfectly valid code.

Example:

import * as Plotly from 'plotly.js';
type RelayoutArg = Parameters<typeof Plotly.relayout>[1];
const wrapped: RelayoutArg = { autosize: true };

There is a red squiggle as typescript evaluates against the "last" overload and completely misses the other valid overload.
Typescript says to put the most generic signature last. What do you think about including a generic "catch-all" overload at the end for these kinds of cases?

export function relayout(root: Root, astr: string | LayoutUpdate, val?: any): Promise<PlotlyHTMLElement>;

The same comment applies to the restyle overloads.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@camdecoster camdecoster Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@camdecoster camdecoster assigned KoolADE85 Oct 19, 2026
@camdecoster
Address PR feedback
b0f48b2
@camdecoster
camdecoster requested a review from KoolADE85 October 19, 2026 22:43
KoolADE85
KoolADE85 approved these changes Oct 19, 2026
View reviewed changes

@KoolADE85 KoolADE85 left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! 💃

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@camdecoster
camdecoster merged commit 8dc3846 into main Oct 19, 2026
86 of 88 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@camdecoster
camdecoster deleted the cam/8047/relayout-update-types branch October 19, 2026 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@KoolADE85 KoolADE85 KoolADE85 approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@KoolADE85 KoolADE85

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[BUG]: Typing issue in relayout()

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@camdecoster @KoolADE85
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.