typenative 0.1.0 → 0.1.1

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/README.md CHANGED
@@ -1,220 +1,258 @@
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.23](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 / unknown | ✅ | Dynamic values handled at runtime (JSON-like objects, arrays, primitives) |
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
- | Object shorthand | ✅ | `{ name }` → `{ name: name }` |
37
- | Array destructuring | ✅ | `const [a, b] = arr` |
38
- | Object destructuring | ✅ | `const { x, y } = obj` |
39
- | Object spread | ✅ | `{ ...base, x: 1 }` |
40
- | Records / dictionaries | ✅ | `Record<K, V>` and objects indexed by key → Go maps |
41
- | Object type aliases | ✅ | `type P = { x: number }` → Go struct |
42
-
43
- **Operators**
44
-
45
- | Feature | Supported | Notes |
46
- | ------------------------ | :-------: | ------------------------------ |
47
- | Arithmetic operators | ✅ | `+`, `-`, etc. |
48
- | Comparison operators | ✅ | `==`, `!=`, `===`, `!==`, etc. |
49
- | Logical operators | ✅ | `&&`, `\|\|` |
50
- | Increment/Decrement | ✅ | `++`, `--` |
51
- | Spread operator | ✅ | `[...arr]`, `fn(...args)` |
52
- | Non-null assertion (`!`) | ✅ | Stripped during transpilation |
53
- | Ternary expressions | ✅ | `condition ? a : b` |
54
- | Nullish coalescing | ✅ | `??` operator |
55
- | Optional chaining | ✅ | `obj?.prop`, `arr?.[i]` |
56
- | Nullish assignment | ✅ | `x ??= value` |
57
- | `in` / `typeof` | ✅ | `"key" in obj`, `typeof x === "string"` |
58
- | JS truthiness | ✅ | `if (str)`, `!count`, `a \|\| fallback` on any type |
59
-
60
- **Control Flow**
61
-
62
- | Feature | Supported | Notes |
63
- | ------------------ | :-------: | ------------------------------------------------------ |
64
- | If/Else statements | ✅ | Fully supported |
65
- | Switch statements | ✅ | Case and default statements |
66
- | For loops | ✅ | Standard `for` loops |
67
- | Continue | ✅ | `continue` in all loop kinds |
68
- | For...of loops | ✅ | Arrays, Maps, Sets; `Object.entries()` unwrapping |
69
- | For...in loops | ✅ | Iterates keys via Go `range` |
70
- | While loops | ✅ | Transpiled to Go's `for` loops |
71
- | Do...while loops | ✅ | Implemented with conditional break |
72
- | Try/Catch/Finally | ✅ | `throw` → `panic`; catch/finally via `defer`/`recover` |
73
- | Narrowing | ✅ | `T \| undefined` narrowed after `if (x)`, `x !== undefined`, early returns |
74
-
75
- **Data Structures & Array Methods**
76
-
77
- | Feature | Supported | Notes |
78
- | -------------------------- | :-------: | --------------------------------------------------------------------------------------------- |
79
- | Arrays | ✅ | Basic array operations |
80
- | Array methods | ✅ | `push`, `pop`, `shift`, `unshift`, `join`, `slice`, `concat`, `reverse`, `sort`, `flat`, `at` |
81
- | Higher-order array methods | ✅ | `.map()`, `.filter()`, `.some()`, `.find()`, `.findIndex()`, `.every()`, `.forEach()`, `.reduce()` |
82
- | Method chaining | ✅ | e.g. `.map(...).filter(...).join(...)` |
83
- | Map | ✅ | `Map<K, V>` → Go `map[K]V`; `.set()`, `.get()`, `.has()`, `.delete()`, `.clear()`, `.size` |
84
- | Set | ✅ | `Set<T>` → Go `map[T]struct{}`; `.add()`, `.has()`, `.delete()`, `.clear()`, `.size` |
85
- | Object.keys / values | ✅ | Typed results for maps and records |
86
- | Array sort / flat | ✅ | `sort((a, b) => a - b)` in place, `flat()` one level |
87
-
88
- **Functions**
89
-
90
- | Feature | Supported | Notes |
91
- | ---------------------------- | :-------: | ----------------------------------------------------------- |
92
- | Function declarations | ✅ | Transpiled to Go functions |
93
- | Arrow functions | ✅ | Transpiled to anonymous functions |
94
- | IIFEs | ✅ | `(() => { ... })()` and `(function name() { ... })()` |
95
- | Closures over mutable state | ✅ | Functions capturing and mutating outer variables |
96
- | Function types | ✅ | `() => number`, `(x: number) => string` as type annotations |
97
- | Generics (functions/classes) | ✅ | Type parameters via Go generics |
98
- | Default parameter values | ✅ | `function(x = defaultValue)` |
99
- | Rest parameters | ✅ | `function(...args: T[])` → Go variadic |
100
- | Optional parameters | ✅ | `function f(x?: string)` |
101
- | Destructured parameters | ✅ | `function f({ a, b }: T)`, `([x, y]: number[])` |
102
-
103
- **Classes & Interfaces**
104
-
105
- | Feature | Supported | Notes |
106
- | ------------------- | :-------: | -------------------------------------------------------------- |
107
- | Classes | ✅ | Transpiled to Go structs with constructor and receiver methods |
108
- | Parameter properties | ✅ | `constructor(private x: number)` |
109
- | Class inheritance | ✅ | `extends` via embedded structs, `super()` supported |
110
- | Static members | ✅ | `static method()` / `static prop` → package-level declarations |
111
- | Getters / Setters | ✅ | `get prop()` → `Get_prop()`, `set prop(v)` → `Set_prop(v)` |
112
- | Interfaces | ✅ | Transpiled to Go interfaces, supports `extends` |
113
- | Optional properties | ✅ | `prop?: Type` in interfaces/types |
114
- | Enums | ✅ | `enum` declarations and member access |
115
-
116
- **Async & Timing**
117
-
118
- | Feature | Supported | Notes |
119
- | ----------- | :-------: | ----------------------------------------------------------------- |
120
- | Async/Await | ✅ | `async` functions return Go channels, `await` reads from channels |
121
- | Promises | ✅ | `new Promise` transpiled to channel + goroutine pattern |
122
- | setTimeout | ✅ | Mapped to Go's `time.AfterFunc` |
123
-
124
- **Built-in Functions & Utilities**
125
-
126
- | Feature | Supported | Notes |
127
- | --------------------- | :-------: | ----------------------------------------------------- |
128
- | console.log | ✅ | Mapped to `fmt.Println` |
129
- | console.error | ✅ | Mapped to `fmt.Fprintln(os.Stderr, ...)` |
130
- | console.time/timeEnd | ✅ | Performance measurement via `time.Now` / `time.Since` |
131
- | assert | ✅ | Transpiled to `panic` on failure |
132
- | parseInt / parseFloat | ✅ | Mapped to Go's `strconv` package |
133
- | JSON.stringify | ✅ | Mapped to `encoding/json` `Marshal` / `MarshalIndent` |
134
- | JSON.parse | ✅ | Mapped to `encoding/json` `Unmarshal` |
135
- | Object.keys/values | ✅ | Map key/value iteration helpers |
136
- | process.argv | ✅ | Mapped to `os.Args` |
137
- | process.platform | ✅ | Mapped to `runtime.GOOS` |
138
- | process.exit | ✅ | Mapped to `os.Exit` |
139
-
140
- **Math Methods**
141
-
142
- | Feature | Supported | Notes |
143
- | ------------------------- | :-------: | ------------------------------------------------- |
144
- | Math.random | ✅ | Mapped to `rand.Float64()` |
145
- | Math.floor / ceil / round | ✅ | Mapped to `math.Floor`, `math.Ceil`, `math.Round` |
146
- | Math.abs / sqrt / pow | ✅ | Mapped to corresponding `math` functions |
147
- | Math.min / max | ✅ | Go builtins `min` / `max` |
148
- | Math.max(...arr) | ✅ | Spread and any number of arguments via `slices.Max` / `max` |
149
- | Math.log / log2 / log10 | ✅ | Mapped to `math.Log`, `math.Log2`, `math.Log10` |
150
- | Math.sin / cos / tan | ✅ | Mapped to `math.Sin`, `math.Cos`, `math.Tan` |
151
- | Math.trunc / sign | ✅ | Mapped to `math.Trunc` and inline sign check |
152
-
153
- **String Methods**
154
-
155
- | Feature | Supported | Notes |
156
- | -------------------------- | :-------: | --------------------------------------------- |
157
- | Template literals | ✅ | Backtick strings with `${expr}` interpolation |
158
- | toUpperCase / toLowerCase | ✅ | Via `strings` package |
159
- | trim / trimStart / trimEnd | ✅ | Via `strings` package |
160
- | split / includes / indexOf | ✅ | Via `strings` package |
161
- | startsWith / endsWith | ✅ | Via `strings` package |
162
- | replace / replaceAll | ✅ | Via `strings` package |
163
- | replace with RegExp | ✅ | `/g` vs first match, `$1`/`$&` patterns, function replacers |
164
- | charAt / substring / slice | ✅ | Direct Go string indexing/slicing |
165
- | concat / repeat | ✅ | String concatenation and `strings.Repeat` |
166
- | padStart / padEnd | ✅ | Via `strings.Repeat` |
167
- | match / matchAll / search | ✅ | Via `regexp` package |
168
- | at | ✅ | Supports negative indices |
169
-
170
- **Number / Object Methods**
171
-
172
- | Feature | Supported | Notes |
173
- | -------- | :-------: | ----------------------------------------------------- |
174
- | toString | ✅ | Universal `toString()` via `fmt.Sprintf` for any type |
175
- | toFixed | ✅ | `n.toFixed(2)` via `strconv.FormatFloat` |
176
-
177
- **RegExp**
178
-
179
- | Feature | Supported | Notes |
180
- | -------------- | :-------: | --------------------------------------------------- |
181
- | Regex literals | ✅ | `/pattern/flags` transpiled to `regexp.MustCompile` |
182
- | new RegExp() | ✅ | Constructor with optional flags |
183
- | test() | ✅ | Mapped to `regexp.MatchString` |
184
- | exec() | ✅ | Mapped to `regexp.FindStringSubmatch` |
185
-
186
- **Modules & Imports**
187
-
188
- | Feature | Supported | Notes |
189
- | ------------------------ | :-------: | ------------------------------------------------------------------ |
190
- | Named imports | ✅ | `import { x } from './file'` |
191
- | Default imports | ✅ | `import x from 'pkg'` — namespace stripped in output |
192
- | Namespace imports | ✅ | `import * as x from 'pkg'` |
193
- | Local file imports | ✅ | Relative paths transpiled to a separate Go file |
194
- | Node.js built-in imports | ✅ | `import { join } from 'node:path'` mapped to Go stdlib |
195
- | Go package imports | ✅ | `import { x } from 'go:pkg'` |
196
- | npm package imports | ✅ | `import { x } from 'pkg'` mapped to Go module imports |
197
- | Named exports | ✅ | `export function` / `export const` declarations |
198
-
199
- ## Native (self-hosted) compiler
200
-
201
- TypeNative compiles itself: `src/main.ts` transpiles to Go and builds into a native `typenative`
202
- binary that needs no Node.js at runtime and produces the same Go output as the npm package.
1
+ # TypeNative
2
+
3
+ TypeNative is a TypeScript-to-Go transpiler, it turns TypeScript into Go code and compiles it to a single-file native executable — no Node.js runtime, no bundler, just a binary. Write TypeScript, ship native binaries.
4
+
5
+ ```ts
6
+ // hello.ts
7
+ console.log('Hello, native world!');
8
+ ```
203
9
 
204
10
  ```sh
205
- npm run build # compile the TypeScript sources
206
- npm run build:native # build native/typenative and native/tsparser
207
- native/typenative --source app.ts --script
11
+ npx typenative --source hello.ts --script
12
+ # Hello, native world!
13
+ ```
14
+
15
+ > Early development: the supported language subset grows with every release. See [conformance.md](conformance.md) for exactly what transpiles today.
16
+
17
+ ---
18
+
19
+ ## Contents
20
+
21
+ - [Requirements](#requirements)
22
+ - [Install](#install)
23
+ - [Quick start](#quick-start)
24
+ - [CLI reference](#cli-reference)
25
+ - [Writing TypeNative-compatible TypeScript](#writing-typenative-compatible-typescript)
26
+ - [Examples](#examples)
27
+ - [How it works](#how-it-works)
28
+ - [Testing and conformance](#testing-and-conformance)
29
+ - [Self-hosted native compiler](#self-hosted-native-compiler)
30
+ - [License](#license)
31
+
32
+ ## Requirements
33
+
34
+ - [Node.js v24](https://nodejs.org/en) or newer.
35
+ - [Go 1.26](https://go.dev/doc/install) or newer.
36
+
37
+ ## Install
38
+
39
+ Use without installing:
40
+
41
+ ```sh
42
+ npx typenative --source main.ts --script
43
+ ```
44
+
45
+ Or add to a project:
46
+
47
+ ```sh
48
+ npm install typenative -D
49
+ npx typenative --source main.ts --output ./bin/myapp
50
+ ```
51
+
52
+ Generated projects pin it automatically as a dev dependency.
53
+
54
+ ## Quick start
55
+
56
+ **1. Run a snippet directly (script mode):**
57
+
58
+ ```sh
59
+ npx typenative --source hello.ts --script
208
60
  ```
209
61
 
210
- Building the native compiler requires Go 1.26 (for the TypeScript parser, `tsparser/`). The
211
- `typenative` binary finds `tsparser` next to itself, or via the `TYPENATIVE_TSPARSER`
212
- environment variable.
62
+ Transpiles `hello.ts` to `dist/code.go`, builds `dist/native(.exe)`, runs it, and forwards its exit code.
63
+
64
+ **2. Build a distributable binary:**
65
+
66
+ ```sh
67
+ npx typenative --source main.ts --output ./bin/myapp
68
+ # Windows: --output ./bin/myapp.exe
69
+ ```
70
+
71
+ **3. Interactive mode (no flags):**
72
+
73
+ ```sh
74
+ npx typenative
75
+ # prompts for TypeScript entry file and output path
76
+ ```
77
+
78
+ ```sh
79
+ npx typenative --script
80
+ # opens an editor prompt; runs what you type without saving a file
81
+ ```
82
+
83
+ **4. Scaffold a new project:**
84
+
85
+ ```sh
86
+ npx typenative --new
87
+ # prompts for project name + whether to npm install
88
+ # creates main.ts, package.json (with execute/build scripts), tsconfig.json, README.md, .gitignore
89
+ ```
90
+
91
+ The scaffolded `package.json` gives you:
92
+
93
+ ```json
94
+ {
95
+ "scripts": {
96
+ "execute": "npx typenative --source main.ts --script",
97
+ "build": "npx typenative --source main.ts --output bin/<name>"
98
+ }
99
+ }
100
+ ```
101
+
102
+ Scaffolded `tsconfig.json` targets the TypeNative type surface:
103
+
104
+ ```json
105
+ {
106
+ "compilerOptions": {
107
+ "target": "es2020",
108
+ "strict": true,
109
+ "types": ["typenative", "typenative/go", "typenative/npm"]
110
+ }
111
+ }
112
+ ```
113
+
114
+ ## CLI reference
115
+
116
+ | Flag | Mode | Description |
117
+ | ----------------- | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
118
+ | `--source <file>` | build / script | TypeScript entry file. Relative imports (`./util`) and npm packages are resolved from its directory. |
119
+ | `--output <path>` | build | Where to copy the compiled binary. If omitted with `--script`, the temp binary in `dist/` is executed and kept there. |
120
+ | `--script` | run | Build to `dist/native(.exe)` and execute immediately with inherited stdio. Combine with `--source`, or omit `--source` to type code into the prompt. |
121
+ | `--new` | scaffold | Create a new project directory (`main.ts`, `package.json`, `tsconfig.json`, `README.md`, `.gitignore`). |
122
+
123
+ Exit codes from `--script` are the exit code of your program. A non-zero `go build` prints `go build failed:` plus the compiler output and exits `1`.
124
+
125
+ ## Writing TypeNative-compatible TypeScript
126
+
127
+ TypeNative supports a growing subset of TypeScript, not the whole language. The source of truth is [conformance.md](conformance.md) — every supported feature links to a runnable probe in [conformance/](conformance/).
128
+
129
+ **Language highlights that work today:**
130
+
131
+ - `let`/`const`, functions, arrow functions, closures, recursion, rest/spread, default and optional params, destructured params.
132
+ - Classes (inheritance, static members, getters, parameter properties, abstract, `implements`), interfaces, type aliases, generics, enums (numeric + string).
133
+ - `if`/`switch` (incl. fallthrough), `for`/`for...of`/`while`/`do...while`, `try`/`catch`/`finally` (`throw` → `panic`, catch via `defer`/`recover`), ternaries, optional chaining, nullish coalescing, `in`, `typeof`, `instanceof`.
134
+ - `async`/`await`, generators, custom iterators, tagged templates.
135
+
136
+ **Standard library that works today:**
137
+
138
+ | Area | What to use |
139
+ | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
140
+ | Console | `console.log`, `assert` (→ `panic` on failure) |
141
+ | `Array` | `push`/`pop`, `slice`/`splice`, `map`/`filter`/`reduce`, `find`/`some`/`every`, `sort` with comparator, `flat`/`flatMap`, `at`, `entries`, `join`, `reverse`, `shift`/`unshift` |
142
+ | `Object` | `assign`, `keys`/`values`/`entries`, spread of records → Go maps |
143
+ | `String` | `split`/`slice`/`replace`, `padStart`/`padEnd`, `repeat`, search/compare, char codes, unicode |
144
+ | `Number`/`Math` | `parseInt`/`parseFloat`, `toFixed`/`toString(radix)`, `isInteger`/`isNaN`, `min`/`max`/`random` |
145
+ | `Map`/`Set` | Full `set`/`get`/`has`/`delete`/`size` plus `for...of` iteration (→ Go maps) |
146
+ | `JSON` | `parse` / `stringify` |
147
+ | `RegExp` | Literals + `new RegExp()`, `test()`, `exec()` with groups, `i`/`m` flags (backreferences, named groups, stateful `/g` loops and lookbehind are not supported — Go `regexp` limitation) |
148
+ | `process` | `argv` (→ `os.Args`), `platform` (→ `runtime.GOOS`), `env` |
149
+
150
+ **Node built-ins (import with the `node:` prefix, mapped to Go helpers):**
151
+
152
+ ```ts
153
+ import path from 'node:path';
154
+ import * as fs from 'node:fs';
155
+ import { platform } from 'node:os';
156
+ import * as childProcess from 'node:child_process';
157
+
158
+ path.join('a', 'b');
159
+ fs.readFileSync('file.txt', 'utf-8');
160
+ childProcess.spawnSync('go', ['version'], { encoding: 'utf-8' });
161
+ ```
162
+
163
+ Supported: `node:path` (`join`, `dirname`, `basename`, `extname`, `resolve`), `node:fs` (`read/write/append/exists/mkdir/readdir/copy/rm`), `node:os` (`platform`, `homedir`, `tmpdir`), `node:child_process` (sync `exec`/`execSync`/`spawnSync`/`spawnInherit` shape). `node:readline.question()` exists as a TypeNative sync extension for self-hosted prompts.
164
+
165
+ **Direct Go access (import with the `go:` prefix):**
166
+
167
+ ```ts
168
+ import { Println, Sprintf } from 'go:fmt';
169
+ import { ToUpper } from 'go:strings';
170
+
171
+ Println(Sprintf('hi %s', ToUpper('bob')));
172
+ ```
173
+
174
+ Supported: `go:fmt` (`Println`, `Sprintf`), `go:strings` (`ToUpper`, `ToLower`), `go:strconv` (`FormatBool`).
175
+
176
+ **npm packages:**
177
+
178
+ ```ts
179
+ import { helper } from 'my-lib';
180
+ ```
181
+
182
+ Resolved by walking up to `node_modules/<name>` (TypeScript source preferred, CommonJS normalized to ESM). Local ambient `.d.ts` declarations (`declare module "my-lib" { ... }`) are used to inject precise parameter/return types.
183
+
184
+ Type mappings to keep in mind: `number` → `float64`, `boolean` → `bool`, nullable `T | null` → Go pointer, `Record<K, V>` / key-indexed objects → Go maps, object types → Go structs (copied by value, unlike JS references).
185
+
186
+ ## Examples
187
+
188
+ Hello world:
189
+
190
+ ```ts
191
+ console.log('Hello, World!');
192
+ ```
193
+
194
+ ```sh
195
+ npx typenative --source hello.ts --script
196
+ ```
197
+
198
+ Files and paths:
199
+
200
+ ```ts
201
+ import path from 'node:path';
202
+ import * as fs from 'node:fs';
203
+
204
+ const dir: string = path.dirname(path.resolve('data.txt'));
205
+ const text: string = fs.readFileSync(path.join(dir, 'data.txt'), 'utf-8');
206
+ console.log(text.toUpperCase());
207
+ ```
208
+
209
+ Classes and maps:
210
+
211
+ ```ts
212
+ class Counter {
213
+ count: number = 0;
214
+ inc(): void {
215
+ this.count++;
216
+ }
217
+ }
218
+
219
+ const seen: Map<string, number> = new Map();
220
+ seen.set('a', 1);
221
+ const c: Counter = new Counter();
222
+ c.inc();
223
+ console.log(`count=${c.count} seen=${seen.get('a')}`);
224
+ ```
225
+
226
+ ## How it works
227
+
228
+ ```text
229
+ main.ts --(parse)--> normalized JSON AST --(transpileToNative)--> dist/code.go --(go build)--> dist/native(.exe) --run/copy--> your binary
230
+ ```
231
+
232
+ - **Parse:** Node CLI uses the `typescript` npm package (`src/parse-node.ts`); the self-hosted binary spawns the Go `tsparser` tool (`src/parse-native.ts`). Both emit the same `{ kind: "Xxx", ... }` JSON shape so one transpiler consumes either.
233
+ - **Transpile:** `transpileToNative(code, { parse, readFile })` in `src/transpiler.ts` lowers the AST to Go, resolving relative and npm imports into additional Go files (`TranspileResult { main, files }`).
234
+ - **Build:** `run()` in `src/index.ts` writes `dist/code.go` (+ one Go file per module), cleans stale `dist/*.go`, shells out to `go build -o dist/native(.exe)`, then either executes it (`--script`, stdio inherited) or copies it to `--output`.
235
+
236
+ ## Testing and conformance
237
+
238
+ `npm test` is `npm run conformance`: every `conformance/*.ts` probe is transpiled, built with `go`, executed, and must exit `0`. Results print per category (`syntax` / `semantics` / `lib`) plus a total pass rate; any failure exits non-zero and lists the first diagnostic line (`*.go:line`, `panic:`, `Unsupported syntax`, `Error`).
239
+
240
+ CI (`.github/workflows/ci.yml`) runs `npm ci`, `npm run build`, and `npm run conformance` on Ubuntu with Node 24 and Go. Releases are cut from `TypeNative_*` tags via trusted publishing.
241
+
242
+ When adding a feature: add a probe, link it from [conformance.md](conformance.md), and keep the ✅/❌ matrix honest — gaps are documented, not hidden.
243
+
244
+ ## Self-hosted native compiler
245
+
246
+ TypeNative compiles itself. `src/main.ts` transpiles to Go and builds into a `typenative` binary that needs no Node.js at runtime and emits the same Go as the npm package:
247
+
248
+ ```sh
249
+ npm run build
250
+ npm run build:native # builds native/tsparser + native/typenative side by side
251
+ native/typenative --source app.ts --script
252
+ ```
213
253
 
214
- ### Known limitations
254
+ `TYPENATIVE_TSPARSER` overrides parser discovery if you move the binaries apart. Verify parity with `node scripts/conformance.mjs --native`.
215
255
 
216
- - Stateful `/g` regex loops (`while ((m = re.exec(s)))`) are not supported — use `matchAll`
217
- - `import.meta.url` is not lowered
218
- - Object types compile to Go structs, which are copied by value (JS objects are references)
256
+ ## License
219
257
 
220
- TypeNative is in early development and new features are being added regularly.
258
+ MIT — see [LICENSE](LICENSE).
package/bin/index.js CHANGED
@@ -217,7 +217,7 @@ function getPackageJson(projectName) {
217
217
  build: `npx typenative --source main.ts --output bin/${exeName}`
218
218
  },
219
219
  devDependencies: {
220
- typenative: '^0.0.19'
220
+ typenative: '^0.1.1'
221
221
  }
222
222
  };
223
223
  return JSON.stringify(pckg, null, 2);