dividab/graphql-norm

Support object in NormalizedObject mapped type

jonaskello opened this issue · 0 comments

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