{"id":13669690,"url":"https://github.com/ASDAlexander77/TypeScript2Cxx","last_synced_at":"2025-04-27T08:32:49.673Z","repository":{"id":41121021,"uuid":"251032187","full_name":"ASDAlexander77/TypeScript2Cxx","owner":"ASDAlexander77","description":"TypeScript to C++","archived":false,"fork":false,"pushed_at":"2023-04-03T15:15:44.000Z","size":9124,"stargazers_count":689,"open_issues_count":7,"forks_count":39,"subscribers_count":19,"default_branch":"master","last_synced_at":"2024-11-11T07:38:40.628Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ASDAlexander77.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-03-29T12:57:08.000Z","updated_at":"2024-11-02T19:23:33.000Z","dependencies_parsed_at":"2024-01-14T14:31:03.079Z","dependency_job_id":"df2deacc-e0c0-4442-a281-2d1b0b97e381","html_url":"https://github.com/ASDAlexander77/TypeScript2Cxx","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ASDAlexander77%2FTypeScript2Cxx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ASDAlexander77%2FTypeScript2Cxx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ASDAlexander77%2FTypeScript2Cxx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ASDAlexander77%2FTypeScript2Cxx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ASDAlexander77","download_url":"https://codeload.github.com/ASDAlexander77/TypeScript2Cxx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251112597,"owners_count":21538162,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-08-02T09:00:19.345Z","updated_at":"2025-04-27T08:32:47.180Z","avatar_url":"https://github.com/ASDAlexander77.png","language":"C","readme":"TypeScript to C++\r\n===========================\r\n\r\nLicense\r\n-------\r\n\r\nTypeScript2Cxx is licensed under the MIT license.\r\n\r\nChat Room\r\n---------\r\n\r\nWant to chat with other members of the TypeScript to C++ community?\r\n\r\n[![Join the chat at https://gitter.im/ASDAlexander77/TypeScript2Cxx](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ASDAlexander77/TypeScript2Cxx?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\r\n\r\n\r\nQuick Start\r\n-----------\r\n\r\n1) Build Project\r\n\r\n```\r\nnpm install\r\nnpm run build\r\n```\r\n\r\n2) Compile test.ts\r\n\r\ncreate file test.ts\r\n\r\n```TypeScript\r\nclass Person {\r\n    protected name: string;\r\n    constructor(name: string) { this.name = name; }\r\n}\r\n\r\nclass Employee extends Person {\r\n    private department: string;\r\n\r\n    constructor(name: string, department: string) {\r\n        super(name);\r\n        this.department = department;\r\n    }\r\n\r\n    public get ElevatorPitch() {\r\n        return `Hello, my name is ${this.name} and I work in ${this.department}.`;\r\n    }\r\n}\r\n\r\nconst howard = new Employee(\"Howard\", \"Sales\");\r\nconsole.log(howard.ElevatorPitch);\r\n```\r\n\r\n```\r\nnode __out\\main.js test.ts\r\n```\r\n\r\nNow you have test.cpp and test.h\r\n\r\ntest.h:\r\n```C++\r\n#ifndef TEST_H\r\n#define TEST_H\r\n#include \"core.h\"\r\n\r\nusing namespace js;\r\n\r\nclass Person;\r\nclass Employee;\r\n\r\nclass Person : public object, public std::enable_shared_from_this\u003cPerson\u003e {\r\npublic:\r\n    string name;\r\n\r\n    Person(string name);\r\n};\r\n\r\nclass Employee : public Person, public std::enable_shared_from_this\u003cEmployee\u003e {\r\npublic:\r\n    string department;\r\n\r\n    Employee(string name, string department);\r\n    virtual any get_ElevatorPitch();\r\n    Employee(string name);\r\n};\r\n\r\nextern std::shared_ptr\u003cEmployee\u003e howard;\r\n#endif\r\n```\r\n\r\ntest.cpp:\r\n```C++\r\n#include \"test.h\"\r\n\r\nusing namespace js;\r\n\r\nPerson::Person(string name) {\r\n    this-\u003ename = name;\r\n}\r\n\r\nEmployee::Employee(string name, string department) : Person(name) {\r\n    this-\u003edepartment = department;\r\n}\r\n\r\nany Employee::get_ElevatorPitch()\r\n{\r\n    return \"Hello, my name is \"_S + this-\u003ename + \" and I work in \"_S + this-\u003edepartment + \".\"_S;\r\n}\r\n\r\nEmployee::Employee(string name) : Person(name) {\r\n}\r\n\r\nstd::shared_ptr\u003cEmployee\u003e howard = std::make_shared\u003cEmployee\u003e(\"Howard\"_S, \"Sales\"_S);\r\n\r\nvoid Main(void)\r\n{\r\n    console-\u003elog(howard-\u003eget_ElevatorPitch());\r\n}\r\n\r\nint main(int argc, char** argv)\r\n{\r\n    Main();\r\n    return 0;\r\n}\r\n```\r\n\r\n3) Compile it.\r\n\r\nVisual Studio C++\r\n\r\n```\r\ncl /W3 /GR /EHsc /std:c++20 /Fe:test.exe /I ../cpplib test.cpp\r\n```\r\n\r\nor Clang++\r\n\r\n```\r\nclang++ -std=c++20 -Wno-switch -Wno-deprecated-declarations -I../cpplib test.cpp -o test.exe\r\n```\r\n\r\n\r\n4) Run it.\r\n\r\n```\r\ntest.exe\r\n```\r\n\r\nResult:\r\n```\r\nHello, my name is Howard and I work in Sales.\r\n```\r\n\r\nEnjoy it. \r\n","funding_links":[],"categories":["C","Other Language Targets"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FASDAlexander77%2FTypeScript2Cxx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FASDAlexander77%2FTypeScript2Cxx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FASDAlexander77%2FTypeScript2Cxx/lists"}