(node: Node, ctx: Context)
| 1026 | } |
| 1027 | |
| 1028 | private evaluateReference(node: Node, ctx: Context): Lookup { |
| 1029 | node = unwrapExpression(node) |
| 1030 | if (node.type === "Identifier") |
| 1031 | return this.readIdentifier(node as IdentifierReference, ctx) |
| 1032 | if (node.type !== "MemberExpression") |
| 1033 | return { value: this.evaluate(node, ctx) } |
| 1034 | const base = this.evaluateReference(node.object, ctx) |
| 1035 | if (base.value === shortCircuit || isDynamic(base.value)) return base |
| 1036 | if (base.declaration) |
| 1037 | ctx.trace.declared.push([base.value, base.declaration]) |
| 1038 | // e.g. `$` in `$.type.or("a", "b")` |
| 1039 | if ( |
| 1040 | hasArkKind(base.value, "root") || |
| 1041 | hasArkKind(base.value, "scope") || |
| 1042 | hasArkKind(base.value, "generic") |
| 1043 | ) |
| 1044 | this.recordRead(node.object, base.value, ctx) |
| 1045 | const dynamic = findDynamic(base.value) |
| 1046 | if (dynamic) return { value: dynamic.asOperand() } |
| 1047 | if (node.optional && (base.value === null || base.value === undefined)) |
| 1048 | return { value: shortCircuit } |
| 1049 | const key = this.keyOf(node, ctx) |
| 1050 | if (isDynamic(key)) return { value: key } |
| 1051 | const value = this.readMember(base.value, key, node, ctx) |
| 1052 | // a Module's Types are declared with it, though only it compares |
| 1053 | const declaration = |
| 1054 | base.declaration && hasArkKind(base.value, "module") ? |
| 1055 | { ...base.declaration, compares: false } |
| 1056 | : undefined |
| 1057 | if (!base.read) return { value, declaration } |
| 1058 | // a read stops at a Type whose validator lacks the member |
| 1059 | if ( |
| 1060 | base.read.value !== base.value || |
| 1061 | (lacksMember(base.value, key) && |
| 1062 | ((hasArkKind(base.value, "root") && isTypeOnlyMember(key)) || |
| 1063 | this.isReadThrough(ctx.site))) |
| 1064 | ) |
| 1065 | return { value, read: base.read, declaration } |
| 1066 | return { |
| 1067 | value, |
| 1068 | read: { root: base.read.root, path: [...base.read.path, key], value }, |
| 1069 | declaration |
| 1070 | } |
| 1071 | } |
| 1072 | |
| 1073 | // e.g. `T.in.json`, but not a bare `T.internal` |
| 1074 | private isReadThrough(site: SiteState | undefined): boolean { |
no test coverage detected