Skip to content

Value dependant types #270

Discussion options

You must be logged in to vote

I've also tried something like this, which don't work:

const ImportSchema = Type.Object({
	type: Type.Literal('import'),
	definition: Type.Object({
		importIds: Type.Array(Type.Integer())
	})
})

const UserSchema = Type.Object({
	type: Type.Literal('import'),
	definition: Type.Object({
		userIds: Type.Array(Type.Integer())
	})
})

export const ConfigSchema = Type.Intersect([
	Type.Object({
		campaignId: Type.Number(),
	}),
	Type.Union([ImportSchema, UserSchema])
])

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@chrjohannesen
Comment options

@chrjohannesen
Comment options

@sinclairzx81
Comment options

@chrjohannesen
Comment options

@chrjohannesen
Comment options

Answer selected by chrjohannesen
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