MCPcopy Create free account
hub / github.com/arktypeio/arktype / readArkExport

Method readArkExport

ark/aot/usage.ts:378–415  ·  view source on GitHub ↗
(
		runtime: RuntimeModule,
		as: string,
		name: string,
		seen: Set<string>
	)

Source from the content-addressed store, hash-verified

376
377 // arktype's export `name` re-exported as `as`, read where it's imported
378 private readArkExport(
379 runtime: RuntimeModule,
380 as: string,
381 name: string,
382 seen: Set<string>
383 ): void {
384 const { id } = runtime.module
385 const key = `${id}\0${as}`
386 if (seen.has(key)) return
387 seen.add(key)
388 // whoever reads it
389 if (name === "TraversalError") this.used.add("thrown")
390 // code outside the bundle may read it
391 if (this.program.entries.has(id) || this.program.exposed.has(id))
392 this.used.add("errors")
393 for (const edge of this.edgesByTarget.get(id) ?? []) {
394 switch (edge.kind) {
395 case "named":
396 if (edge.name === as)
397 this.readArkImport(name, edge.binding, edge.importer)
398 break
399 case "reexport":
400 if (edge.name === as)
401 this.readArkExport(edge.importer, edge.as, name, seen)
402 break
403 case "star":
404 if (as !== "default")
405 this.readArkExport(edge.importer, as, name, seen)
406 break
407 case "input":
408 if (edge.name === as) this.used.add("errors")
409 break
410 // what reads a namespace or a whole module isn't followed
411 default:
412 this.used.add("errors")
413 }
414 }
415 }
416
417 // arktype's export, as what it may hand a program of the errors class, or
418 // undefined for its default or namespace

Callers 1

analyzeMethod · 0.95

Calls 4

readArkImportMethod · 0.95
getMethod · 0.65
hasMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected