{"id":30977298,"url":"https://github.com/wowemulation-dev/typescript2cxx","last_synced_at":"2026-05-16T11:34:03.176Z","repository":{"id":308337869,"uuid":"1027127112","full_name":"wowemulation-dev/typescript2cxx","owner":"wowemulation-dev","description":"A TypeScript transpiler enabling users to transpile TypeScript to C++20 standard compliant CPP.","archived":false,"fork":false,"pushed_at":"2026-02-22T23:27:26.000Z","size":828,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-23T04:21:04.968Z","etag":null,"topics":["compiler","cpp","cpp20","transpiler","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wowemulation-dev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"danielsreichenbach"}},"created_at":"2025-07-27T11:23:03.000Z","updated_at":"2026-02-22T23:27:30.000Z","dependencies_parsed_at":"2025-08-05T12:34:08.109Z","dependency_job_id":null,"html_url":"https://github.com/wowemulation-dev/typescript2cxx","commit_stats":null,"previous_names":["wowemulation-dev/typescript2cxx"],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/wowemulation-dev/typescript2cxx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wowemulation-dev%2Ftypescript2cxx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wowemulation-dev%2Ftypescript2cxx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wowemulation-dev%2Ftypescript2cxx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wowemulation-dev%2Ftypescript2cxx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wowemulation-dev","download_url":"https://codeload.github.com/wowemulation-dev/typescript2cxx/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wowemulation-dev%2Ftypescript2cxx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33100896,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-16T04:41:52.686Z","status":"ssl_error","status_checked_at":"2026-05-16T04:41:52.009Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compiler","cpp","cpp20","transpiler","typescript"],"created_at":"2025-09-12T05:04:06.051Z","updated_at":"2026-05-16T11:34:03.170Z","avatar_url":"https://github.com/wowemulation-dev.png","language":"TypeScript","funding_links":["https://github.com/sponsors/danielsreichenbach"],"categories":[],"sub_categories":[],"readme":"# typescript2cxx\n\nA Deno-native TypeScript to C++20 transpiler for generating high-performance C++\ncode from TypeScript sources, targeting World of Warcraft emulation projects.\n\n\u003cdiv align=\"center\"\u003e\n\n[![Discord](https://img.shields.io/discord/1394228766414471219?logo=discord\u0026style=flat-square)](https://discord.gg/Jj4uWy3DGP)\n[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE-APACHE)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE-MIT)\n\n\u003c/div\u003e\n\n## Purpose\n\nThis transpiler enables WoW emulation developers to:\n\n- Write game logic in TypeScript with type safety\n- Generate optimized C++20 code for emulation cores\n- Maintain consistency across different emulation projects\n- Leverage modern JavaScript tooling while targeting C++ performance\n\n## Features\n\n- **Modern C++20 Output** - Utilizes concepts, coroutines, and modules\n- **Type Safety** - Preserves TypeScript type information in C++\n- **Performance Focus** - Generates optimized code patterns for game emulation\n- **Extensible Plugin System** - Support for custom transformations\n- **Spec-Driven Development** - Test-first approach ensuring correctness\n\n## Quick Start\n\n### Installation \u0026 Usage\n\n\u003e **Note**: This package uses the TypeScript Compiler API (npm:typescript) for parsing and type checking.\n\u003e It is now published on JSR.io and can be easily installed in any Deno project.\n\n#### Install from JSR (Recommended)\n\n```bash\n# Install globally as a CLI tool\ndeno install -Arf -n tsc2cxx jsr:@wowemulation-dev/typescript2cxx/cli\n\n# Use the installed CLI\ntsc2cxx input.ts -o output/\n\n# Or add to your project\ndeno add @wowemulation-dev/typescript2cxx\n```\n\n#### Install from Source\n\n```bash\n# Clone the repository\ngit clone https://github.com/wowemulation-dev/typescript2cxx\ncd typescript2cxx\n\n# Run directly with Deno\ndeno run --allow-net --allow-read --allow-write src/cli.ts input.ts\n\n# Or build an executable\ndeno compile --allow-net --allow-read --allow-write --output typescript2cxx src/cli.ts\n./typescript2cxx input.ts\n```\n\n### Module Usage\n\n```typescript\n// Import from JSR\nimport { transpile } from \"@wowemulation-dev/typescript2cxx\";\n\n// Or import from local source\n// import { transpile } from \"./src/mod.ts\";\n\n// Transpile TypeScript to C++\nconst result = await transpile(`\n  class Point {\n    x: number = 42;\n\n    display(): void {\n      console.log(\\`Point x: \\${this.x}\\`);\n    }\n  }\n\n  let p = new Point();\n  p.display();\n`);\n\nconsole.log(result.header); // Generated C++ header\nconsole.log(result.source); // Generated C++ source\n```\n\n## Current Status\n\n**Version 0.5.2** - Production-ready with enhanced project organization and E2E testing\n\n### Recent Achievements\n\n- ✅ **E2E Compilation Success** - TypeScript code now compiles and runs as C++\n- ✅ **Complete JavaScript Runtime** - Full implementation of JS built-in types and objects\n- ✅ **Project Organization** - Consolidated output structure with `.output/` directory\n- ✅ **Enhanced Testing** - Comprehensive E2E pipeline validation with actual C++ compilation\n- ✅ **Advanced TypeScript Features** - Decorators, unions, intersections, type guards\n- ✅ **Exception Handling** - Try/catch/finally with proper C++ semantics\n- ✅ **JSR.io Publishing** - Package available on JSR registry\n\n### Project Highlights\n\n- **50+ TypeScript features** supported\n- **100+ JavaScript runtime methods** implemented\n- **200+ test cases** passing\n- **Cross-platform** C++ compilation (clang++, g++, MSVC)\n\n## TypeScript to C++ Mappings\n\n### Basic Types (v0.4.1)\n\n| TypeScript  | C++20                    | Implementation Status     |\n| ----------- | ------------------------ | ------------------------- |\n| `number`    | `js::number` (double)    | ✅ Complete               |\n| `string`    | `js::string`             | ✅ Complete (30+ methods) |\n| `boolean`   | `bool`                   | ✅ Complete               |\n| `any`       | `js::any` (std::variant) | ✅ Complete               |\n| `void`      | `void`                   | ✅ Complete               |\n| `null`      | `js::null`               | ✅ Complete               |\n| `undefined` | `js::undefined`          | ✅ Complete               |\n\n### Complex Types (v0.4.1)\n\n| TypeScript        | C++20                  | Implementation Status     |\n| ----------------- | ---------------------- | ------------------------- |\n| `T[]`             | `js::array\u003cT\u003e`         | ✅ Complete (20+ methods) |\n| `Array\u003cT\u003e`        | `js::array\u003cT\u003e`         | ✅ Complete               |\n| `object`          | `js::object`           | ✅ Complete               |\n| `class`           | C++ class with methods | ✅ Complete               |\n| `new T()`         | `std::make_shared\u003cT\u003e`  | ✅ Complete               |\n| Template literals | String concatenation   | ✅ Complete               |\n| `Date`            | `js::Date`             | ✅ Complete               |\n| `RegExp`          | `js::RegExp`           | ✅ Complete               |\n| `Promise\u003cT\u003e`      | `std::future\u003cT\u003e`       | ⚠️ Basic                  |\n| `Error`           | `js::Error`            | ✅ Complete               |\n\n### Advanced TypeScript Features (v0.4.1)\n\n| Feature            | C++20 Implementation               | Status      |\n| ------------------ | ---------------------------------- | ----------- |\n| Decorators         | Metadata with `has_metadata\u003cT\u003e`    | ✅ Complete |\n| Union Types        | `js::typed::StringOrNumber`, etc.  | ✅ Complete |\n| Intersection Types | First-type prioritization          | ✅ Complete |\n| Type Guards        | `typeof` operator, type predicates | ✅ Complete |\n| Try/Catch/Finally  | Exception handling with js::any    | ✅ Complete |\n| Async/Await        | C++20 coroutines                   | 📋 Planned  |\n| Generics           | Template specialization            | ⚠️ Basic    |\n| Conditional Types  | Template metaprogramming           | 📋 Planned  |\n| Mapped Types       | Template generation                | 📋 Planned  |\n\n### Comprehensive JavaScript Runtime (v0.3.0)\n\nThe `runtime/core.h` provides a complete JavaScript-compatible runtime:\n\n#### Core Types\n\n- **js::string** - Full JavaScript string with 30+ methods (charAt, slice, split, replace, etc.)\n- **js::number** - IEEE 754 double with NaN/Infinity support and parsing methods\n- **js::array\u003cT\u003e** - JavaScript-compatible arrays with forEach, map, filter, reduce, etc.\n- **js::object** - Prototype-based objects with dynamic property access\n- **js::any** - Dynamic typing using std::variant\n\n#### Standard Objects\n\n- **js::Math** - Complete Math object (PI, random, abs, max, min, sin, cos, etc.)\n- **js::Date** - Full Date/time API (now, getFullYear, toString, etc.)\n- **js::RegExp** - Regular expression support with test/exec methods\n- **js::console** - All console methods (log, error, warn, info, debug, trace)\n- **js::JSON** - stringify and parse methods for object serialization\n\n#### Global Functions\n\n- **parseInt/parseFloat** - String to number conversion with radix support\n- **isNaN/isFinite** - Number validation functions\n- **encodeURI/decodeURI** - URI encoding/decoding\n- **setTimeout/setInterval** - Timer functions (planned)\n\n#### Error Types\n\n- **js::Error** - Base error class with message and stack\n- **js::TypeError** - Type-related errors\n- **js::ReferenceError** - Reference errors\n- **js::SyntaxError** - Syntax errors\n- **js::RangeError** - Range errors\n\n### Type System Enhancements\n\n| TypeScript  | Planned C++20          | Status     |\n| ----------- | ---------------------- | ---------- |\n| `bigint`    | `js::bigint`           | 📋 Planned |\n| `unknown`   | `js::unknown`          | ⚠️ Basic   |\n| `symbol`    | `js::symbol`           | 📋 Planned |\n| `interface` | `struct` with concepts | ⚠️ Basic   |\n| `enum`      | `enum class`           | 📋 Planned |\n| `namespace` | C++ namespace          | ⚠️ Basic   |\n| `module`    | C++20 modules          | 📋 Planned |\n\n### Roadmap\n\n| Version | Focus Area                           |\n| ------- | ------------------------------------ |\n| Next    | Async/Await \u0026 Coroutines             |\n| Future  | Full Generic System                  |\n| Future  | Module System \u0026 Bundling             |\n| Future  | Advanced Types (Conditional, Mapped) |\n| Future  | Performance \u0026 Optimization           |\n| v1.0.0  | Production Ready                     |\n\n## CLI Usage\n\n### Basic Commands\n\n```bash\n# Transpile a TypeScript file\ndeno run --allow-net --allow-read --allow-write src/cli.ts input.ts\n\n# Specify output directory\ndeno run --allow-net --allow-read --allow-write src/cli.ts -o output/ input.ts\n\n# Use custom C++ standard\ndeno run --allow-net --allow-read --allow-write src/cli.ts --std c++20 input.ts\n\n# Custom runtime include path\ndeno run --allow-net --allow-read --allow-write src/cli.ts --runtime \"my/runtime.h\" input.ts\n```\n\n### Available Options\n\n- `--std \u003cstandard\u003e` - C++ standard (c++17, c++20, c++23)\n- `--readable \u003cmode\u003e` - Code readability mode\n- `--optimization \u003clevel\u003e` - Optimization level (O0-O3, Os)\n- `--memory \u003cstrategy\u003e` - Memory management strategy\n- `--runtime \u003cpath\u003e` - Custom runtime include path\n- `--plugin \u003cname\u003e` - Load transpiler plugins\n- `--cmake` - Generate CMakeLists.txt build files ✅ **NEW in v0.5.2**\n\n### Build System Integration (v0.5.2)\n\n```bash\n# Generate CMakeLists.txt with your transpiled C++ code\ndeno run --allow-all src/cli.ts --cmake -o build/ input.ts\n\n# Build with CMake\ncd build/\nmkdir cmake-build \u0026\u0026 cd cmake-build\ncmake ..\nmake\n\n# Run executable\n./input\n```\n\n**CMake Features:**\n\n- ✅ Automatic C++20 standard configuration\n- ✅ Cross-platform compiler support (GCC, Clang, MSVC)\n- ✅ Debug/Release build configurations\n- ✅ Runtime library integration\n- ✅ Include path management\n- ✅ Installation targets\n\n### Planned Options (Future)\n\n- `--build-system \u003ctype\u003e` - Select build system (make, meson, ninja)\n- `--target \u003ctype\u003e` - Build target type (executable, library)\n- `--vcpkg` - Generate vcpkg.json manifest _(Config ready)_\n- `--conan` - Generate conanfile.txt _(Config ready)_\n\n## Documentation\n\n- [Development Guide](docs/DEVELOPMENT.md) - Architecture and development workflow\n- [Changelog](CHANGELOG.md) - Version history and changes\n- [TODO List](TODO.md) - Planned features and known issues\n\n## Current Status\n\n**Version: 0.3.0** - Comprehensive JavaScript Runtime\n\nThe transpiler now includes a complete JavaScript runtime environment in C++:\n\n### ✅ **Core Features Working**\n\n- **TypeScript Parsing** - Complete AST support with TypeScript Compiler API\n- **Code Generation** - Generates valid C++20 header and source files\n- **Type System** - Full type mapping with integrated TypeScript type checker\n- **Classes \u0026 Methods** - Complete class transpilation with constructors\n- **Template Literals** - String interpolation with proper concatenation\n- **Smart Pointers** - Automatic memory management with `std::shared_ptr`\n- **Comprehensive Runtime** - Complete JavaScript runtime with 1000+ lines of C++\n- **Standard Objects** - Math, Date, RegExp, JSON, console, Error classes\n- **CLI Tool** - Full-featured command-line interface\n- **C++ Compilation** - Generated code compiles successfully with clang++ and g++\n\n### ✅ **New in v0.3.0**\n\n- **🚀 Complete JavaScript Runtime** - All major JavaScript types and objects\n- **🧮 Math Operations** - Full Math object with all standard methods\n- **📅 Date/Time Support** - Complete Date API with timezone handling\n- **🔤 Advanced Strings** - 30+ string methods (split, replace, trim, etc.)\n- **📊 Array Methods** - forEach, map, filter, reduce, find, and more\n- **🔍 Regular Expressions** - Full RegExp support with test/exec\n- **🐛 Error Handling** - Complete Error class hierarchy\n- **📝 JSON Support** - stringify/parse for object serialization\n- **⚡ Global Functions** - parseInt, parseFloat, isNaN, URI encoding\n- **🎯 Type Safety** - Comprehensive type mapping to C++ equivalents\n\n### ✅ **Verified Compatibility**\n\n- **clang++ 20.1.2** - C++20 standard support\n- **g++ 14.2.0** - C++20 standard support\n- **Executable Generation** - Programs compile and run correctly\n- **Quality Checks** - 0 linting issues, 0 type errors, 50 test steps passing\n\n### 🔧 **Example Output**\n\n```typescript\n// TypeScript Input - Showcasing v0.3.0 Runtime\nconst numbers = [1, 2, 3, 4, 5];\nconst doubled = numbers.map((x) =\u003e x * 2);\nconst sum = numbers.reduce((a, b) =\u003e a + b, 0);\n\nconst message = `Numbers: ${numbers.join(\", \")}`;\nconsole.log(message.toUpperCase());\nconsole.log(`Sum: ${sum}, PI: ${Math.PI}`);\n\nconst now = new Date();\nconsole.log(`Current year: ${now.getFullYear()}`);\n```\n\nGenerates working C++20 code with full JavaScript semantics and runtime support!\n\n### ✅ **Latest Features (v0.3.0)**\n\n- ✅ **MAJOR**: Complete JavaScript Runtime Library in C++\n- ✅ **1000+ Lines**: Comprehensive runtime implementation with full JavaScript semantics\n- ✅ **Standard Objects**: Math, Date, RegExp, JSON, console, Error classes\n- ✅ **Array Methods**: 20+ array methods including forEach, map, filter, reduce\n- ✅ **String Methods**: 30+ string methods including split, replace, trim, slice\n- ✅ **Type Conversion**: Global functions for parsing and validation\n- ✅ **Memory Management**: Smart pointer integration for runtime objects\n- ✅ **Test Coverage**: 30+ comprehensive runtime tests\n\n### ✅ **Previous Improvements (v0.1.1)**\n\n- ✅ **TypeScript API Migration**: From SWC to TypeScript Compiler API\n- ✅ **Type Checker Integration**: SimpleTypeChecker provides accurate C++ type mappings\n- ✅ **JSR.io Compatibility**: Now fully compatible with JSR publishing\n- ✅ **Enhanced Type Support**: Generic types (Array\u003cT\u003e, Promise\u003cT\u003e), unions, intersections\n\n### ✅ **Previous Improvements (v0.1.0)**\n\n- ✅ Memory annotation support from JSDoc comments (@weak, @shared, @unique)\n- ✅ Optional chaining detection and generation\n- ✅ Runtime include path configuration via --runtime CLI option\n- ✅ Fixed all compilation issues - generated code compiles successfully\n- ✅ Updated GitHub Actions to use explicit permissions (no more -A flag)\n- ✅ Fixed deprecated import usage in CLI\n\n## Development\n\n### Project Structure\n\n```\ntypescript2cxx/\n├── src/               # Transpiler source code\n│   ├── cli.ts        # CLI entry point\n│   ├── ast/          # TypeScript AST parser (using TypeScript API)\n│   ├── ir/           # Intermediate representation\n│   ├── transform/    # AST to C++ transformation\n│   ├── codegen/      # C++ code generation\n│   ├── memory/       # Memory analysis system\n│   ├── plugins/      # Plugin system\n│   ├── type-checker/ # TypeScript type checking integration\n│   └── types.ts      # Core type definitions\n├── runtime/          # C++ runtime library\n│   └── core.h        # JavaScript-compatible C++ types\n├── tests/            # Test suites\n│   ├── specs/        # Specification tests\n│   ├── fixtures/     # Test fixtures\n│   └── unit/         # Unit tests\n├── examples/         # Example transformations\n└── docs/            # Documentation\n```\n\n### Running Tests\n\n```bash\n# Run all tests\ndeno task test\n\n# Run specific test suite\ndeno task test:specs\n\n# Watch mode\ndeno task test:watch\n\n# Generate coverage\ndeno task coverage\n```\n\n### Building\n\n```bash\n# Type check\ndeno task check\n\n# Format code\ndeno task fmt\n\n# Lint\ndeno task lint\n\n# Build executable\ndeno task compile\n```\n\n## Contributing\n\nWe welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.\n\n### Development Setup\n\n1. Fork the repository\n2. Clone your fork\n3. Install Deno 2.x\n4. Run tests to verify setup\n5. Make your changes\n6. Submit a pull request\n\n### Development Scripts\n\nAvailable Deno tasks for development:\n\n```bash\n# Core testing\ndeno task test              # Run all unit and integration tests\ndeno task test:watch        # Run tests in watch mode\ndeno task test:coverage     # Run tests with coverage reporting\ndeno task coverage          # View coverage report\n\n# Spec testing\ndeno task spec              # Run transpiler specification tests\ndeno task spec:watch        # Run specs in watch mode\n\n# E2E testing with C++ compilation\ndeno task test:cmake        # Test full TypeScript → C++ → Binary pipeline\n\n# Code quality\ndeno task lint              # Lint TypeScript code\ndeno task fmt               # Format TypeScript code\ndeno task check             # Type check all files\n\n# Documentation\ndeno task docs              # Generate API documentation\n\n# Build\ndeno task compile           # Build CLI executable\n```\n\n**Output Organization**: All generated files are organized in the `.output/` directory:\n\n- `.output/coverage/` - Test coverage data\n- `.output/dist/` - Compiled CLI executable\n- `.output/docs/` - Generated API documentation\n- `.output/cmake-tests/` - CMake integration test results\n- `.output/reports/` - Test reports and analysis\n\nThe `test:cmake` task is particularly important as it validates the complete compilation chain by transpiling TypeScript code, generating CMake files, compiling with a C++ compiler, and executing the resulting binaries.\n\n### Automated Workflows\n\n- **CI** - Runs on all PRs and main branch pushes\n- **Release** - Creates GitHub releases from version tags\n- **JSR Publish** - Automatically publishes to JSR on version tags\n\nSee [RELEASE.md](docs/RELEASE.md) for the release process.\n\n## Community\n\n- [Discord Server](https://discord.gg/Jj4uWy3DGP) - Join #typescript2cxx channel\n- [Issue Tracker](https://github.com/wowemulation-dev/typescript2cxx/issues)\n- [Discussions](https://github.com/wowemulation-dev/typescript2cxx/discussions)\n\n## Related Projects\n\n- [warcraft-rs](https://github.com/wowemulation-dev/warcraft-rs) - Rust library for WoW file formats\n- [TypeScript2Cxx](https://github.com/ASDAlexander77/TypeScript2Cxx) - Original inspiration for this project\n\n## License\n\nThis project is licensed under either of\n\n- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE))\n- MIT license ([LICENSE-MIT](LICENSE-MIT))\n\nat your option.\n\n## Acknowledgments\n\n- Original TypeScript2Cxx project by ASDAlexander77\n- WoW emulation community for requirements and feedback\n- Deno team for the excellent runtime\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwowemulation-dev%2Ftypescript2cxx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwowemulation-dev%2Ftypescript2cxx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwowemulation-dev%2Ftypescript2cxx/lists"}