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

No runtime type checking with TypeScript components #3014

Open
AnnMarieW opened this issue Sep 23, 2024 · 0 comments
Open

No runtime type checking with TypeScript components #3014

AnnMarieW opened this issue Sep 23, 2024 · 0 comments
Assignees
Labels
bug something broken P3 not needed for current cycle

Comments

@AnnMarieW
Copy link
Collaborator

While working with the dash-mantine-components library, I noticed that no helpful error messages are provided in the browser DevTools when an invalid prop is passed to a dmc component -- unlike with other Dash libraries like dash-core-components.

The issue arises because dmc components are built using TypeScript. They do not use propTypes which is how the runtime type checking is done in Dash. TypeScript is not available at runtime.

Here is an example:

import dash_mantine_components as dmc
from dash import Dash, dcc,_dash_renderer
_dash_renderer._set_react_version("18.2.0")

app = Dash()

app.layout = dmc.MantineProvider([
    dmc.RangeSlider(min="b"),
    dcc.RangeSlider(min="b")
])

if __name__ == "__main__":
    app.run(debug=True)

The first very helpful error message is for the dcc component (which does not use TypeScript), the second is the dmc component:

image

After discussing with the Plotly team, a solution could be to create a script that automatically adds propTypes to TypeScript components when running with debug=True. This script could use information from the metadata.json file, which already has details about the props and their types.

@gvwilson gvwilson changed the title [BUG] No runtime type checking with TypeScript components No runtime type checking with TypeScript components Sep 27, 2024
@gvwilson gvwilson added bug something broken P3 not needed for current cycle labels Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken P3 not needed for current cycle
Projects
None yet
Development

No branches or pull requests

3 participants