Skip to content

export element props without [key: string]: any; #2836

@evollu

Description

@evollu

Feature Request

Problem description

We use typescript and HOC in our project. There are many cases where we wrap a semantic element and need to remove a property.
For example,

  • we have a HOC which wraps Dropdown component and passes option though redux. Then we need to remove option from props
  • we introduced a default property but the only clean way to define the typescript is using HOC to change a required prop to be optional

In both cases, we need to utilize Omit (reference) operation to remove a key from Semantic element's prop type definition. However each type definition from Semantic contains [key: string]: any; which makes Omit not working

Proposed solution

export a type definiton without [key: string]: any; for HOC to use.

MVP

Take button as example
Current code:

export interface ButtonProps {
  [key: string]: any;

  /** An element type to render as (string or function). */
  as?: any;

  /** A button can show it is currently the active user selection. */
  active?: boolean;
}

Proposal

export interface ButtonPropsStrict {
  /** An element type to render as (string or function). */
  as?: any;

  /** A button can show it is currently the active user selection. */
  active?: boolean;
}

export interface ButtonProps = ButtonPropsStrict & { [key: string]: any; }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions