typenative 0.0.14 → 0.0.16

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,36 @@
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
+ # 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}}
package/CHANGELOG.md CHANGED
@@ -1,44 +1,80 @@
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.14] - 2025-05-25
9
-
10
- ### Added
11
- - Project creation with new `--new` command
12
- - Support for functions and arrow functions
13
- - Support for switch statements
14
- - If statements, while loops, and for...of loops for arrays
15
-
16
- ### Changed
17
- - Replaced shelljs dependency with execa for improved process execution
18
-
19
- ### Fixed
20
- - Project creation issues
21
-
22
- ## [0.0.12] - 2025-05-23
23
-
24
- ### Changed
25
- - Switched transpilation target to Go language
26
-
27
- ## [0.0.9] - 2024-03-01
28
-
29
- ### Added
30
- - Basic types support (number, boolean, string, null, any)
31
- - Support for variable declarations
32
- - Support for binary expressions
33
- - Arithmetic, comparison, logical, and increment/decrement operators
34
-
35
- ## [0.0.1] - 2024-02-24
36
-
37
- ### Added
38
- - Initial project setup
39
- - Basic project structure
40
-
41
- ## [0.0.0] - 2022-12-20
42
-
43
- ### Added
44
- - 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.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
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,65 +1,109 @@
1
- # TypeNative
2
-
3
- Build native applications using Typescript.
4
-
5
- ## PreRequisites
6
-
7
- - [Nodejs v20](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
- | **Variables** | | |
35
- | Variable declarations || `let` and `const` |
36
- | **Operators** | | |
37
- | Arithmetic operators | | `+`, `-`, etc. |
38
- | Comparison operators || `==`, `!=`, etc. |
39
- | Logical operators | | `&&`, `\|\|` |
40
- | Increment/Decrement | | `++`, `--` |
41
- | **Control Flow** | | |
42
- | For loops | | Standard `for` loops |
43
- | For...of loops | | Iteration over arrays |
44
- | While loops || Transpiled to Go's `for` loops |
45
- | Do...while loops | | Implemented with conditional break |
46
- | If/Else statements | | Fully supported |
47
- | Switch statements | | Case and default statements |
48
- | **Data Structures** | | |
49
- | Arrays | | Basic array operations |
50
- | Array methods | | `push` supported |
51
- | **Functions** | | |
52
- | Function declarations | | Transpiled to Go functions |
53
- | Arrow Functions | | Transpiled to anonymous functions |
54
- | console.log || Mapped to `fmt.Println` |
55
- | console.time/timeEnd | | Performance measurement |
56
- | Math.random | | Mapped to Go's `rand.Float64()` |
57
- | Math.floor | | Mapped to Go's `math.Floor()` |
58
- | **Unsupported Features** | | |
59
- | Classes | | Not implemented |
60
- | Interfaces | | Not implemented |
61
- | Async/Await | | Not implemented |
62
- | Modules/Imports || Not implemented |
63
- | Generics | | Not implemented |
64
-
65
- 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
+ - 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.