L08 Search and symbol navigation
17 minSuggested first: L07 Repository maps and snapshots
Outcome
Distinguish a definition, use, and re-export, then navigate to the implementation behind a public name.
Learn
A symbol is a named program entity, such as a function or class. Text search proposes candidates, but it can match a comment or an unrelated symbol with the same name. A go-to-definition jump follows an indexed relationship. A re-export exposes an existing symbol, under the same name or a new one.
If the index has no edge between two names, read the imports and source yourself, and don't claim an inferred link is verified.
Worked example
The caller in demo.ts uses price. Where is the body that runs?
// public.ts
export { basePrice as price } from "./cost";
// cost.ts
export function basePrice(count: number) { return count * 4; }
// demo.ts
import { price } from "./public";
const quoted = price(3);
Predict first, then show the worked explanation
demo.ts imports price from the public module. That module re-exports basePrice under the
name price. The function body is in cost.ts. So: search for the public name, follow the
re-export, then read the body.
Practice and check
Common mistake
Assuming "references" means "runtime calls". A reference can be a type, an alias, or a function passed as a value.
Practice on a real repository
Try the symbol navigation in the puzzle below. No answer path is supplied: start from its prompt.
- Where immer's produce is renamedArchitecture · Easy · reduxjs-redux-toolkit
Related topics: Code structure
Practice is optional. Solving a puzzle doesn't complete a lesson, and lessons never change a puzzle's points.
References
- Modules and Packages (Node.js documentation)
- SCIP Code Intelligence Protocol (SCIP maintainers)