Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Primitive unions are not supported #290

Open
evantrimboli opened this issue Sep 8, 2022 · 0 comments
Open

Primitive unions are not supported #290

evantrimboli opened this issue Sep 8, 2022 · 0 comments
Labels

Comments

@evantrimboli
Copy link

evantrimboli commented Sep 8, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant