Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Cpp2TypeScript

Cpp2TypeScript is a partial-coverage C++-to-TypeScript translator and proof-of-concept. It is not a general C++20 compiler, and it is not actively developed. I have no plans to finish it. This repository is prepared as an experimental snapshot of one approach to translating C++-shaped programs into refactorable TypeScript.

The project inherits the C translation machinery used by C2TypeScript and adds experimental C++ runtime support for smart pointers, exceptions, RTTI, standard-library containers, move-oriented code, and related C++ constructs.

Status

v0.1 - inactive proof-of-concept, partial C++20 coverage. The C++ path is less mature than the C path. It demonstrates pieces of a possible C++20 translation pipeline, but it does not claim full template support, complete standard-library coverage, correct exception behavior across every boundary, coroutine support, module support, or general compatibility with arbitrary C++ projects.

Treat Cpp2TypeScript as a research artifact. It is useful for inspecting how C++ semantics might be represented in TypeScript, not as a maintained compiler project or a production dependency.

Demonstrated Scope

  • C subset translation via the shared translator core.
  • Experimental C++ standard-library runtime helpers.
  • Early support for smart pointers, exceptions, RTTI, containers, and move-oriented patterns.
  • A small C++ validation suite used during development.

No medium-scale C++ library has been published as a completed ts-* translation from this project.

Known Limits

  • Full C++20 coverage was not reached.
  • Template-heavy libraries remain outside demonstrated coverage.
  • The C++ standard library is only partially modeled.
  • Exceptions, lambdas, move semantics, coroutines, and modules are incomplete.
  • Unsupported constructs should be treated as outside the experiment, even where partial code paths exist.

Snapshot Usage

This repository is not presented as a polished npm package or maintained CLI. The commands below describe the intended shape of the prototype interface, but expect rough edges in the checked-in snapshot.

Translate a C++ file:

npx cpp2typescript --input path/to/program.cpp --output path/to/program.ts

Run the translated program:

node path/to/program.ts

Runtime Model

Cpp2TypeScript emits to vendored runtime libraries with literal names:

  • vendor/cpp-stdlib/ - experimental C++ runtime helpers, including smart pointers, exceptions, RTTI, and standard-library container support.
  • vendor/c-pointer-layout/ - C/C++ pointer model, heap, numeric primitives, and struct layout.
  • vendor/c-stdlib/ - C standard-library support shared with the C translator.
  • vendor/posix-runtime/ - POSIX-shaped surfaces used by translated programs.
  • vendor/browser-runtime/ - optional browser-oriented runtime surfaces.

The repository also vendors translator-support libraries: clang-frontend/, source-mapping/, compile-db/, dep-graph/, conformance/, validation-harness/, cpp-validation/, and concurrency-runtime/.

Relationship To C2TypeScript And Lua2TypeScript

Cpp2TypeScript is a sibling experimental translator snapshot:

  • C2TypeScript - C17 to TypeScript; the most complete of the three.
  • Lua2TypeScript - Lua 5.4 to TypeScript; partial and inactive.
  • Cpp2TypeScript - C++20 to TypeScript; partial and inactive.

License

MIT - see LICENSE.

Author

Scott Moore.