( def: unknown, scope: BaseScope, seen: Set<unknown> )
| 1236 | } |
| 1237 | |
| 1238 | const evalDefInScope = ( |
| 1239 | def: unknown, |
| 1240 | scope: BaseScope, |
| 1241 | seen: Set<unknown> |
| 1242 | ): BaseRoot | undefined => { |
| 1243 | try { |
| 1244 | if (hasArkKind(def, "root")) return def |
| 1245 | if (typeof def === "string") return evalStringTypeInScope(def, scope, seen) |
| 1246 | if (seen.has(def)) return undefined |
| 1247 | if (Array.isArray(def)) { |
| 1248 | seen.add(def) |
| 1249 | if (def.length === 3 && def[1] === ":") { |
| 1250 | const base = evalDefInScope(def[0], scope, seen) |
| 1251 | if (base && typeof def[2] === "function") |
| 1252 | return base.narrow(def[2] as never) |
| 1253 | return base |
| 1254 | } |
| 1255 | if (def.length === 3 && def[1] === "@") |
| 1256 | return evalDefInScope(def[0], scope, seen) |
| 1257 | if (def.length === 3 && def[1] === "&") { |
| 1258 | const l = evalDefInScope(def[0], scope, new Set(seen)) |
| 1259 | const r = evalDefInScope(def[2], scope, new Set(seen)) |
| 1260 | return l && r ? l.and(r) : undefined |
| 1261 | } |
| 1262 | if (def.length === 3 && def[1] === "|") { |
| 1263 | const l = evalDefInScope(def[0], scope, new Set(seen)) |
| 1264 | const r = evalDefInScope(def[2], scope, new Set(seen)) |
| 1265 | return l && r ? l.or(r) : undefined |
| 1266 | } |
| 1267 | return undefined |
| 1268 | } |
| 1269 | if (isPlainContainer(def)) return type.raw(def).internal |
| 1270 | } catch { |
| 1271 | return undefined |
| 1272 | } |
| 1273 | return undefined |
| 1274 | } |
| 1275 | |
| 1276 | const evalStringTypeInScope = ( |
| 1277 | rawExpr: string, |
no test coverage detected