From 13b0933f9684834616914c3ca1fefad7337ee85c Mon Sep 17 00:00:00 2001 From: BluJ Date: Tue, 2 May 2023 16:31:55 -0600 Subject: [PATCH] chore: Add in the documentation for the withWrapperData --- lib/config/builder/config.ts | 14 ++++++++++++++ lib/config/builder/list.ts | 18 ++++++++++++++++++ lib/config/builder/value.ts | 14 ++++++++++++++ lib/config/builder/variants.ts | 13 +++++++++++++ 4 files changed, 59 insertions(+) diff --git a/lib/config/builder/config.ts b/lib/config/builder/config.ts index 51bb612..d709e84 100644 --- a/lib/config/builder/config.ts +++ b/lib/config/builder/config.ts @@ -114,6 +114,20 @@ export class Config, WD> { }, } } + /** + * Use this during the times that the input needs a more specific type. + * Used in types that the value/ variant/ list/ config is constructed somewhere else. + ```ts + const a = Config.text({ + name: "a", + required: false, + }) + + return topConfig()({ + myValue: a.withWrapperData(), + }) + ``` + */ withWrapperData() { return this as any as Config } diff --git a/lib/config/builder/list.ts b/lib/config/builder/list.ts index e0c3cfa..3b20e61 100644 --- a/lib/config/builder/list.ts +++ b/lib/config/builder/list.ts @@ -250,4 +250,22 @@ export class List { } }, arrayOf(aSpec.spec.validator)) } + + /** + * Use this during the times that the input needs a more specific type. + * Used in types that the value/ variant/ list/ config is constructed somewhere else. + ```ts + const a = Config.text({ + name: "a", + required: false, + }) + + return topConfig()({ + myValue: a.withWrapperData(), + }) + ``` + */ + withWrapperData() { + return this as any as List + } } diff --git a/lib/config/builder/value.ts b/lib/config/builder/value.ts index 4ebb4f9..06ca397 100644 --- a/lib/config/builder/value.ts +++ b/lib/config/builder/value.ts @@ -672,6 +672,20 @@ export class Value { ) } + /** + * Use this during the times that the input needs a more specific type. + * Used in types that the value/ variant/ list/ config is constructed somewhere else. + ```ts + const a = Config.text({ + name: "a", + required: false, + }) + + return topConfig()({ + myValue: a.withWrapperData(), + }) + ``` + */ withWrapperData() { return this as any as Value } diff --git a/lib/config/builder/variants.ts b/lib/config/builder/variants.ts index f0641aa..5b625eb 100644 --- a/lib/config/builder/variants.ts +++ b/lib/config/builder/variants.ts @@ -103,7 +103,20 @@ export class Variants { return variants }, validator) } + /** + * Use this during the times that the input needs a more specific type. + * Used in types that the value/ variant/ list/ config is constructed somewhere else. + ```ts + const a = Config.text({ + name: "a", + required: false, + }) + return topConfig()({ + myValue: a.withWrapperData(), + }) + ``` + */ withWrapperData() { return this as any as Variants }