TypeScript2Python is a transpiler that converts TypeScript type declarations into Python type annotations compatible with Pyright and TypedDict. The current stable version is 2.2.0. It is actively maintained with regular releases. Key differentiators include support for nested objects, optional properties, docstrings, and strict null checks. It is designed for serializable data (JSON) and does not support generics or function signatures.
npm install typescript2pythonNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
How to use the transform function to convert TypeScript type declarations to Python TypedDict classes.
Use import statements or dynamic import() for CJS codebases.
Use '--nullable-optionals' (correct spelling) in v2.2.0+.
Pre-process your TypeScript types to remove unsupported constructs before passing to the transformer.
Update to v2.1.1+ where empty string keys are no longer transpiled.
Use dynamic import: const { transform } = await import('typescript2python');Use import { transform } from 'typescript2python';Remove generics or replace with concrete types before transpilation.