Language Support
Codegen provides first-class support for both Python and TypeScript codebases. The language is automatically inferred when you initialize a codebase.
Language Detection
When you create a new Codebase
instance, Codegen automatically detects the programming language:
Learn more about codebase initialization options in Parsing Codebases.
Type System
Codegen uses specialized types for each language. These are defined as type aliases:
Every code element has both a Python and TypeScript implementation that inherits from a common base class. For example:
…
This inheritance pattern means that most Codegen programs can work with either Python or TypeScript without modification, since they share the same API structure.
TypeScript-Specific Features
Some features are only available in TypeScript codebases:
- Types and Interfaces: TypeScript’s rich type system (TSTypeAlias, TSInterface)
- Exports: Module exports and re-exports (TSExport)
- JSX/TSX: React component handling (see React and JSX)
Example of TypeScript-specific features: