chore: Update and fix config type test

This commit is contained in:
BluJ
2023-04-03 13:41:25 -06:00
parent 2d835e0a9f
commit 82e96eb18e
4 changed files with 30 additions and 5 deletions

View File

@@ -0,0 +1,25 @@
import {
ListValueSpecOf,
ValueSpecList,
isValueSpecListOf,
} from "../config-types";
import { Config } from "./config";
import { List } from "./list";
import { Value } from "./value";
describe("Config Types", () => {
test("isValueSpecListOf", () => {
const options = [List.obj, List.string, List.number];
for (const option of options) {
const test = option({} as any, { spec: Config.of({}) } as any) as any;
const someList = Value.list(test).build();
if (isValueSpecListOf(someList, "string")) {
someList.spec satisfies ListValueSpecOf<"string">;
} else if (isValueSpecListOf(someList, "number")) {
someList.spec satisfies ListValueSpecOf<"number">;
} else if (isValueSpecListOf(someList, "object")) {
someList.spec satisfies ListValueSpecOf<"object">;
}
}
});
});

View File

@@ -129,9 +129,9 @@ export interface ValueSpecListOf<T extends ListValueSpecType>
// sometimes the type checker needs just a little bit of help
export function isValueSpecListOf<S extends ListValueSpecType>(
t: ValueSpecList,
t: ValueSpecListOf<ListValueSpecType>,
s: S
): t is ValueSpecListOf<S> {
): t is ValueSpecListOf<S> & { spec: ListValueSpecOf<S> } {
return t.spec.type === s;
}

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "start-sdk",
"version": "0.4.0-lib0.beta8",
"version": "0.4.0-lib0.beta9",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "start-sdk",
"version": "0.4.0-lib0.beta8",
"version": "0.4.0-lib0.beta9",
"license": "MIT",
"dependencies": {
"@iarna/toml": "^2.2.5",

View File

@@ -1,6 +1,6 @@
{
"name": "start-sdk",
"version": "0.4.0-lib0.beta8",
"version": "0.4.0-lib0.beta9",
"description": "For making the patterns that are wanted in making services for the startOS.",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",