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

Method keepBinding

ark/aot/flat.ts:835–852  ·  view source on GitHub ↗
(module: SourceModule, binding: Binding | undefined)

Source from the content-addressed store, hash-verified

833 }
834
835 private keepBinding(module: SourceModule, binding: Binding | undefined) {
836 if (!binding || binding.scope !== module.scopes.root) return
837 if (binding.kind !== "import") {
838 this.keep(module, statementOf(binding.declaration))
839 return
840 }
841 if (this.imports.has(binding)) return
842 this.imports.add(binding)
843 const specifier = binding.declaration
844 if (specifier.parent?.type !== "ImportDeclaration") return
845 const target = this.targetOf(specifier.parent.source.value, module)
846 if (!target) return
847 if (specifier.type === "ImportSpecifier")
848 this.keepExport(target, exportNameOf(specifier.imported))
849 else if (specifier.type === "ImportDefaultSpecifier")
850 this.keepExport(target, "default")
851 else this.keepExports(target)
852 }
853
854 // a generated module by its specifier, another as the bundler resolves it
855 private targetOf(

Callers 2

keepMethod · 0.95
keepExportMethod · 0.95

Calls 8

keepMethod · 0.95
targetOfMethod · 0.95
keepExportMethod · 0.95
keepExportsMethod · 0.95
statementOfFunction · 0.90
exportNameOfFunction · 0.90
hasMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected