mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-30 20:24:47 +00:00
chore: Make the expanded types extended, so that way we know we are outputing the correct type.
This commit is contained in:
@@ -1,17 +1,18 @@
|
||||
import { ConfigSpec, ValueSpecAny } from "../types.ts";
|
||||
import { BuilderExtract, IBuilder } from "./builder.ts";
|
||||
import { Value } from "./value.ts";
|
||||
|
||||
export class Config<A> extends IBuilder<A> {
|
||||
export class Config<A extends ConfigSpec> extends IBuilder<A> {
|
||||
static empty() {
|
||||
return new Config({});
|
||||
}
|
||||
static withValue<K extends string, B>(key: K, value: Value<B>) {
|
||||
static withValue<K extends string, B extends ValueSpecAny>(key: K, value: Value<B>) {
|
||||
return new Config({
|
||||
[key]: value.build(),
|
||||
} as { [key in K]: B });
|
||||
}
|
||||
|
||||
static of<B extends { [key: string]: Value<unknown> }>(spec: B) {
|
||||
static of<B extends { [key: string]: Value<C> }, C extends ValueSpecAny>(spec: B) {
|
||||
// deno-lint-ignore no-explicit-any
|
||||
const answer: { [K in keyof B]: BuilderExtract<B[K]> } = {} as any;
|
||||
for (const key in spec) {
|
||||
@@ -20,7 +21,7 @@ export class Config<A> extends IBuilder<A> {
|
||||
}
|
||||
return new Config(answer);
|
||||
}
|
||||
addValue<K extends string, B>(key: K, value: Value<B>) {
|
||||
addValue<K extends string, B extends ValueSpecAny>(key: K, value: Value<B>) {
|
||||
return new Config({
|
||||
...this.a,
|
||||
[key]: value.build(),
|
||||
|
||||
Reference in New Issue
Block a user