Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Does not support select knobs on TypeScript string unions  #72

@dantman

Description

@dantman

I'm using smart-knobs with TypeScript components using react-docgen-typescript-loader.

However I do not get any knobs on a component that just uses string union props like these. String props are fine so this is specific to the type handling.

export interface StatusIndicatorProps {
  status: 'completed' | 'incomplete' | 'overdue';
}

const StatusIndicator: FC<StatusIndicatorProps> = props => {
  // ...
}

The resulting __docgenInfo output by react-docgen-typescript-loader contains the following props:

props: {
  status: {
    defaultValue: null,
    description: "",
    name: "status",
    required: true,
    type: {name: '"completed" | "incomplete" | "overdue"'}
  }
}

It would be nice if smart-props could support the string union types for at least simple unions that can properly be represented as a select or radio (e.g. a union of primitives like numbers, strings, undefined/null, and/or booleans).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions