Skip to content

Override Typebox object properties in schema composiiton/merge #268

Answered by sinclairzx81
lucashfreitas asked this question in Q&A
Discussion options

You must be logged in to vote

@lucashfreitas Hi!

TypeBox types/schemas are considered immutable from a library standpoint. TypeBox doesn't prevent users from mutating schemas...but doing so may invalidate the TS type associated with that schema (so it would be generally discouraged)

Composition in TypeBox is however supported; but limited to composition types provided by the library such as Type.Intersect([A, B]), Type.KeyOf(A), Type.Partial(A), etc. I'm not very familiar with json-merger but taking a look at it's readme, it doesn't seem like it would be immediately compatible. To merge objects in TypeBox, you would use similar type construction patterns used to compose types in TypeScript. For example.

// typescript …

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
3 replies
@lucashfreitas
Comment options

@sinclairzx81
Comment options

@lucashfreitas
Comment options

Answer selected by lucashfreitas
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@lucashfreitas
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants