typenative 0.0.16 → 0.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,36 +1,73 @@
1
- # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
- # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
-
4
- name: Node.js Package
5
-
6
- on:
7
- release:
8
- types: [created]
9
-
10
- jobs:
11
- build:
12
- runs-on: ubuntu-latest
13
- steps:
14
- - uses: actions/checkout@v4
15
- - uses: actions/setup-node@v4
16
- with:
17
- node-version: 20
18
- - run: npm ci
19
- - run: npm test
20
-
21
- publish-gpr:
22
- needs: build
23
- runs-on: ubuntu-latest
24
- permissions:
25
- contents: read
26
- packages: write
27
- steps:
28
- - uses: actions/checkout@v4
29
- - uses: actions/setup-node@v4
30
- with:
31
- node-version: 20
32
- registry-url: https://npm.pkg.github.com/
33
- - run: npm ci
34
- - run: npm publish
35
- env:
36
- NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
1
+ # Triggered by tags matching "TypeNative_{version}" (e.g. TypeNative_0.0.18)
2
+ # Runs tests, creates a GitHub release, and publishes to npm.
3
+ #
4
+ # Requires an NPM_TOKEN secret set in your GitHub repository settings.
5
+ # Setup: npmjs.com → Access Tokens → Generate New Token (Automation)
6
+ # GitHub repo → Settings → Secrets → Actions → New secret: NPM_TOKEN
7
+
8
+ name: Release & Publish
9
+
10
+ on:
11
+ push:
12
+ tags:
13
+ - 'TypeNative_*'
14
+
15
+ jobs:
16
+ test:
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+ - uses: actions/setup-node@v4
21
+ with:
22
+ node-version: 24
23
+ - uses: actions/setup-go@v5
24
+ with:
25
+ go-version: '1.21'
26
+ - run: npm ci
27
+ - run: npm test
28
+
29
+ release:
30
+ needs: test
31
+ runs-on: ubuntu-latest
32
+ permissions:
33
+ contents: write
34
+ steps:
35
+ - uses: actions/checkout@v4
36
+
37
+ - name: Extract version from tag
38
+ id: version
39
+ run: echo "VERSION=${GITHUB_REF_NAME#TypeNative_}" >> $GITHUB_OUTPUT
40
+
41
+ - name: Create GitHub Release
42
+ uses: softprops/action-gh-release@v2
43
+ with:
44
+ name: TypeNative v${{ steps.version.outputs.VERSION }}
45
+ tag_name: ${{ github.ref_name }}
46
+ generate_release_notes: true
47
+
48
+ publish-npm:
49
+ needs: test
50
+ runs-on: ubuntu-latest
51
+ permissions:
52
+ id-token: write # required for npm Trusted Publishing (OIDC)
53
+ contents: read
54
+ steps:
55
+ - uses: actions/checkout@v4
56
+
57
+ - uses: actions/setup-node@v4
58
+ with:
59
+ node-version: 24
60
+ registry-url: https://registry.npmjs.org/
61
+
62
+ - name: Extract version from tag
63
+ id: version
64
+ run: echo "VERSION=${GITHUB_REF_NAME#TypeNative_}" >> $GITHUB_OUTPUT
65
+
66
+ - name: Sync package.json version to tag
67
+ run: npm version ${{ steps.version.outputs.VERSION }} --no-git-tag-version --allow-same-version
68
+
69
+ - run: npm ci
70
+
71
+ - run: npm publish --provenance --access public
72
+ env:
73
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/CHANGELOG.md CHANGED
@@ -1,80 +1,109 @@
1
- # Changelog
2
-
3
- All notable changes to TypeNative will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ## [0.0.16] - 2025-02-15
9
-
10
- ### Added
11
-
12
- - RegExp support: regex literals (`/pattern/flags`), `new RegExp()`, `test()`, and `exec()` mapped to Go's `regexp` package
13
- - Universal `toString()` support for numbers, booleans, arrays, and objects
14
-
15
- ## [0.0.15] - 2025-02-15
16
-
17
- ### Added
18
-
19
- - Classes with constructors, inheritance (`extends`, `super()`), and methods transpiled to Go structs
20
- - Interfaces with method signatures and `extends` transpiled to Go interfaces
21
- - Generics support for functions and classes via Go type parameters
22
- - Async/Await transpiled to Go channels and goroutines
23
- - Promises (`new Promise`) transpiled to channel + goroutine pattern
24
- - `setTimeout` mapped to Go's `time.AfterFunc`
25
- - Nullable types (`T | null`, `T | undefined`) transpiled to Go pointer types
26
- - Object literals transpiled to Go struct literals
27
- - `assert()` function transpiled to `panic` on failure
28
- - `parseInt` and `parseFloat` mapped to Go's `strconv` package
29
- - String methods: `split`, `trim`, `trimStart`, `trimEnd`, `toUpperCase`, `toLowerCase`, `indexOf`, `includes`, `startsWith`, `endsWith`, `replace`, `replaceAll`, `repeat`, `charAt`, `substring`, `slice`, `concat`, `toString`
30
- - Array methods: `join`, `slice`, `toString` (in addition to existing `push`)
31
- - Math methods: `ceil`, `round`, `abs`, `sqrt`, `pow`, `min`, `max` (in addition to existing `random`, `floor`)
32
- - Non-null assertion operator (`!`) support
33
- - Type-aware method dispatch to prevent class methods from being intercepted as built-in string/array methods
34
- - Safe name collision avoidance for Go reserved identifiers
35
- - Automatic Go import management for `fmt`, `math`, `math/rand`, `strings`, `strconv`, `time`
36
-
37
- ## [0.0.14] - 2025-05-25
38
-
39
- ### Added
40
-
41
- - Project creation with new `--new` command
42
- - Support for functions and arrow functions
43
- - Support for switch statements
44
- - If statements, while loops, and for...of loops for arrays
45
-
46
- ### Changed
47
-
48
- - Replaced shelljs dependency with execa for improved process execution
49
-
50
- ### Fixed
51
-
52
- - Project creation issues
53
-
54
- ## [0.0.12] - 2025-05-23
55
-
56
- ### Changed
57
-
58
- - Switched transpilation target to Go language
59
-
60
- ## [0.0.9] - 2024-03-01
61
-
62
- ### Added
63
-
64
- - Basic types support (number, boolean, string, null, any)
65
- - Support for variable declarations
66
- - Support for binary expressions
67
- - Arithmetic, comparison, logical, and increment/decrement operators
68
-
69
- ## [0.0.1] - 2024-02-24
70
-
71
- ### Added
72
-
73
- - Initial project setup
74
- - Basic project structure
75
-
76
- ## [0.0.0] - 2022-12-20
77
-
78
- ### Added
79
-
80
- - Initial commit
1
+ # Changelog
2
+
3
+ All notable changes to TypeNative will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.0.18] - 2026-03-03
9
+
10
+ ### Added
11
+
12
+ - `Map<K, V>` support: transpiled to Go `map[K]V`; `.set()`, `.get()`, `.has()`, `.delete()`, `.clear()`, `.size` fully supported
13
+ - `Set<T>` support: transpiled to Go `map[T]struct{}`; `.add()`, `.has()`, `.delete()`, `.clear()`, `.size` fully supported
14
+ - Try/Catch/Finally support: `try/catch/finally` transpiled to Go IIFE with `defer`/`recover` pattern
15
+ - `throw new Error("msg")` transpiled to `panic("msg")`; bare `throw expr` transpiled to `panic(expr)`
16
+ - `Error` type added to `typenative.d.ts` for IDE type checking in test files
17
+ - Closures over mutable state: functions can now capture and mutate variables from outer scopes
18
+ - Function type annotations: `() => number`, `(x: number) => string`, etc. transpiled to Go `func(...)` types
19
+ - Return type inference for functions and arrow functions: when no explicit return type annotation is present, the transpiler infers the return type from `return` statements
20
+ - Expression-body arrow functions now correctly wrap the result as `{ return expr; }` in Go
21
+
22
+ ## [0.0.17] - 2026-02-16
23
+
24
+ ### Added
25
+
26
+ - Support for ternary expressions (`condition ? a : b`)
27
+ - Support for optional chaining (`obj?.prop`, `arr?.[i]`)
28
+ - Support for nullish coalescing (`??` operator)
29
+ - Support for type aliases (`type X = ...`)
30
+ - Support for type assertions (`expr as Type`)
31
+ - Support for optional properties (`prop?: Type` in interfaces/types)
32
+ - Support for default parameter values (e.g. `function(x = defaultValue)`)
33
+ - Support for enum declarations and member access (`enum X { ... }`, `X.Member`)
34
+ - Support for array methods: `map`, `filter`, `some`, `find`
35
+ - Support for chaining array methods (e.g. `arr.map(...).filter(...).join(...)`)
36
+
37
+ ## [0.0.16] - 2025-02-15
38
+
39
+ ### Added
40
+
41
+ - RegExp support: regex literals (`/pattern/flags`), `new RegExp()`, `test()`, and `exec()` mapped to Go's `regexp` package
42
+ - Universal `toString()` support for numbers, booleans, arrays, and objects
43
+
44
+ ## [0.0.15] - 2025-02-15
45
+
46
+ ### Added
47
+
48
+ - Classes with constructors, inheritance (`extends`, `super()`), and methods transpiled to Go structs
49
+ - Interfaces with method signatures and `extends` transpiled to Go interfaces
50
+ - Generics support for functions and classes via Go type parameters
51
+ - Async/Await transpiled to Go channels and goroutines
52
+ - Promises (`new Promise`) transpiled to channel + goroutine pattern
53
+ - `setTimeout` mapped to Go's `time.AfterFunc`
54
+ - Nullable types (`T | null`, `T | undefined`) transpiled to Go pointer types
55
+ - Object literals transpiled to Go struct literals
56
+ - `assert()` function transpiled to `panic` on failure
57
+ - `parseInt` and `parseFloat` mapped to Go's `strconv` package
58
+ - String methods: `split`, `trim`, `trimStart`, `trimEnd`, `toUpperCase`, `toLowerCase`, `indexOf`, `includes`, `startsWith`, `endsWith`, `replace`, `replaceAll`, `repeat`, `charAt`, `substring`, `slice`, `concat`, `toString`
59
+ - Array methods: `join`, `slice`, `toString` (in addition to existing `push`)
60
+ - Math methods: `ceil`, `round`, `abs`, `sqrt`, `pow`, `min`, `max` (in addition to existing `random`, `floor`)
61
+ - Non-null assertion operator (`!`) support
62
+ - Type-aware method dispatch to prevent class methods from being intercepted as built-in string/array methods
63
+ - Safe name collision avoidance for Go reserved identifiers
64
+ - Automatic Go import management for `fmt`, `math`, `math/rand`, `strings`, `strconv`, `time`
65
+
66
+ ## [0.0.14] - 2025-05-25
67
+
68
+ ### Added
69
+
70
+ - Project creation with new `--new` command
71
+ - Support for functions and arrow functions
72
+ - Support for switch statements
73
+ - If statements, while loops, and for...of loops for arrays
74
+
75
+ ### Changed
76
+
77
+ - Replaced shelljs dependency with execa for improved process execution
78
+
79
+ ### Fixed
80
+
81
+ - Project creation issues
82
+
83
+ ## [0.0.12] - 2025-05-23
84
+
85
+ ### Changed
86
+
87
+ - Switched transpilation target to Go language
88
+
89
+ ## [0.0.9] - 2024-03-01
90
+
91
+ ### Added
92
+
93
+ - Basic types support (number, boolean, string, null, any)
94
+ - Support for variable declarations
95
+ - Support for binary expressions
96
+ - Arithmetic, comparison, logical, and increment/decrement operators
97
+
98
+ ## [0.0.1] - 2024-02-24
99
+
100
+ ### Added
101
+
102
+ - Initial project setup
103
+ - Basic project structure
104
+
105
+ ## [0.0.0] - 2022-12-20
106
+
107
+ ### Added
108
+
109
+ - Initial commit
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 danisss9
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 danisss9
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,109 +1,154 @@
1
- # TypeNative
2
-
3
- Build native applications using Typescript.
4
-
5
- ## PreRequisites
6
-
7
- - [Nodejs v24](https://nodejs.org/en) or newer.
8
- - [Go 1.21](https://go.dev/doc/install) or newer.
9
-
10
- ## Get Started
11
-
12
- - Write a file `test.ts` with content `console.log('Hello World!');` or any other message
13
- - Run `npx typenative --source test.ts --script`
14
- - See your message in the terminal
15
-
16
- ## Create a TypeNative Project
17
-
18
- - Run `npx typenative --new`
19
- - Give your project a name
20
- - Start writing code
21
-
22
- ## Typescript Syntax Support
23
-
24
- TypeNative currently supports a subset of TypeScript syntax elements that are transpiled to Go code:
25
-
26
- | Feature | Supported | Notes |
27
- | --------------------------- | :-------: | ----------------------------------------------------------------- |
28
- | **Basic Types** | | |
29
- | number | ✅ | Transpiled to `float64` |
30
- | boolean | ✅ | Transpiled to `bool` |
31
- | string | ✅ | |
32
- | null || |
33
- | any | ✅ | Used for type inference |
34
- | Nullable types | ✅ | `T \| null` / `T \| undefined` transpiled to Go pointer types |
35
- | **Variables** | | |
36
- | Variable declarations | ✅ | `let` and `const` |
37
- | Object literals | ✅ | Transpiled to Go struct literals |
38
- | **Operators** | | |
39
- | Arithmetic operators | ✅ | `+`, `-`, etc. |
40
- | Comparison operators | ✅ | `==`, `!=`, `===`, `!==`, etc. |
41
- | Logical operators | ✅ | `&&`, `\|\|` |
42
- | Increment/Decrement | ✅ | `++`, `--` |
43
- | Non-null assertion (`!`) | ✅ | Stripped during transpilation |
44
- | **Control Flow** | | |
45
- | For loops | ✅ | Standard `for` loops |
46
- | For...of loops | ✅ | Iteration over arrays |
47
- | While loops | ✅ | Transpiled to Go's `for` loops |
48
- | Do...while loops | ✅ | Implemented with conditional break |
49
- | If/Else statements | ✅ | Fully supported |
50
- | Switch statements | ✅ | Case and default statements |
51
- | **Data Structures** | | |
52
- | Arrays | ✅ | Basic array operations |
53
- | Array methods | ✅ | `push`, `join`, `slice`, `toString` |
54
- | **Functions** | | |
55
- | Function declarations | ✅ | Transpiled to Go functions |
56
- | Arrow functions | ✅ | Transpiled to anonymous functions |
57
- | **Classes & Interfaces** | | |
58
- | Classes | ✅ | Transpiled to Go structs with constructor and receiver methods |
59
- | Class inheritance | ✅ | `extends` via embedded structs, `super()` supported |
60
- | Interfaces | ✅ | Transpiled to Go interfaces, supports `extends` |
61
- | Generics | ✅ | Type parameters on functions and classes via Go generics |
62
- | **Async** | | |
63
- | Async/Await | ✅ | `async` functions return Go channels, `await` reads from channels |
64
- | Promises | ✅ | `new Promise` transpiled to channel + goroutine pattern |
65
- | setTimeout | ✅ | Mapped to Go's `time.AfterFunc` |
66
- | **Built-in Functions** | | |
67
- | console.log | ✅ | Mapped to `fmt.Println` |
68
- | console.time/timeEnd | ✅ | Performance measurement via `time.Now` / `time.Since` |
69
- | assert | ✅ | Transpiled to `panic` on failure |
70
- | parseInt / parseFloat | ✅ | Mapped to Go's `strconv` package |
71
- | **Math Methods** | | |
72
- | Math.random | ✅ | Mapped to `rand.Float64()` |
73
- | Math.floor / ceil / round | ✅ | Mapped to `math.Floor`, `math.Ceil`, `math.Round` |
74
- | Math.abs / sqrt / pow | ✅ | Mapped to corresponding `math` functions |
75
- | Math.min / max | ✅ | Mapped to `math.Min`, `math.Max` |
76
- | **String Methods** | | |
77
- | toUpperCase / toLowerCase | ✅ | Via `strings` package |
78
- | trim / trimStart / trimEnd | ✅ | Via `strings` package |
79
- | split / includes / indexOf | ✅ | Via `strings` package |
80
- | startsWith / endsWith | ✅ | Via `strings` package |
81
- | replace / replaceAll | ✅ | Via `strings` package |
82
- | charAt / substring / slice | ✅ | Direct Go string indexing/slicing |
83
- | concat / repeat / toString | ✅ | String concatenation and `strings.Repeat` |
84
- | **Number / Object Methods** | | |
85
- | toString | ✅ | Universal `toString()` via `fmt.Sprintf` for any type |
86
- | **RegExp** | | |
87
- | Regex literals | ✅ | `/pattern/flags` transpiled to `regexp.MustCompile` |
88
- | new RegExp() | ✅ | Constructor with optional flags |
89
- | test() | ✅ | Mapped to `regexp.MatchString` |
90
- | exec() | ✅ | Mapped to `regexp.FindStringSubmatch` |
91
- | **Unsupported Features** | | |
92
- | Modules/Imports | | `import` / `export` declarations |
93
- | Try/Catch | ❌ | Error handling |
94
- | Template literals | ❌ | Backtick strings with `${expr}` interpolation |
95
- | Ternary expressions | ❌ | `condition ? a : b` |
96
- | Optional chaining | ❌ | `obj?.prop`, `arr?.[i]` |
97
- | Nullish coalescing || `??` operator |
98
- | Spread operator | | `[...iterable]`, `{...obj}` |
99
- | Type aliases | | `type X = ...` |
100
- | Type assertions | | `expr as Type` |
101
- | Optional properties | ❌ | `prop?: Type` in interfaces/types |
102
- | Default parameter values | ❌ | `function(x = defaultValue)` |
103
- | Map / Set | ❌ | Built-in collection types and their methods |
104
- | Higher-order array methods | ❌ | `.map()`, `.filter()`, `.some()`, `.find()` with callbacks |
105
- | Method chaining || `arr.map(...).filter(...).join(...)` |
106
- | Enums | | `enum` declarations and member access |
107
- | Closures over mutable state | | Functions capturing and mutating outer variables |
108
-
109
- TypeNative is currently in early development and new features are being added regularly.
1
+ # TypeNative
2
+
3
+ Build native applications using Typescript.
4
+
5
+ ## PreRequisites
6
+
7
+ - [Nodejs v24](https://nodejs.org/en) or newer.
8
+ - [Go 1.21](https://go.dev/doc/install) or newer.
9
+
10
+ ## Get Started
11
+
12
+ - Write a file `test.ts` with content `console.log('Hello World!');` or any other message
13
+ - Run `npx typenative --source test.ts --script`
14
+
15
+ ## Typescript Syntax Support
16
+
17
+ TypeNative currently supports a focused subset of TypeScript syntax elements that are transpiled to Go code. The support is grouped by topic for easier scanning.
18
+
19
+ **Basic Types**
20
+
21
+ | Feature | Supported | Notes |
22
+ | -------------- | :-------: | ------------------------------------------------------------- |
23
+ | number | ✅ | Transpiled to `float64` |
24
+ | boolean | ✅ | Transpiled to `bool` |
25
+ | string | ✅ | |
26
+ | null || |
27
+ | any | ✅ | Used for type inference |
28
+ | Nullable types || `T \| null` / `T \| undefined` transpiled to Go pointer types |
29
+
30
+ **Variables & Objects**
31
+
32
+ | Feature | Supported | Notes |
33
+ | --------------------- | :-------: | -------------------------------- |
34
+ | Variable declarations | ✅ | `let` and `const` |
35
+ | Object literals || Transpiled to Go struct literals |
36
+
37
+ **Operators**
38
+
39
+ | Feature | Supported | Notes |
40
+ | ------------------------ | :-------: | ------------------------------ |
41
+ | Arithmetic operators | ✅ | `+`, `-`, etc. |
42
+ | Comparison operators | ✅ | `==`, `!=`, `===`, `!==`, etc. |
43
+ | Logical operators | ✅ | `&&`, `\|\|` |
44
+ | Increment/Decrement || `++`, `--` |
45
+ | Non-null assertion (`!`) | ✅ | Stripped during transpilation |
46
+ | Ternary expressions | ✅ | `condition ? a : b` |
47
+ | Nullish coalescing | ✅ | `??` operator |
48
+ | Optional chaining | ✅ | `obj?.prop`, `arr?.[i]` |
49
+
50
+ **Control Flow**
51
+
52
+ | Feature | Supported | Notes |
53
+ | ------------------ | :-------: | ---------------------------------- |
54
+ | If/Else statements || Fully supported |
55
+ | Switch statements | ✅ | Case and default statements |
56
+ | For loops | ✅ | Standard `for` loops |
57
+ | For...of loops | | Iteration over arrays |
58
+ | While loops | ✅ | Transpiled to Go's `for` loops |
59
+ | Do...while loops | ✅ | Implemented with conditional break |
60
+ | Try/Catch/Finally | ✅ | `throw` `panic`; catch/finally via `defer`/`recover` |
61
+
62
+ **Data Structures & Array Methods**
63
+
64
+ | Feature | Supported | Notes |
65
+ | -------------------------- | :-------: | ---------------------------------------------------------------- |
66
+ | Arrays || Basic array operations |
67
+ | Array methods | ✅ | `push`, `join`, `slice` |
68
+ | Higher-order array methods | ✅ | `.map()`, `.filter()`, `.some()`, `.find()` |
69
+ | Method chaining | ✅ | Chaining array methods such as `.map(...).filter(...).join(...)` |
70
+ | Map | ✅ | `Map<K, V>` Go `map[K]V`; `.set()`, `.get()`, `.has()`, `.delete()`, `.clear()`, `.size` |
71
+ | Set || `Set<T>` → Go `map[T]struct{}`; `.add()`, `.has()`, `.delete()`, `.clear()`, `.size` |
72
+
73
+ **Functions**
74
+
75
+ | Feature | Supported | Notes |
76
+ | ---------------------------- | :-------: | ------------------------------------------------------------ |
77
+ | Function declarations | ✅ | Transpiled to Go functions |
78
+ | Arrow functions | ✅ | Transpiled to anonymous functions |
79
+ | Closures over mutable state | ✅ | Functions capturing and mutating outer variables |
80
+ | Function types | ✅ | `() => number`, `(x: number) => string` as type annotations |
81
+ | Generics (functions/classes) | ✅ | Type parameters via Go generics |
82
+ | Default parameter values | ✅ | `function(x = defaultValue)` |
83
+
84
+ **Classes & Interfaces**
85
+
86
+ | Feature | Supported | Notes |
87
+ | ------------------- | :-------: | -------------------------------------------------------------- |
88
+ | Classes | ✅ | Transpiled to Go structs with constructor and receiver methods |
89
+ | Class inheritance | ✅ | `extends` via embedded structs, `super()` supported |
90
+ | Interfaces | ✅ | Transpiled to Go interfaces, supports `extends` |
91
+ | Optional properties | | `prop?: Type` in interfaces/types |
92
+ | Enums | | `enum` declarations and member access |
93
+
94
+ **Async & Timing**
95
+
96
+ | Feature | Supported | Notes |
97
+ | ----------- | :-------: | ----------------------------------------------------------------- |
98
+ | Async/Await | | `async` functions return Go channels, `await` reads from channels |
99
+ | Promises | | `new Promise` transpiled to channel + goroutine pattern |
100
+ | setTimeout | | Mapped to Go's `time.AfterFunc` |
101
+
102
+ **Built-in Functions & Utilities**
103
+
104
+ | Feature | Supported | Notes |
105
+ | --------------------- | :-------: | ----------------------------------------------------- |
106
+ | console.log | | Mapped to `fmt.Println` |
107
+ | console.time/timeEnd | | Performance measurement via `time.Now` / `time.Since` |
108
+ | assert | ✅ | Transpiled to `panic` on failure |
109
+ | parseInt / parseFloat | ✅ | Mapped to Go's `strconv` package |
110
+
111
+ **Math Methods**
112
+
113
+ | Feature | Supported | Notes |
114
+ | ------------------------- | :-------: | ------------------------------------------------- |
115
+ | Math.random | ✅ | Mapped to `rand.Float64()` |
116
+ | Math.floor / ceil / round | ✅ | Mapped to `math.Floor`, `math.Ceil`, `math.Round` |
117
+ | Math.abs / sqrt / pow | ✅ | Mapped to corresponding `math` functions |
118
+ | Math.min / max | ✅ | Mapped to `math.Min`, `math.Max` |
119
+
120
+ **String Methods**
121
+
122
+ | Feature | Supported | Notes |
123
+ | -------------------------- | :-------: | --------------------------------------------- |
124
+ | Template literals | ✅ | Backtick strings with `${expr}` interpolation |
125
+ | toUpperCase / toLowerCase | ✅ | Via `strings` package |
126
+ | trim / trimStart / trimEnd | ✅ | Via `strings` package |
127
+ | split / includes / indexOf | ✅ | Via `strings` package |
128
+ | startsWith / endsWith | ✅ | Via `strings` package |
129
+ | replace / replaceAll | ✅ | Via `strings` package |
130
+ | charAt / substring / slice | ✅ | Direct Go string indexing/slicing |
131
+ | concat / repeat | ✅ | String concatenation and `strings.Repeat` |
132
+
133
+ **Number / Object Methods**
134
+
135
+ | Feature | Supported | Notes |
136
+ | -------- | :-------: | ----------------------------------------------------- |
137
+ | toString | ✅ | Universal `toString()` via `fmt.Sprintf` for any type |
138
+
139
+ **RegExp**
140
+
141
+ | Feature | Supported | Notes |
142
+ | -------------- | :-------: | --------------------------------------------------- |
143
+ | Regex literals | ✅ | `/pattern/flags` transpiled to `regexp.MustCompile` |
144
+ | new RegExp() | ✅ | Constructor with optional flags |
145
+ | test() | ✅ | Mapped to `regexp.MatchString` |
146
+ | exec() | ✅ | Mapped to `regexp.FindStringSubmatch` |
147
+
148
+ **Unsupported / Roadmap**
149
+
150
+ | Feature | Supported | Notes |
151
+ | --------------- | :-------: | -------------------------------- |
152
+ | Modules/Imports | ❌ | `import` / `export` declarations |
153
+
154
+ TypeNative is currently in early development and new features are being added regularly. The goal for `1.0` release is for TypeNative to transpile itself.