typenative 0.0.17 → 0.0.19

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,75 @@
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 ci
28
+ working-directory: test
29
+ - run: npm test
30
+
31
+ release:
32
+ needs: test
33
+ runs-on: ubuntu-latest
34
+ permissions:
35
+ contents: write
36
+ steps:
37
+ - uses: actions/checkout@v4
38
+
39
+ - name: Extract version from tag
40
+ id: version
41
+ run: echo "VERSION=${GITHUB_REF_NAME#TypeNative_}" >> $GITHUB_OUTPUT
42
+
43
+ - name: Create GitHub Release
44
+ uses: softprops/action-gh-release@v2
45
+ with:
46
+ name: TypeNative v${{ steps.version.outputs.VERSION }}
47
+ tag_name: ${{ github.ref_name }}
48
+ generate_release_notes: true
49
+
50
+ publish-npm:
51
+ needs: test
52
+ runs-on: ubuntu-latest
53
+ permissions:
54
+ id-token: write # required for npm Trusted Publishing (OIDC)
55
+ contents: read
56
+ steps:
57
+ - uses: actions/checkout@v4
58
+
59
+ - uses: actions/setup-node@v4
60
+ with:
61
+ node-version: 24
62
+ registry-url: https://registry.npmjs.org/
63
+
64
+ - name: Extract version from tag
65
+ id: version
66
+ run: echo "VERSION=${GITHUB_REF_NAME#TypeNative_}" >> $GITHUB_OUTPUT
67
+
68
+ - name: Sync package.json version to tag
69
+ run: npm version ${{ steps.version.outputs.VERSION }} --no-git-tag-version --allow-same-version
70
+
71
+ - run: npm ci
72
+
73
+ - run: npm publish --provenance --access public
74
+ env:
75
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/CHANGELOG.md CHANGED
@@ -1,95 +1,119 @@
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.17] - 2026-02-16
9
-
10
- ### Added
11
-
12
- - Support for ternary expressions (`condition ? a : b`)
13
- - Support for optional chaining (`obj?.prop`, `arr?.[i]`)
14
- - Support for nullish coalescing (`??` operator)
15
- - Support for type aliases (`type X = ...`)
16
- - Support for type assertions (`expr as Type`)
17
- - Support for optional properties (`prop?: Type` in interfaces/types)
18
- - Support for default parameter values (e.g. `function(x = defaultValue)`)
19
- - Support for enum declarations and member access (`enum X { ... }`, `X.Member`)
20
- - Support for array methods: `map`, `filter`, `some`, `find`
21
- - Support for chaining array methods (e.g. `arr.map(...).filter(...).join(...)`)
22
-
23
- ## [0.0.16] - 2025-02-15
24
-
25
- ### Added
26
-
27
- - RegExp support: regex literals (`/pattern/flags`), `new RegExp()`, `test()`, and `exec()` mapped to Go's `regexp` package
28
- - Universal `toString()` support for numbers, booleans, arrays, and objects
29
-
30
- ## [0.0.15] - 2025-02-15
31
-
32
- ### Added
33
-
34
- - Classes with constructors, inheritance (`extends`, `super()`), and methods transpiled to Go structs
35
- - Interfaces with method signatures and `extends` transpiled to Go interfaces
36
- - Generics support for functions and classes via Go type parameters
37
- - Async/Await transpiled to Go channels and goroutines
38
- - Promises (`new Promise`) transpiled to channel + goroutine pattern
39
- - `setTimeout` mapped to Go's `time.AfterFunc`
40
- - Nullable types (`T | null`, `T | undefined`) transpiled to Go pointer types
41
- - Object literals transpiled to Go struct literals
42
- - `assert()` function transpiled to `panic` on failure
43
- - `parseInt` and `parseFloat` mapped to Go's `strconv` package
44
- - String methods: `split`, `trim`, `trimStart`, `trimEnd`, `toUpperCase`, `toLowerCase`, `indexOf`, `includes`, `startsWith`, `endsWith`, `replace`, `replaceAll`, `repeat`, `charAt`, `substring`, `slice`, `concat`, `toString`
45
- - Array methods: `join`, `slice`, `toString` (in addition to existing `push`)
46
- - Math methods: `ceil`, `round`, `abs`, `sqrt`, `pow`, `min`, `max` (in addition to existing `random`, `floor`)
47
- - Non-null assertion operator (`!`) support
48
- - Type-aware method dispatch to prevent class methods from being intercepted as built-in string/array methods
49
- - Safe name collision avoidance for Go reserved identifiers
50
- - Automatic Go import management for `fmt`, `math`, `math/rand`, `strings`, `strconv`, `time`
51
-
52
- ## [0.0.14] - 2025-05-25
53
-
54
- ### Added
55
-
56
- - Project creation with new `--new` command
57
- - Support for functions and arrow functions
58
- - Support for switch statements
59
- - If statements, while loops, and for...of loops for arrays
60
-
61
- ### Changed
62
-
63
- - Replaced shelljs dependency with execa for improved process execution
64
-
65
- ### Fixed
66
-
67
- - Project creation issues
68
-
69
- ## [0.0.12] - 2025-05-23
70
-
71
- ### Changed
72
-
73
- - Switched transpilation target to Go language
74
-
75
- ## [0.0.9] - 2024-03-01
76
-
77
- ### Added
78
-
79
- - Basic types support (number, boolean, string, null, any)
80
- - Support for variable declarations
81
- - Support for binary expressions
82
- - Arithmetic, comparison, logical, and increment/decrement operators
83
-
84
- ## [0.0.1] - 2024-02-24
85
-
86
- ### Added
87
-
88
- - Initial project setup
89
- - Basic project structure
90
-
91
- ## [0.0.0] - 2022-12-20
92
-
93
- ### Added
94
-
95
- - 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.19] - 2026-03-07
9
+
10
+ ### Added
11
+
12
+ - Module/import support: `import { x } from './file'` transpiled to Go package imports for local TypeScript files
13
+ - Node.js built-in module imports: `import { join } from 'node:path'` and similar mapped to corresponding Go standard library packages
14
+ - npm package imports: `import { x } from 'pkg'` mapped to Go module imports via `typenative-npm.d.ts` type definitions
15
+ - Go package imports: `import { x } from 'go:package'` to import a Go library package
16
+ - Named exports: `export function` and `export const` declarations now transpiled correctly
17
+
18
+ ## [0.0.18] - 2026-03-03
19
+
20
+ ### Added
21
+
22
+ - `Map<K, V>` support: transpiled to Go `map[K]V`; `.set()`, `.get()`, `.has()`, `.delete()`, `.clear()`, `.size` fully supported
23
+ - `Set<T>` support: transpiled to Go `map[T]struct{}`; `.add()`, `.has()`, `.delete()`, `.clear()`, `.size` fully supported
24
+ - Try/Catch/Finally support: `try/catch/finally` transpiled to Go IIFE with `defer`/`recover` pattern
25
+ - `throw new Error("msg")` transpiled to `panic("msg")`; bare `throw expr` transpiled to `panic(expr)`
26
+ - `Error` type added to `typenative.d.ts` for IDE type checking in test files
27
+ - Closures over mutable state: functions can now capture and mutate variables from outer scopes
28
+ - Function type annotations: `() => number`, `(x: number) => string`, etc. transpiled to Go `func(...)` types
29
+ - 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
30
+ - Expression-body arrow functions now correctly wrap the result as `{ return expr; }` in Go
31
+
32
+ ## [0.0.17] - 2026-02-16
33
+
34
+ ### Added
35
+
36
+ - Support for ternary expressions (`condition ? a : b`)
37
+ - Support for optional chaining (`obj?.prop`, `arr?.[i]`)
38
+ - Support for nullish coalescing (`??` operator)
39
+ - Support for type aliases (`type X = ...`)
40
+ - Support for type assertions (`expr as Type`)
41
+ - Support for optional properties (`prop?: Type` in interfaces/types)
42
+ - Support for default parameter values (e.g. `function(x = defaultValue)`)
43
+ - Support for enum declarations and member access (`enum X { ... }`, `X.Member`)
44
+ - Support for array methods: `map`, `filter`, `some`, `find`
45
+ - Support for chaining array methods (e.g. `arr.map(...).filter(...).join(...)`)
46
+
47
+ ## [0.0.16] - 2025-02-15
48
+
49
+ ### Added
50
+
51
+ - RegExp support: regex literals (`/pattern/flags`), `new RegExp()`, `test()`, and `exec()` mapped to Go's `regexp` package
52
+ - Universal `toString()` support for numbers, booleans, arrays, and objects
53
+
54
+ ## [0.0.15] - 2025-02-15
55
+
56
+ ### Added
57
+
58
+ - Classes with constructors, inheritance (`extends`, `super()`), and methods transpiled to Go structs
59
+ - Interfaces with method signatures and `extends` transpiled to Go interfaces
60
+ - Generics support for functions and classes via Go type parameters
61
+ - Async/Await transpiled to Go channels and goroutines
62
+ - Promises (`new Promise`) transpiled to channel + goroutine pattern
63
+ - `setTimeout` mapped to Go's `time.AfterFunc`
64
+ - Nullable types (`T | null`, `T | undefined`) transpiled to Go pointer types
65
+ - Object literals transpiled to Go struct literals
66
+ - `assert()` function transpiled to `panic` on failure
67
+ - `parseInt` and `parseFloat` mapped to Go's `strconv` package
68
+ - String methods: `split`, `trim`, `trimStart`, `trimEnd`, `toUpperCase`, `toLowerCase`, `indexOf`, `includes`, `startsWith`, `endsWith`, `replace`, `replaceAll`, `repeat`, `charAt`, `substring`, `slice`, `concat`, `toString`
69
+ - Array methods: `join`, `slice`, `toString` (in addition to existing `push`)
70
+ - Math methods: `ceil`, `round`, `abs`, `sqrt`, `pow`, `min`, `max` (in addition to existing `random`, `floor`)
71
+ - Non-null assertion operator (`!`) support
72
+ - Type-aware method dispatch to prevent class methods from being intercepted as built-in string/array methods
73
+ - Safe name collision avoidance for Go reserved identifiers
74
+ - Automatic Go import management for `fmt`, `math`, `math/rand`, `strings`, `strconv`, `time`
75
+
76
+ ## [0.0.14] - 2025-05-25
77
+
78
+ ### Added
79
+
80
+ - Project creation with new `--new` command
81
+ - Support for functions and arrow functions
82
+ - Support for switch statements
83
+ - If statements, while loops, and for...of loops for arrays
84
+
85
+ ### Changed
86
+
87
+ - Replaced shelljs dependency with execa for improved process execution
88
+
89
+ ### Fixed
90
+
91
+ - Project creation issues
92
+
93
+ ## [0.0.12] - 2025-05-23
94
+
95
+ ### Changed
96
+
97
+ - Switched transpilation target to Go language
98
+
99
+ ## [0.0.9] - 2024-03-01
100
+
101
+ ### Added
102
+
103
+ - Basic types support (number, boolean, string, null, any)
104
+ - Support for variable declarations
105
+ - Support for binary expressions
106
+ - Arithmetic, comparison, logical, and increment/decrement operators
107
+
108
+ ## [0.0.1] - 2024-02-24
109
+
110
+ ### Added
111
+
112
+ - Initial project setup
113
+ - Basic project structure
114
+
115
+ ## [0.0.0] - 2022-12-20
116
+
117
+ ### Added
118
+
119
+ - 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.