mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-26 02:11:56 +00:00
chore: Update and fix config type test
This commit is contained in:
25
lib/config/builder/config-types.test.ts
Normal file
25
lib/config/builder/config-types.test.ts
Normal 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">;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -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
4
package-lock.json
generated
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user