https://github.com/leaningtech/ts2cpp
A tool to generate C++ headers from TypeScript declaration files
https://github.com/leaningtech/ts2cpp
cheerp cpp typescript typescript-definitions wasm webassembly
Last synced: 8 months ago
JSON representation
A tool to generate C++ headers from TypeScript declaration files
- Host: GitHub
- URL: https://github.com/leaningtech/ts2cpp
- Owner: leaningtech
- License: apache-2.0
- Created: 2023-11-03T13:51:34.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-09-02T14:04:12.000Z (over 1 year ago)
- Last Synced: 2025-04-25T03:18:07.937Z (9 months ago)
- Topics: cheerp, cpp, typescript, typescript-definitions, wasm, webassembly
- Language: TypeScript
- Homepage:
- Size: 530 KB
- Stars: 7
- Watchers: 5
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README

A tool to generate C++ headers from typescript declaration files (.d.ts) for use with [Cheerp](https://github.com/leaningtech/cheerp-meta).
```
Usage: ts2cpp [options]
Options:
--pretty format output files
--default-lib generate headers for the default library
--out, -o path to output file
--ignore-errors ignore errors
--list-files write a list of all included .d.ts files
--verbose, -v verbose output
--verbose-progress verbose progress
--namespace wrap output in a namespace
--no-constraints do not use std::enable_if or static_asserts
--full-names always use fully qualified names
-h, --help display help for command
```
## Setup
```
git clone https://github.com/leaningtech/ts2cpp.git
cd ts2cpp
npm i && npx tsc
```
Or run with `npx`:
```
npx @leaningtech/ts2cpp --help
```
## Examples
Generating clientlib headers
```
mkdir -p cheerp
npx ts2cpp --default-lib --pretty
```
Generating headers from a custom declaration file
```
npx ts2cpp --pretty test.d.ts -o test.h
```