Skip to content

ParseError: An unordered union of a type including a morph and a type with overlapping input is indeterminate #1094

Closed Answered by ssalbdivad
agladysh asked this question in Q&A
Discussion options

You must be logged in to vote

The problem is as the error states, we can't tell which morph we are supposed to execute from that union.

Instead, just handle the branching logic in your morph implementation:

const schema = scope({
	id: "string",
	argdef: [
		"Record<id, string | argdef_entry>",
		"=>",
		(entry, ctx): ArgDefSchema => {
			const keys = Object.keys(entry)
			if (keys.length !== 1) {
				ctx.error(
					`definition must have exactly one key, got "${keys.join(", ")}"`
				)
			}
			const id = keys.shift() as string
			const v = entry[id]

			return typeof v === "string" ?
					{
						id,
						default: v
					}
				:	{ id, ...v }
		}
	],
	argdef_entry: {
		"default?": "string"
	},
	value: {
		defs: "argde…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by agladysh
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