Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect type error when assigning string to automargin property in LayoutAxis #7331

Open
amrtgaber opened this issue Jan 10, 2025 · 0 comments
Labels
bug something broken P2 considered for next cycle

Comments

@amrtgaber
Copy link

amrtgaber commented Jan 10, 2025

I'm getting what I believe to be an incorrect type error. I'm using typescript and I needed to set the automargin for the xaxis to "bottom" to avoid an infinite automargin loop. When I did that I got a type error that string is not assignable to type "boolean | undefined".

Screenshot:
Image

However the automargin behaves as expected and the infinite automargin loop is gone so it's clear that the value can indeed be a string. I fixed it by augmenting the LayoutAxis and Layout type like so.

interface AugmentedLayoutAxis extends Omit<LayoutAxis, "automargin"> {
  automargin: string | boolean;
}

interface AugmentedLayout extends Omit<Layout, "xaxis"> {
  xaxis: Partial<AugmentedLayoutAxis>;
}

Screenshot:
Image

But then I also had to cast it in the component layout property

Screenshot:
Image

I believe the fix is to update the LayoutAxis type in @types/plotly.js here: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/plotly.js/index.d.ts#L937

Hope this helps.

@gvwilson gvwilson added bug something broken P2 considered for next cycle labels Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken P2 considered for next cycle
Projects
None yet
Development

No branches or pull requests

2 participants