Skip to content

Commit

Permalink
fix: Metadata types for protection from missing fields & generation
Browse files Browse the repository at this point in the history
  • Loading branch information
cmath10 committed Nov 11, 2024
1 parent 9b39862 commit c6541f3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion meta/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,17 @@ export const schemaListDocumentation: SchemaListDocumentation<SchemaList> = {
},
}

type UnionToArray<T, U = T> = [T] extends [never]
? []
: T extends T
? [T, ...UnionToArray<Exclude<U, T>>]
: []

export type TargetListDocumentation = {
[Target in keyof SchemaListByTarget]: {
description: TranslationList;
location: TranslationList;
contexts: Array<keyof SchemaListByTarget[Target]>;
contexts: UnionToArray<keyof SchemaListByTarget[Target]>;
}
}

Expand All @@ -153,6 +159,7 @@ export const targetListDocumentation: TargetListDocumentation = {
},
contexts: [
'customer/card',
'customer/card.phone',
'settings',
],
},
Expand Down

0 comments on commit c6541f3

Please sign in to comment.