MCPcopy Create free account
hub / github.com/arktypeio/arktype / _jsDeclaresKey

Method _jsDeclaresKey

ark/schema/structure/structure.ts:1035–1051  ·  view source on GitHub ↗

writes whether `k` is a declared key

(js: NodeCompiler)

Source from the content-addressed store, hash-verified

1033
1034 /** writes whether `k` is a declared key */
1035 _jsDeclaresKey(js: NodeCompiler): string {
1036 const parts: string[] = []
1037 if (this.index) {
1038 for (const index of this.index)
1039 parts.push(js.allows(index.signature, "k"))
1040 }
1041
1042 if (this.sequence) {
1043 parts.push(
1044 `typeof k === "string" && ${js.ref(arrayIndexMatcher)}.test(k) && +k < ${maxArrayLength}`
1045 )
1046 }
1047
1048 // if parts is empty, this is a structure like { "+": "reject" }
1049 // that declares no keys other than its props, so return false
1050 return parts.join(" || ") || "false"
1051 }
1052
1053 // copied by slice: declares only indices and no cycle runs through it
1054 get slicesSeq(): boolean {

Callers 3

deletesMethod · 0.95
jsDeleteTransformMethod · 0.95
jsEntryMethod · 0.95

Calls 3

allowsMethod · 0.80
pushMethod · 0.45
refMethod · 0.45

Tested by

no test coverage detected