Skip to content

Stricter types for select macro #2214

Open
@MikaelSiidorow

Description

@MikaelSiidorow

Problem Description

Select macro doesn't validate choices other than other currently.

Proposed Solution

Make the macro generic over value, and the choice keys required if the value is a union type.

Potential solution:

 declare function select<T extends string | number>(
    value: T,
    options: {
      [key in T]: string
    } & {
      other: string
    }
  ): string

Alternatives Considered

I can extend the types or patch the dependency locally, but it could make sense to contribute this change to benefit everyone

Additional Context

No response

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