MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / globalTypeMember

Function globalTypeMember

src/resolution/import-resolver.ts:3084–3094  ·  view source on GitHub ↗

* The member of a namespace the project declares global (`Express.User`, an * interface in `declare global { namespace Express { … } }`): a declaration of * the reference's name directly in such a block. A test's or a fixture's * globals reach its tests only.

(namespace: string, ref: UnresolvedRef, context: ResolutionContext)

Source from the content-addressed store, hash-verified

3082 * globals reach its tests only.
3083 */
3084function globalTypeMember(namespace: string, ref: UnresolvedRef, context: ResolutionContext): Node | undefined {
3085 const fromTest = isTestFile(ref.filePath);
3086 return context.getNodesByName(ref.referenceName)
3087 .filter((n) => {
3088 if (!TS_JS_FILE.test(n.filePath) || n.qualifiedName !== n.name || !MEMBER_DECLARATION_KINDS.has(n.kind)) return false;
3089 if (!fromTest && isTestFile(n.filePath)) return false;
3090 const block = innermostBlock(n, namespaceBlocks(n.filePath, context));
3091 return block?.global === true && block.path === namespace;
3092 })
3093 .sort(typesFirst)[0];
3094}
3095
3096/**
3097 * What `path` names in `file`, from the namespace `scope` (the file's top

Callers 1

Calls 5

isTestFileFunction · 0.90
namespaceBlocksFunction · 0.90
innermostBlockFunction · 0.85
hasMethod · 0.80
getNodesByNameMethod · 0.65

Tested by

no test coverage detected