chore: fix the values.

This commit is contained in:
BluJ
2023-03-27 13:16:54 -06:00
parent 281b752967
commit 56c775e9a4

View File

@@ -14,9 +14,9 @@ import {
export type DefaultString = export type DefaultString =
| string | string
| { | {
charset: string | null | undefined; charset: string | null | undefined;
len: number; len: number;
}; };
export type Description = { export type Description = {
name: string; name: string;
description: string | null; description: string | null;
@@ -78,9 +78,9 @@ export class Value<A extends ValueSpec> extends IBuilder<A> {
} }
static string< static string<
A extends Description & A extends Description &
NullableDefault<DefaultString> & NullableDefault<DefaultString> &
Nullable & Nullable &
StringSpec StringSpec
>(a: A) { >(a: A) {
return new Value({ return new Value({
type: "string" as const, type: "string" as const,
@@ -97,10 +97,9 @@ export class Value<A extends ValueSpec> extends IBuilder<A> {
} }
static select< static select<
A extends Description & A extends Description &
Default<string> & { Default<string> & {
values: readonly string[] | string[]; values: Record<string, string>;
valueNames: Record<string, string>; }
}
>(a: A) { >(a: A) {
return new Value({ return new Value({
type: "select" as const, type: "select" as const,
@@ -129,21 +128,14 @@ export class Value<A extends ValueSpec> extends IBuilder<A> {
} }
static union< static union<
A extends Description & A extends Description &
Default<string> & { Default<string> & {
tag: { name: string;
id: B; description: string | null;
name: string; warning: string | null;
description: string | null; variants: Variants<{ [key: string]: { name: string, spec: InputSpec } }>;
warning: string | null; displayAs: string | null;
variantNames: { uniqueBy: UniqueBy;
[key: string]: string; }
};
};
variants: Variants<{ [key: string]: InputSpec }>;
displayAs: string | null;
uniqueBy: UniqueBy;
},
B extends string
>(a: A) { >(a: A) {
const { variants: previousVariants, ...rest } = a; const { variants: previousVariants, ...rest } = a;
const variants = previousVariants.build() as BuilderExtract<A["variants"]>; const variants = previousVariants.build() as BuilderExtract<A["variants"]>;