Skip to content

Struggling to define a simple recursive type #1137

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

You must be logged in to vote

Here's one potential workaround you can use to tell ArkType not to recurse into your JSON array type, although it could interface with e.g. extracting morphs out of some other types because of how broad Value[] is.

type Value = boolean | number | string | { [k: string]: Value } | Value[]

declare global {
	interface ArkEnv {
		prototypes(): Value[]
	}
}

If you were to also brand Value like Value[] & {[mySymbol]: "jsonArray"}, I think that would be safe.

Replies: 1 comment 13 replies

Comment options

You must be logged in to vote
13 replies
@ssalbdivad
Comment options

Answer selected by agladysh
@agladysh
Comment options

@ssalbdivad
Comment options

@ssalbdivad
Comment options

@agladysh
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