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

Function loadedSpecifierOf

ark/aot/scope.ts:1028–1040  ·  view source on GitHub ↗
(node: Node)

Source from the content-addressed store, hash-verified

1026
1027// e.g. "./a.ts" for `import("./a.ts")`, `require("./a.ts")` or `import a = require("./a.ts")`
1028export const loadedSpecifierOf = (node: Node): unknown => {
1029 // a require() may be one createRequire() returns
1030 const source =
1031 loadedSourceOf(node) ??
1032 ((
1033 node.type === "TSImportEqualsDeclaration" &&
1034 node.importKind !== "type" &&
1035 node.moduleReference.type === "TSExternalModuleReference"
1036 ) ?
1037 node.moduleReference.expression
1038 : undefined)
1039 return source?.type === "Literal" ? source.value : undefined
1040}
1041
1042// e.g. `await import("arktype")` as a statement, loading a module only to run it
1043export const isDiscarded = (node: Node): boolean => {

Callers 3

valueSpecifiersOfMethod · 0.90
checkHelperReadsMethod · 0.90
checkDynamicImportsMethod · 0.90

Calls 1

loadedSourceOfFunction · 0.85

Tested by

no test coverage detected