Replies: 2 comments
-
@sleewoo Hi,
Hey, Thanks! :) It took many years!!
Unfortunately, I can't really change the name for const User = Type.Script(`{
name: string,
email: Options<string, { // Internally calls to Options(...) to augment the embedded
format: 'email', // type with auxiliary metadata, in this case a format.
minLength: 4
}>
}`) The Options function was an interesting case where Script needed to be able to apply metadata to types, but where I didn't want to invent new TypeScript syntax (as there are no facilities to apply metadata to types in the language). The name Options was selected as TypeBox used this term to describe any additional schema constraints applied to a type. An alternative name may have been Metadata, but figured I'd just go with library terminology, but both terms are valid. Perhaps you could rename |
Beta Was this translation helpful? Give feedback.
-
i'd rather define a global import type { TStringOptions, TNumberOptions, TArrayOptions } from "typebox";
declare global {
type TRefine<
T,
O extends T extends string
? TStringOptions
: T extends number
? TNumberOptions
: T extends unknown[]
? TArrayOptions
: unknown,
> = T;
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Congrats on v1 release!
The new refinement through
Options
is awesome, but... as usual there is a but :)I'm using
Options
name pretty frequently in my projects and now i have to either move schemas with refinements to separate files or toimport { Options as CoreOptions } from "@/core"
Both prertty incovenient, involves lot of moving.
Perhaps makes sense to add (unless already) a way to customize
Options
name?Perhaps a global option in
typebox/system
or per schema option somehow?Thanks
Beta Was this translation helpful? Give feedback.
All reactions