ref: use Registry instead of TypeSystem#977
Conversation
| ) => TUnsafe<File> | ||
|
|
||
| const File: ElysiaFile = | ||
| (TypeRegistry.Get('Files') as unknown as ElysiaFile) ?? |
There was a problem hiding this comment.
Here was "Files" instead of "File"
There was a problem hiding this comment.
Furthermore, TypeRegistry.Get('...') didn't work as expected because it returns the validation function instead of the schema-function with options, which means it breaks if someone overwrites it nowadays or when type-system.ts gets executed twice.
| schema.enum.includes(value as never) | ||
| ) | ||
| }) | ||
| if (!TypeRegistry.Has('UnionEnum')) |
There was a problem hiding this comment.
Here was no "Has"-check.. In case a user wanna override it
|
|
||
| t.UnionEnum = ElysiaType.UnionEnum | ||
|
|
||
| function getOrSetType<TSchema = unknown, TReturn = unknown>( |
There was a problem hiding this comment.
This function implementation is based on sinclare docs and TypeSystem.Type.
It's not recommendet anymore to use TypeSystem and instead switch to TypeRegistry and FormatRegistry.
This approach doesn't throw any TypeSystemDuplicateTypeKind-Error.
| TypeSystemDuplicateFormat, | ||
| TypeSystemDuplicateTypeKind | ||
| } from '@sinclair/typebox/system' | ||
| export { TypeRegistry, FormatRegistry } from '@sinclair/typebox' |
There was a problem hiding this comment.
Added registry exports to simplify providing additional type/format logic without bun add @sinclair/typebox@<exact-elysia-version>.
Maybe we could export this getOrSetType in the future as well or we wait until typebox comes up with something similar..

Fixes #914