Files
Homarr/packages/definitions/src/_definition.ts
Thomas Camlong f1b1ec59ec chore: update prettier configuration for print width (#519)
* feat: update prettier configuration for print width

* chore: apply code formatting to entire repository

* fix: remove build files

* fix: format issue

---------

Co-authored-by: Meier Lukas <meierschlumpf@gmail.com>
2024-05-19 22:38:39 +02:00

18 lines
418 B
TypeScript

export const createDefinition = <const TKeys extends string[], TOptions extends { defaultValue: TKeys[number] } | void>(
values: TKeys,
options: TOptions,
) => ({
values,
defaultValue: options?.defaultValue as TOptions extends {
defaultValue: infer T;
}
? T
: undefined,
});
export type inferDefinitionType<TDefinition> = TDefinition extends {
values: readonly (infer T)[];
}
? T
: never;