Skip to content

[BUG] typescript-defined prop with string literal union type gets mistranslated in proptypes.js #3639

@bernardelli

Description

@bernardelli

Context

I am developing a custom components library using dash 3.4.0.

This library uses typescript to define component properties. One of those properties is defined as a literal union:

example_literal_prop: "this" | "that" | "another option"

This gets translated nicely into the python component:

[...]
example_literal_prop: typing.Optional[Literal["this", "that", "another option"]] = None,
[...]

But, in prototypes.js, it gets wrapped around simple quotes:

{
[...]
 example_literal_prop:pt.oneOf(["'this'", "'that'", "'another option'"]),
[...]
}

Bug description

When running a dash app that uses my component with the prop example_literal_prop="this" in debug mode, I get the following error:

Invalid argument `example_literal_prop` passed into Component with ID "example".
Expected one of ["'this'","'that'","'another option'"].
Value provided: "this"

If I use example_literal_prop="'this'", the error goes away, but that's not the value I want the prop to have.

Expected behavior

It's expected that "this" should be a valid value for example_literal_prop.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions