Section 2.5.5Source:
server/src/parser/extractors/SymbolExtractor.tsTypeScript Type Declarations
Extracting compile-time type definitions including interfaces, type aliases, and enums from Babel syntax trees.
Source:
server/src/parser/extractors/SymbolExtractor.tsSupported TypeScript Types
CodeGraph extracts three core TypeScript type declarations as first-class symbols:
| Declaration Type | SymbolKind | Example Syntax | Runtime Scope Binding? |
|---|---|---|---|
| TSInterfaceDeclaration | interface | interface UserRecord { id: string; } | No (stripped at runtime) |
| TSTypeAliasDeclaration | typeAlias | type Handler = (e: Event) => void | No (stripped at runtime) |
| TSEnumDeclaration | enum | enum Direction { Up, Down } | Yes (runtime object in JS) |
Why Type Declarations Require Name-Based Fallbacks
Because TypeScript interfaces and type aliases are purely compile-time constructs, Babel's scope tracking (path.scope.getBinding(name)) does not create runtime binding records for them.
When an export or implements statement references a type (e.g. export default UserInterface orclass A implements UserInterface), the resolver falls back to searching parsedFile.symbolsby identifier name:
Type Binding Fallback
12345678// Fallback when Babel scope binding returns undefined for types: const symbol = parsedFile.symbols.find( s => s.name === name && ( s.symbolKind === "interface" || s.symbolKind === "typeAlias" || s.symbolKind === "enum" ) );