( node: Node, parent: Node | null | undefined, runtime: RuntimeModule, path: readonly string[] = [] )
| 728 | // a read of a validator, or of an object holding one at path, e.g. |
| 729 | // `schemas.user(data)` where `const schemas = { user: User }` |
| 730 | private read( |
| 731 | node: Node, |
| 732 | parent: Node | null | undefined, |
| 733 | runtime: RuntimeModule, |
| 734 | path: readonly string[] = [] |
| 735 | ): void { |
| 736 | const { module } = runtime |
| 737 | // passed to its site's factory, which finds the holes it holds by the |
| 738 | // validator itself, reading no member |
| 739 | if (runtime.kept.some(span => isSpan(node, span))) return |
| 740 | // e.g. `import.meta.env.DEV ? DevPost : Post`, read as its result is |
| 741 | if ( |
| 742 | (parent?.type === "ConditionalExpression" && parent.test !== node) || |
| 743 | parent?.type === "LogicalExpression" |
| 744 | ) |
| 745 | return this.readValue(parent, runtime, path) |
| 746 | // held in an object literal at a key, read off the object |
| 747 | if ( |
| 748 | parent?.type === "Property" && |
| 749 | parent.value === node && |
| 750 | parent.kind === "init" && |
| 751 | !parent.method && |
| 752 | parent.parent?.type === "ObjectExpression" |
| 753 | ) { |
| 754 | const key = propertyKeyOf(parent) |
| 755 | if ( |
| 756 | key !== undefined && |
| 757 | (key === "__proto__" || |
| 758 | mayReadThrough( |
| 759 | key, |
| 760 | parent.parent, |
| 761 | module, |
| 762 | this.thisReads, |
| 763 | !path.length |
| 764 | )) |
| 765 | ) |
| 766 | this.handedOff ??= `${module.positionOf(node)} holds a validator at ${key} of an object whose members may read it through this` |
| 767 | |
| 768 | if (key !== undefined) |
| 769 | return this.readValue(parent.parent, runtime, [key, ...path]) |
| 770 | } |
| 771 | if (path.length) return this.readHolder(node, parent, runtime, path) |
| 772 | if (parent?.type === "CallExpression" && parent.callee === node) { |
| 773 | this.used.add("call") |
| 774 | this.readArguments(parent) |
| 775 | this.readResult(parent, runtime) |
| 776 | return |
| 777 | } |
| 778 | if ( |
| 779 | parent?.type === "MemberExpression" && |
| 780 | parent.object === node && |
| 781 | !isWriteTarget(parent) |
| 782 | ) { |
| 783 | const name = memberNameOf(parent) |
| 784 | if (typeof name === "string" && name in usedMembersByName) { |
| 785 | const used = usedMembersByName[name] |
| 786 | if (used) this.used.add(used) |
| 787 | // a call by another name |
no test coverage detected