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

Function globalTypeMember

src/resolution/import-resolver.ts:3185–3195  ·  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

3183 * globals reach its tests only.
3184 */
3185function globalTypeMember(namespace: string, ref: UnresolvedRef, context: ResolutionContext): Node | undefined {
3186 const fromTest = isTestFile(ref.filePath);
3187 return context.getNodesByName(ref.referenceName)
3188 .filter((n) => {
3189 if (!TS_JS_FILE.test(n.filePath) || n.qualifiedName !== n.name || !MEMBER_DECLARATION_KINDS.has(n.kind)) return false;
3190 if (!fromTest && isTestFile(n.filePath)) return false;
3191 const block = innermostBlock(n, namespaceBlocks(n.filePath, context));
3192 return block?.global === true && block.path === namespace;
3193 })
3194 .sort(typesFirst)[0];
3195}
3196
3197/**
3198 * 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