( id: Node, module: SourceModule, isWritten: (value: unknown) => boolean )
| 8431 | } |
| 8432 | |
| 8433 | private writeInto( |
| 8434 | id: Node, |
| 8435 | module: SourceModule, |
| 8436 | isWritten: (value: unknown) => boolean |
| 8437 | ): [write: Node, value: Node, isDirect: boolean] | undefined { |
| 8438 | // reads since the last call, any of which may be arktype's |
| 8439 | const objects: Node[] = [id] |
| 8440 | for (let node = id; ; node = node.parent!) { |
| 8441 | const parent = node.parent! |
| 8442 | if (isTransparent(parent)) continue |
| 8443 | let write: Node | undefined |
| 8444 | if (parent.type === "MemberExpression" && parent.object === node) { |
| 8445 | if (isWriteTarget(parent)) write = writeOf(parent) |
| 8446 | } else if (parent.type === "CallExpression" && parent.callee === node) |
| 8447 | objects.length = 0 |
| 8448 | else if ( |
| 8449 | parent.type === "CallExpression" && |
| 8450 | parent.arguments[0] === node && |
| 8451 | isObjectWrite(parent.callee, module) |
| 8452 | ) |
| 8453 | write = parent |
| 8454 | else return |
| 8455 | if (write) { |
| 8456 | for (let i = objects.length - 1; i >= 0; i--) { |
| 8457 | const state = this.interpreter.evaluateSite( |
| 8458 | createSiteState(objects[i], module, { readsLiterals: true }) |
| 8459 | ) |
| 8460 | if (isWritten(state.value)) |
| 8461 | return [write, objects[i], i === objects.length - 1] |
| 8462 | } |
| 8463 | return |
| 8464 | } |
| 8465 | objects.push(parent) |
| 8466 | } |
| 8467 | } |
| 8468 | |
| 8469 | // e.g. `(await import("arktype")).type`, loading arktype/runtime with no |
| 8470 | // definition to precompile |
no test coverage detected