chore: Use the types from the fronted system

This commit is contained in:
BluJ
2023-02-13 16:58:04 -07:00
parent 2989347a55
commit 1c4a14d631
13 changed files with 252 additions and 273 deletions

View File

@@ -1,4 +1,4 @@
import { ConfigSpec, ValueSpecAny } from "../types.ts";
import { ConfigSpec, ValueSpec } from "../types/config-types.ts";
import { BuilderExtract, IBuilder } from "./builder.ts";
import { Value } from "./value.ts";
@@ -6,13 +6,13 @@ export class Config<A extends ConfigSpec> extends IBuilder<A> {
static empty() {
return new Config({});
}
static withValue<K extends string, B extends ValueSpecAny>(key: K, value: Value<B>) {
static withValue<K extends string, B extends ValueSpec>(key: K, value: Value<B>) {
return new Config({
[key]: value.build(),
} as { [key in K]: B });
}
static of<B extends { [key: string]: Value<C> }, C extends ValueSpecAny>(spec: B) {
static of<B extends { [key: string]: Value<C> }, C extends ValueSpec>(spec: B) {
// deno-lint-ignore no-explicit-any
const answer: { [K in keyof B]: BuilderExtract<B[K]> } = {} as any;
for (const key in spec) {
@@ -21,13 +21,13 @@ export class Config<A extends ConfigSpec> extends IBuilder<A> {
}
return new Config(answer);
}
withValue<K extends string, B extends ValueSpecAny>(key: K, value: Value<B>) {
withValue<K extends string, B extends ValueSpec>(key: K, value: Value<B>) {
return new Config({
...this.a,
[key]: value.build(),
} as A & { [key in K]: B });
}
addValue<K extends string, B extends ValueSpecAny>(key: K, value: Value<B>) {
addValue<K extends string, B extends ValueSpec>(key: K, value: Value<B>) {
return new Config({
...this.a,
[key]: value.build(),