This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type MappedParameterTypes<T extends Parameter[]> = { | |
// Check if the parameter has an 'enum' defined | |
[P in T[number] as P["name"]]: P extends { enum: Array<infer E> } | |
? E extends string // Ensure the enum values are strings | |
? P["required"] extends false // Check if the parameter is optional | |
? E | undefined // If so, include 'undefined' in the type | |
: E // Otherwise, use the enum type directly | |
: never // This case should not occur since 'enum' implies string values | |
: // Handle parameters defined as 'object' with specified attributes | |
P extends { type: "object"; attributes: infer Attributes } |