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

Function isExportUsed

ark/aot/usage.ts:2114–2149  ·  view source on GitHub ↗
(
	module: SourceModule,
	exportName: string,
	ctx: ThisReadsContext,
	seen = new Set<string>()
)

Source from the content-addressed store, hash-verified

2112}
2113
2114const isExportUsed = (
2115 module: SourceModule,
2116 exportName: string,
2117 ctx: ThisReadsContext,
2118 seen = new Set<string>()
2119): boolean => {
2120 const key = `${module.id}\0${exportName}`
2121 if (seen.has(key)) return false
2122 seen.add(key)
2123 if (ctx.entries.has(module.id) || ctx.exposed.has(module.id)) return true
2124 for (const edge of ctx.importersById.get(module.id) ?? []) {
2125 switch (edge.kind) {
2126 case "named":
2127 if (edge.name === exportName) return true
2128 break
2129 case "namespace":
2130 case "whole":
2131 return true
2132 case "reexport":
2133 if (
2134 edge.name === exportName &&
2135 isExportUsed(edge.module, edge.as, ctx, seen)
2136 )
2137 return true
2138 break
2139 case "star":
2140 if (
2141 exportName !== "default" &&
2142 isExportUsed(edge.module, exportName, ctx, seen)
2143 )
2144 return true
2145 break
2146 }
2147 }
2148 return false
2149}
2150
2151// the function a this is read in, where it has one a class doesn't bind
2152const enclosingThisFunctionOf = (node: Node): Node | undefined => {

Callers 1

isDeadTopLevelFunctionFunction · 0.85

Calls 3

getMethod · 0.65
hasMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected