CodeGraph/docs
Section 2.5.5

TypeScript Type Declarations

Extracting compile-time type definitions including interfaces, type aliases, and enums from Babel syntax trees.

Source: server/src/parser/extractors/SymbolExtractor.ts

Supported TypeScript Types

CodeGraph extracts three core TypeScript type declarations as first-class symbols:

Declaration TypeSymbolKindExample SyntaxRuntime Scope Binding?
TSInterfaceDeclarationinterfaceinterface UserRecord { id: string; }No (stripped at runtime)
TSTypeAliasDeclarationtypeAliastype Handler = (e: Event) => voidNo (stripped at runtime)
TSEnumDeclarationenumenum 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
1
2
3
4
5
6
7
8
// 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" ) );