A generator function declared at top level is not indexed — no node, no edges in or out, no warning.
Repro
src/a.ts, the whole project:
function plain() { return 1; }
function* gen() { return 2; }
async function asyncFn() { return 3; }
async function* asyncGen() { return 4; }
After codegraph index:
gen and asyncGen are absent. The same holds in .js, and for the expression
form const g = function* () {}.
Why this looks like an oversight rather than a scope decision
Generators are indexed everywhere else:
| Where |
Example |
Indexed |
| Class method |
*m() {} |
yes |
| Class method, async |
async *m() {} |
yes |
| Exported object literal |
export const o = { *m() {} } |
yes |
| Top-level declaration |
function* g() {} |
no |
| Top-level, async |
async function* g() {} |
no |
| Function expression |
const g = function* () {} |
no |
The non-generator form of each missing row is indexed. The only difference is
the *.
Cause
The generator node types are missing from the TS/JS function-type lists — in
both extraction paths, which is worth noting because the native kernel is the
one that runs by default:
// src/extraction/languages/typescript.ts:42
// src/extraction/languages/javascript.ts:6
functionTypes: ['function_declaration', 'arrow_function', 'function_expression'],
// codegraph-kernel/src/tsjs/mod.rs:63
matches!(kind, "function_declaration" | "arrow_function" | "function_expression")
Neither lists generator_function_declaration or generator_function, so the
walker skips those nodes. The type name is already known to the codebase —
src/graph/branch-guards.ts:1297 uses 'generator_function_declaration'.
Scope
Three of CodeGraph's own functions are invisible to CodeGraph:
src/utils.ts:427 export async function* readFileInChunks(…)
src/resolution/callback-synthesizer.ts:139 function* methodAndFunctionNodes(…)
src/resolution/frameworks/object-literal.ts:59 export function* topLevelObjects(…)
Beyond that, function* is the core idiom of redux-saga and shows up throughout
Effect-TS codebases and hand-written iterators, so on those projects the loss is
not incidental.
The failure is silent: indexing reports success and the caller lists of the
surrounding functions look complete.
A generator function declared at top level is not indexed — no node, no edges in or out, no warning.
Repro
src/a.ts, the whole project:After
codegraph index:genandasyncGenare absent. The same holds in.js, and for the expressionform
const g = function* () {}.Why this looks like an oversight rather than a scope decision
Generators are indexed everywhere else:
*m() {}async *m() {}export const o = { *m() {} }function* g() {}async function* g() {}const g = function* () {}The non-generator form of each missing row is indexed. The only difference is
the
*.Cause
The generator node types are missing from the TS/JS function-type lists — in
both extraction paths, which is worth noting because the native kernel is the
one that runs by default:
Neither lists
generator_function_declarationorgenerator_function, so thewalker skips those nodes. The type name is already known to the codebase —
src/graph/branch-guards.ts:1297uses'generator_function_declaration'.Scope
Three of CodeGraph's own functions are invisible to CodeGraph:
Beyond that,
function*is the core idiom of redux-saga and shows up throughoutEffect-TS codebases and hand-written iterators, so on those projects the loss is
not incidental.
The failure is silent: indexing reports success and the caller lists of the
surrounding functions look complete.