chore: Add in the documentation for the withWrapperData

This commit is contained in:
BluJ
2023-05-02 16:31:55 -06:00
parent bda5fc59a2
commit 13b0933f96
4 changed files with 59 additions and 0 deletions

View File

@@ -114,6 +114,20 @@ export class Config<Type extends Record<string, any>, 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<WrapperData>()({
myValue: a.withWrapperData(),
})
```
*/
withWrapperData<NewWrapperData extends WD>() {
return this as any as Config<Type, NewWrapperData>
}

View File

@@ -250,4 +250,22 @@ export class List<Type, WD> {
}
}, 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<WrapperData>()({
myValue: a.withWrapperData(),
})
```
*/
withWrapperData<NewWrapperData extends WD>() {
return this as any as List<Type, NewWrapperData>
}
}

View File

@@ -672,6 +672,20 @@ export class Value<Type, 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<WrapperData>()({
myValue: a.withWrapperData(),
})
```
*/
withWrapperData<NewWrapperData extends WD>() {
return this as any as Value<Type, NewWrapperData>
}

View File

@@ -103,7 +103,20 @@ export class Variants<Type, WD> {
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<WrapperData>()({
myValue: a.withWrapperData(),
})
```
*/
withWrapperData<NewWrapperData extends WD>() {
return this as any as Variants<Type, NewWrapperData>
}