writes whether `k` is a declared key
(js: NodeCompiler)
| 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 { |