Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ jobs:
run: npm run test-ci
- name: Integration test
run: npm run integration
- name: Generate supported.md
run: npm run generate-supported
- name: Generating coverage badges
if: github.ref == 'refs/heads/master'
uses: jpb06/jest-badges-action@latest
Expand All @@ -48,5 +50,7 @@ jobs:
# if: github.ref == 'refs/heads/master'
# uses: EndBug/add-and-commit@v9 # You can change this to use a specific version.
# with:
# add: "dist/ -f"
# message: "Update generated files"
# add: |
# dist/ -f
# README.md
# message: 'Update generated files'
74 changes: 74 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,80 @@ function printOutOfOrderCallExpressionIfAny(node, identation) {
transpiler.pythonTranspiler.printOutOfOrderCallExpressionIfAny = printOutOfOrderCallExpressionIfAny;
```


<!-- START_SUPPORTED_LIST -->
<!--
AUTO-GENERATED SECTION - DO NOT EDIT MANUALLY.
Generated by `src/generate-supported-md.ts` (runs in CI on every push).
To update, modify the transpiler source and re-run the generator.
-->

## 📚 Supported Methods & Operators

Below is a detailed reference of the TypeScript constructs that the transpiler is able to convert
(derived from `src/baseTranspiler.ts` and the language specific transpilers).

### Operators

`!==`, `!=`, `!`, `%`, `&&`, `*`, `++`, `+=`, `+`, `--`, `-`, `/`, `<=`, `<`, `===`, `==`, `=`, `>=`, `>`, `in`, `||`

### Keywords / Modifiers

`async`, `await`, `boolean`, `number`, `private`, `public`, `static`, `string`, `void`

### Built-in Global Functions

These global calls are recognized and converted to each target language:

- `Array.isArray`
- `Date.now`
- `JSON.parse`
- `JSON.stringify`
- `Math.ceil`
- `Math.floor`
- `Math.round`
- `Number.isInteger`
- `Object.keys`
- `Object.values`
- `Promise.all`

### Built-in Instance Methods (string / array / object)

These instance methods are recognized and converted to each target language:

- `concat`
- `endsWith`
- `includes`
- `indexOf`
- `join`
- `padEnd`
- `padStart`
- `pop`
- `push`
- `replace`
- `replaceAll`
- `reverse`
- `search`
- `shift`
- `slice`
- `split`
- `startsWith`
- `toFixed`
- `toLowerCase`
- `toString`
- `toUpperCase`
- `trim`

## Per-language Conversions
Conversions of global calls and string/array methods are also detailed. Explicit replacements are documented in [language-conversions.md](./language-conversions.md).

> ⚠️ Many of these conversions rely on type information. Make sure to annotate
> types (especially function arguments) so the transpiler can disambiguate
> (e.g. `.length` → `len`/`count`, `+` → string concat vs numeric addition).

<!-- END_SUPPORTED_LIST -->


## Contributing

Pull requests are welcome. For major changes, please open an issue first
Expand Down
123 changes: 123 additions & 0 deletions language-conversions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<!--
AUTO-GENERATED FILE - DO NOT EDIT MANUALLY.
Generated by `src/generate-supported-md.ts` (runs in CI on every push).
To update, modify the transpiler source and re-run the generator.
-->

# 🌐 Per-language Conversions

This document is automatically generated from the transpiler source code.
It lists the explicit property replacements, call expression replacements and method conversions mapped to each target language.

## Python

| TypeScript | Python |
| --- | --- |
| `console.log` | `print` |
| `JSON.stringify` | `json.dumps` |
| `JSON.parse` | `json.loads` |
| `Math.log` | `math.log` |
| `Math.abs` | `abs` |
| `Math.min` | `min` |
| `Math.max` | `max` |
| `Math.ceil` | `math.ceil` |
| `Math.round` | `math.round` |
| `Math.floor` | `math.floor` |
| `Math.pow` | `math.pow` |
| `process.exit` | `sys.exit` |
| `Number.MAX_SAFE_INTEGER` | `float(\'inf\')` |
| `x.push(...)` | `x.append(...)` |
| `x.toUpperCase(...)` | `x.upper(...)` |
| `x.toLowerCase(...)` | `x.lower(...)` |
| `x.parseFloat(...)` | `x.float(...)` |
| `x.parseInt(...)` | `x.int(...)` |
| `x.indexOf(...)` | `x.find(...)` |
| `x.padEnd(...)` | `x.ljust(...)` |
| `x.padStart(...)` | `x.rjust(...)` |
| `parseInt(...)` | `int(...)` |
| `parseFloat(...)` | `float(...)` |

## PHP

| TypeScript | PHP |
| --- | --- |
| `Number.MAX_SAFE_INTEGER` | `PHP_INT_MAX` |
| `JSON.stringify` | `json_encode` |
| `console.log` | `var_dump` |
| `process.exit` | `exit` |
| `Math.log` | `log` |
| `Math.abs` | `abs` |
| `Math.floor` | `(int) floor` |
| `Math.ceil` | `(int) ceil` |
| `Math.round` | `(int) round` |
| `Math.pow` | `pow` |
| `Math.min` | `min` |
| `Math.max` | `max` |
| `Promise.all` | `\\React\\Promise\\all` |
| `parseFloat(...)` | `floatval(...)` |
| `parseInt(...)` | `intval(...)` |

## C#

| TypeScript | C# |
| --- | --- |
| `JSON.parse` | `parseJson` |
| `console.log` | `Console.WriteLine` |
| `Number.MAX_SAFE_INTEGER` | `Int32.MaxValue` |
| `Math.min` | `Math.Min` |
| `Math.max` | `Math.Max` |
| `Math.log` | `Math.Log` |
| `Math.abs` | `Math.Abs` |
| `Math.ceil` | `Math.Ceiling` |
| `Math.round` | `Math.Round` |
| `Math.floor` | `Math.Floor` |
| `Math.pow` | `Math.Pow` |
| `Promise.all` | `Task.WhenAll` |
| `x.push(...)` | `x.Add(...)` |
| `x.indexOf(...)` | `x.IndexOf(...)` |
| `x.toUpperCase(...)` | `x.ToUpper(...)` |
| `x.toLowerCase(...)` | `x.ToLower(...)` |
| `x.toString(...)` | `x.ToString(...)` |
| `parseInt(...)` | `parseINt(...)` |
| `parseFloat(...)` | `float.Parse(...)` |

## Go

| TypeScript | Go |
| --- | --- |
| `JSON.parse` | `parseJson` |
| `console.log` | `fmt.Println` |
| `Number.MAX_SAFE_INTEGER` | `Int32.MaxValue` |
| `Math.min` | `Math.Min` |
| `Math.max` | `Math.Max` |
| `Math.log` | `Math.Log` |
| `Math.abs` | `Math.Abs` |
| `Math.ceil` | `Math.Ceiling` |
| `Math.round` | `Math.Round` |
| `Math.floor` | `Math.Floor` |
| `Math.pow` | `Math.Pow` |
| `Promise.all` | `Task.WhenAll` |
| `x.push(...)` | `x.Add(...)` |
| `x.indexOf(...)` | `x.IndexOf(...)` |
| `x.toUpperCase(...)` | `x.ToUpper(...)` |
| `x.toLowerCase(...)` | `x.ToLower(...)` |
| `x.toString(...)` | `x.ToString(...)` |
| `parseInt(...)` | `parseINt(...)` |
| `parseFloat(...)` | `float.Parse(...)` |

## Java

| TypeScript | Java |
| --- | --- |
| `JSON.parse` | `parseJson` |
| `console.log` | `System.out.println` |
| `Number.MAX_SAFE_INTEGER` | `Long.MAX_VALUE` |
| `Math.min` | `Math.min` |
| `Math.max` | `Math.max` |
| `Math.log` | `Math.log` |
| `Math.abs` | `Math.abs` |
| `Math.floor` | `Math.floor` |
| `Math.pow` | `Math.pow` |
| `parseInt(...)` | `Helpers.parseInt(...)` |
| `parseFloat(...)` | `Helpers.parseFloat(...)` |

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"testv": "jest --verbose --coverage",
"integration": "tsx tests/integration/test.ts",
"lint": "eslint src/ --ext .ts",
"generate-supported": "node src/generate-supported-md.ts",
"publishPackage": "npm run build && sh publish.sh && git push && git push --tags && npm publish"
},
"devDependencies": {
Expand Down
Loading
Loading