chore: Update the types to be required

This commit is contained in:
BluJ
2023-04-13 13:31:50 -06:00
parent 556b1b03f1
commit cff86718f8
8 changed files with 55 additions and 545 deletions

View File

@@ -1,41 +1,35 @@
import * as C from "./configTypesRaw";
export type ValueType = C.ValueType;
// prettier-ignore
export type WithOutOptionals<A> =
A extends Record<string | number, unknown> ? {[k in keyof A]: A[k]} :
A;
export type InputSpec = Record<string, WithOutOptionals<C.ValueSpec>>;
export type InputSpec = Record<string, Required<C.ValueSpec>>;
export type ValueSpec = WithOutOptionals<C.ValueSpec>;
export type ValueSpec = Required<C.ValueSpec>;
/** core spec types. These types provide the metadata for performing validations */
export type ValueSpecOf<T extends ValueType> = WithOutOptionals<
C.ValueSpecOf<T>
>;
export type ValueSpecOf<T extends ValueType> = Required<C.ValueSpecOf<T>>;
export type ValueSpecString = WithOutOptionals<C.ValueSpecString>;
export type ValueSpecTextarea = WithOutOptionals<C.ValueSpecTextarea>;
export type ValueSpecNumber = WithOutOptionals<C.ValueSpecNumber>;
export type ValueSpecSelect = WithOutOptionals<C.ValueSpecSelect>;
export type ValueSpecMultiselect = WithOutOptionals<C.ValueSpecMultiselect>;
export type ValueSpecBoolean = WithOutOptionals<C.ValueSpecBoolean>;
export type ValueSpecUnion = WithOutOptionals<C.ValueSpecUnion>;
export type ValueSpecFile = WithOutOptionals<C.ValueSpecFile>;
export type ValueSpecObject = WithOutOptionals<C.ValueSpecObject>;
export type WithStandalone = WithOutOptionals<C.WithStandalone>;
export type SelectBase = WithOutOptionals<C.SelectBase>;
export type ListValueSpecType = WithOutOptionals<C.ListValueSpecType>;
export type ValueSpecString = Required<C.ValueSpecString>;
export type ValueSpecTextarea = Required<C.ValueSpecTextarea>;
export type ValueSpecNumber = Required<C.ValueSpecNumber>;
export type ValueSpecSelect = Required<C.ValueSpecSelect>;
export type ValueSpecMultiselect = Required<C.ValueSpecMultiselect>;
export type ValueSpecBoolean = Required<C.ValueSpecBoolean>;
export type ValueSpecUnion = Required<C.ValueSpecUnion>;
export type ValueSpecFile = Required<C.ValueSpecFile>;
export type ValueSpecObject = Required<C.ValueSpecObject>;
export type WithStandalone = Required<C.WithStandalone>;
export type SelectBase = Required<C.SelectBase>;
export type ListValueSpecType = Required<C.ListValueSpecType>;
/** represents a spec for the values of a list */
export type ListValueSpecOf<T extends ListValueSpecType> = WithOutOptionals<
export type ListValueSpecOf<T extends ListValueSpecType> = Required<
C.ListValueSpecOf<T>
>;
/** represents a spec for a list */
export type ValueSpecList = WithOutOptionals<C.ValueSpecList>;
export type ValueSpecListOf<T extends ListValueSpecType> = WithOutOptionals<
export type ValueSpecList = Required<C.ValueSpecList>;
export type ValueSpecListOf<T extends ListValueSpecType> = Required<
C.ValueSpecListOf<T>
>;
@@ -46,11 +40,11 @@ export function isValueSpecListOf<S extends ListValueSpecType>(
): t is ValueSpecListOf<S> & { spec: ListValueSpecOf<S> } {
return t.spec.type === s;
}
export type ListValueSpecString = WithOutOptionals<C.ListValueSpecString>;
export type ListValueSpecNumber = WithOutOptionals<C.ListValueSpecNumber>;
export type ListValueSpecObject = WithOutOptionals<C.ListValueSpecObject>;
export type UniqueBy = WithOutOptionals<C.UniqueBy>;
export type DefaultString = WithOutOptionals<C.DefaultString>;
export type ListValueSpecString = Required<C.ListValueSpecString>;
export type ListValueSpecNumber = Required<C.ListValueSpecNumber>;
export type ListValueSpecObject = Required<C.ListValueSpecObject>;
export type UniqueBy = Required<C.UniqueBy>;
export type DefaultString = Required<C.DefaultString>;
export const unionSelectKey = "unionSelectKey" as const;
export type UnionSelectKey = typeof unionSelectKey;