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

Support object in NormalizedObject mapped type #55

Closed
jonaskello opened this issue Jan 7, 2020 · 0 comments · Fixed by #56
Closed

Support object in NormalizedObject mapped type #55

jonaskello opened this issue Jan 7, 2020 · 0 comments · Fixed by #56

Comments

@jonaskello
Copy link
Member

jonaskello commented Jan 7, 2020

This mapped type converts a the type of a denrmalized object to the corresponding type for its normalized form. It does that by replacing arrays of objects with array of string. However it also needs to support object without array. It needs to be added here.

The result should be like this:

export type NormalizedField<T> = T extends string
  ? string
  : T extends number
  ? number
  : T extends boolean
  ? boolean
  : T extends {}
  ? string
  : T extends ReadonlyArray<string>
  ? ReadonlyArray<string>
  : T extends ReadonlyArray<boolean>
  ? ReadonlyArray<boolean>
  : T extends ReadonlyArray<number>
  ? ReadonlyArray<number>
  : T extends ReadonlyArray<object>
  ? ReadonlyArray<NormKey>
  : "undefined value";

The new part is:

 : T extends {}
  ? string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant