Skip to content

Primitive unions are not supported #290

@evantrimboli

Description

@evantrimboli

Describe the bug
When using a union of string, number or boolean values, the types ultimately resolve back to the base type.

To Reproduce
Steps to reproduce the behavior:

type OperatingState = 'good' | 'bad' | 'alright';
interface Thing {
  readonly state: OperatingState
}

// FormControlState<string>, should be FormControlState<OperatingState>
type Bad = FormGroupState<Thing>['controls']['state'];

[If possible, please also provide a reproduction repository or fork this code sandbox and reproduce the issue there.]

Expected behavior
The union type should be retained.

Screenshots
[If applicable, add screenshots to help explain your problem.]

Library version:
7.0.0

Additional context
It seems like we could take advantage of some of the newer TS features in 4.7+ to achieve this:

type InferredStringFormState<T extends InferenceWrapper<any>> =
  T extends InferenceWrapper<infer U extends string | null | undefined> ? FormControlState<U>
  : never;

The same treatment could be applied to number and boolean.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions