Skip to content

How to use multiple types in record value? #837

Answered by sinclairzx81
dhruv-nudge asked this question in Q&A
Discussion options

You must be logged in to vote

@dhruv-nudge Hiya, try the following

TypeScript Link Here

import { Type, Static } from '@sinclair/typebox'

const T = Type.Record(Type.String(), Type.Union([
    Type.Number(),
    Type.String(),
    Type.Boolean(),
    Type.Date()
]))

type T = Static<typeof T>

// type T = {
//    [x: string]: string | number | boolean | Date;
// }

Hope this helps
S

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Dhruv-Garg79
Comment options

Answer selected by dhruv-nudge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants