typenative 0.0.17 → 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.
- package/.github/workflows/npm-publish-github-packages.yml +73 -36
- package/CHANGELOG.md +109 -95
- package/LICENSE +21 -21
- package/README.md +154 -152
- package/bin/index.js +133 -126
- package/bin/transpiler.js +258 -15
- package/package.json +63 -59
- package/types/typenative.d.ts +247 -193
|
@@ -1,36 +1,73 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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,95 +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.
|
|
9
|
-
|
|
10
|
-
### Added
|
|
11
|
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
-
|
|
42
|
-
- `
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
-
|
|
49
|
-
-
|
|
50
|
-
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
-
|
|
57
|
-
-
|
|
58
|
-
-
|
|
59
|
-
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
-
|
|
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.
|