typenative 0.7.0 → 0.7.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.
Files changed (217) hide show
  1. package/bin/node/assert.js +2 -2
  2. package/bin/node/child_process.js +66 -8
  3. package/bin/node/fs.js +1012 -4
  4. package/bin/node/histogram.js +1991 -0
  5. package/bin/node/process.js +14 -2
  6. package/bin/node/sqlite.js +1488 -5
  7. package/bin/node/stream.js +2 -1
  8. package/bin/node/system_extra.js +3 -270
  9. package/bin/node/test.js +39 -1
  10. package/bin/node/test_report.js +47 -1
  11. package/bin/node/test_run.js +57 -2
  12. package/bin/node/util.js +8 -5
  13. package/bin/node/webassembly.js +20 -5
  14. package/bin/node/webview.js +3257 -244
  15. package/bin/node/zlib.js +118 -14
  16. package/bin/node/zlib_iter.js +585 -0
  17. package/bin/transpiler.js +1370 -258
  18. package/bin/version.js +1 -1
  19. package/govendor/software.sslmate.com/src/go-pkcs12/.gitattributes +10 -0
  20. package/govendor/software.sslmate.com/src/go-pkcs12/LICENSE +28 -0
  21. package/govendor/software.sslmate.com/src/go-pkcs12/README.md +31 -0
  22. package/govendor/software.sslmate.com/src/go-pkcs12/bmp-string.go +63 -0
  23. package/govendor/software.sslmate.com/src/go-pkcs12/crypto.go +331 -0
  24. package/govendor/software.sslmate.com/src/go-pkcs12/errors.go +23 -0
  25. package/govendor/software.sslmate.com/src/go-pkcs12/go.mod +3 -0
  26. package/govendor/software.sslmate.com/src/go-pkcs12/internal/rc2/rc2.go +271 -0
  27. package/govendor/software.sslmate.com/src/go-pkcs12/mac.go +202 -0
  28. package/govendor/software.sslmate.com/src/go-pkcs12/pbkdf.go +184 -0
  29. package/govendor/software.sslmate.com/src/go-pkcs12/pkcs12.go +1000 -0
  30. package/govendor/software.sslmate.com/src/go-pkcs12/safebags.go +107 -0
  31. package/package.json +10 -1
  32. package/types/tsconfig.json +17 -0
  33. package/types/typenative-npm.d.ts +492 -12
  34. package/types/typenative.d.ts +88 -2
  35. package/.gitattributes +0 -1
  36. package/.github/workflows/ci.yml +0 -68
  37. package/.github/workflows/npm-publish-github-packages.yml +0 -88
  38. package/CHANGELOG.md +0 -1746
  39. package/CONTRIBUTION.md +0 -133
  40. package/conformance.md +0 -1497
  41. package/examples/README.md +0 -114
  42. package/examples/angular-templates/README.md +0 -141
  43. package/examples/angular-templates/bench.mjs +0 -173
  44. package/examples/angular-templates/dom-type-globals.d.ts +0 -21
  45. package/examples/angular-templates/dom-type-stubs.ts +0 -21
  46. package/examples/angular-templates/main.ts +0 -135
  47. package/examples/angular-templates/parity.mjs +0 -157
  48. package/examples/angular-templates/run-node.mjs +0 -69
  49. package/examples/angular-templates/vendor/angular/compiler/LICENSE +0 -21
  50. package/examples/desktop-notes/README.md +0 -106
  51. package/examples/desktop-notes/bench.mjs +0 -125
  52. package/examples/desktop-notes/main.ts +0 -131
  53. package/examples/desktop-notes/package-lock.json +0 -726
  54. package/examples/desktop-notes/package.json +0 -9
  55. package/examples/desktop-notes/ui.ts +0 -176
  56. package/examples/dupe-finder/README.md +0 -78
  57. package/examples/dupe-finder/bench.mjs +0 -120
  58. package/examples/dupe-finder/main.ts +0 -87
  59. package/examples/fibonacci/README.md +0 -89
  60. package/examples/fibonacci/bench.mjs +0 -87
  61. package/examples/fibonacci/main.ts +0 -21
  62. package/examples/hello-world/README.md +0 -62
  63. package/examples/hello-world/bench.mjs +0 -66
  64. package/examples/hello-world/main.ts +0 -7
  65. package/examples/json-server/README.md +0 -132
  66. package/examples/json-server/bench.mjs +0 -263
  67. package/examples/json-server/main.ts +0 -67
  68. package/examples/mandelbrot-png/README.md +0 -63
  69. package/examples/mandelbrot-png/bench.mjs +0 -95
  70. package/examples/mandelbrot-png/main.ts +0 -98
  71. package/examples/mandelbrot-png/preview.png +0 -0
  72. package/examples/marked-cli/README.md +0 -174
  73. package/examples/marked-cli/bench.mjs +0 -178
  74. package/examples/marked-cli/main.ts +0 -410
  75. package/examples/marked-cli/parity.mjs +0 -185
  76. package/examples/marked-cli/vendor/marked/LICENSE +0 -44
  77. package/examples/marked-cli/vendor/marked/VENDOR.md +0 -26
  78. package/examples/openai-chat/README.md +0 -148
  79. package/examples/openai-chat/bench.mjs +0 -175
  80. package/examples/openai-chat/main.ts +0 -488
  81. package/examples/react-compiler/README.md +0 -185
  82. package/examples/react-compiler/bench.mjs +0 -181
  83. package/examples/react-compiler/main.ts +0 -324
  84. package/examples/react-compiler/parity.mjs +0 -362
  85. package/examples/react-compiler/run-node.mjs +0 -90
  86. package/examples/react-compiler/vendor/babel/LICENSE +0 -22
  87. package/examples/react-compiler/vendor/babel/helper-globals/data/builtin-lower.json +0 -15
  88. package/examples/react-compiler/vendor/babel/helper-globals/data/builtin-upper.json +0 -51
  89. package/examples/react-compiler/vendor/charcodes/package.json +0 -25
  90. package/examples/react-compiler/vendor/invariant/LICENSE +0 -21
  91. package/examples/react-compiler/vendor/invariant/invariant.cjs +0 -51
  92. package/examples/react-compiler/vendor/invariant/invariant.d.cts +0 -11
  93. package/examples/react-compiler/vendor/invariant/types/LICENSE +0 -21
  94. package/examples/react-compiler/vendor/jridgewell/gen-mapping/LICENSE +0 -19
  95. package/examples/react-compiler/vendor/jridgewell/resolve-uri/LICENSE +0 -19
  96. package/examples/react-compiler/vendor/jridgewell/sourcemap-codec/LICENSE +0 -19
  97. package/examples/react-compiler/vendor/jridgewell/trace-mapping/LICENSE +0 -19
  98. package/examples/react-compiler/vendor/js-tokens/LICENSE +0 -21
  99. package/examples/react-compiler/vendor/js-tokens/index.cjs +0 -23
  100. package/examples/react-compiler/vendor/js-tokens/index.d.cts +0 -13
  101. package/examples/react-compiler/vendor/jsesc/LICENSE-MIT.txt +0 -20
  102. package/examples/react-compiler/vendor/jsesc/jsesc.cjs +0 -337
  103. package/examples/react-compiler/vendor/jsesc/jsesc.d.cts +0 -384
  104. package/examples/react-compiler/vendor/jsesc/types/LICENSE +0 -21
  105. package/examples/react-compiler/vendor/picocolors/LICENSE +0 -15
  106. package/examples/react-compiler/vendor/picocolors/picocolors.cjs +0 -75
  107. package/examples/react-compiler/vendor/picocolors/picocolors.d.cts +0 -5
  108. package/examples/react-compiler/vendor/picocolors/types.d.ts +0 -51
  109. package/examples/react-compiler/vendor/react-compiler/LICENSE +0 -21
  110. package/examples/react-compiler/vendor/stubs/babel-core.ts +0 -31
  111. package/examples/react-compiler/vendor/stubs/debug.ts +0 -18
  112. package/examples/react-compiler/vendor/stubs/js-tokens.d.ts +0 -13
  113. package/examples/react-compiler/vendor/stubs/pretty-format.ts +0 -18
  114. package/examples/react-compiler/vendor/zod/LICENSE +0 -21
  115. package/examples/react-compiler/vendor/zod-validation-error/LICENSE +0 -9
  116. package/examples/react-compiler/vendor/zod-validation-error/lib/utils/NonEmptyArray.ts +0 -5
  117. package/examples/react-compiler/vendor/zod-validation-error/lib/utils/joinPath.ts +0 -49
  118. package/examples/react-compiler/vendor/zod-validation-error/lib/utils/joinValues.ts +0 -48
  119. package/examples/react-compiler/vendor/zod-validation-error/lib/utils/stringify.ts +0 -50
  120. package/examples/react-compiler/vendor/zod-validation-error/lib/utils/titleCase.ts +0 -6
  121. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/MessageBuilder.ts +0 -126
  122. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/ValidationError.ts +0 -39
  123. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/custom.ts +0 -12
  124. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/errorMap.ts +0 -78
  125. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/index.ts +0 -2
  126. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidElement.ts +0 -12
  127. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidKey.ts +0 -12
  128. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidStringFormat.ts +0 -131
  129. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidType.ts +0 -54
  130. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidUnion.ts +0 -12
  131. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidValue.ts +0 -40
  132. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/notMultipleOf.ts +0 -12
  133. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/tooBig.ts +0 -76
  134. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/tooSmall.ts +0 -76
  135. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/types.ts +0 -27
  136. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/unrecognizedKeys.ts +0 -27
  137. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/fromError.ts +0 -13
  138. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/fromZodError.ts +0 -61
  139. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/fromZodIssue.ts +0 -38
  140. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/index.ts +0 -20
  141. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/isValidationError.ts +0 -5
  142. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/isValidationErrorLike.ts +0 -8
  143. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/isZodErrorLike.ts +0 -11
  144. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/toValidationError.ts +0 -20
  145. package/examples/react-compiler/vendor.mjs +0 -688
  146. package/examples/todo-cli/README.md +0 -69
  147. package/examples/todo-cli/bench.mjs +0 -89
  148. package/examples/todo-cli/main.ts +0 -92
  149. package/examples/yaml-cli/README.md +0 -152
  150. package/examples/yaml-cli/bench.mjs +0 -265
  151. package/examples/yaml-cli/main.ts +0 -251
  152. package/examples/yaml-cli/parity.mjs +0 -156
  153. package/examples/yaml-cli/vendor/yaml/LICENSE +0 -13
  154. package/examples/yaml-cli/vendor/yaml/VENDOR.md +0 -25
  155. package/performance/README.md +0 -248
  156. package/performance/any-dynamic.ts +0 -21
  157. package/performance/any-record-view.ts +0 -20
  158. package/performance/arr-for-of.ts +0 -29
  159. package/performance/arr-hof.ts +0 -21
  160. package/performance/arr-push-index.ts +0 -15
  161. package/performance/arr-push-local.ts +0 -39
  162. package/performance/arr-slice-concat.ts +0 -24
  163. package/performance/arr-sort.ts +0 -21
  164. package/performance/async-await.ts +0 -24
  165. package/performance/async-promise-all.ts +0 -38
  166. package/performance/bigint-arith.ts +0 -36
  167. package/performance/buf-encode.ts +0 -29
  168. package/performance/class-accessors.ts +0 -48
  169. package/performance/class-dispatch.ts +0 -52
  170. package/performance/date-format.ts +0 -18
  171. package/performance/events-emit.ts +0 -27
  172. package/performance/exc-throw-rare.ts +0 -25
  173. package/performance/exc-try-catch.ts +0 -26
  174. package/performance/fn-closures.ts +0 -29
  175. package/performance/fn-recursion-tree.ts +0 -31
  176. package/performance/fn-rest-spread.ts +0 -43
  177. package/performance/gen-for-of.ts +0 -46
  178. package/performance/gen-next.ts +0 -32
  179. package/performance/iter-helpers.ts +0 -38
  180. package/performance/json-any.ts +0 -30
  181. package/performance/json-roundtrip.ts +0 -27
  182. package/performance/map-delete.ts +0 -24
  183. package/performance/map-iterate.ts +0 -26
  184. package/performance/map-number-keys.ts +0 -37
  185. package/performance/map-string-keys.ts +0 -22
  186. package/performance/num-arith-loop.ts +0 -14
  187. package/performance/num-bitwise.ts +0 -21
  188. package/performance/num-hash-imul.ts +0 -36
  189. package/performance/num-mod-int.ts +0 -16
  190. package/performance/num-to-string.ts +0 -16
  191. package/performance/obj-alloc.ts +0 -32
  192. package/performance/obj-keys-entries.ts +0 -44
  193. package/performance/obj-optional-chain.ts +0 -42
  194. package/performance/obj-record-dict.ts +0 -24
  195. package/performance/obj-spread-destructure.ts +0 -40
  196. package/performance/regex-exec.ts +0 -29
  197. package/performance/regex-replace-fn.ts +0 -24
  198. package/performance/regex-site.ts +0 -28
  199. package/performance/set-ops.ts +0 -20
  200. package/performance/str-char-scan.ts +0 -35
  201. package/performance/str-concat-plus.ts +0 -18
  202. package/performance/str-concat.ts +0 -24
  203. package/performance/str-methods.ts +0 -24
  204. package/performance/str-short-scan.ts +0 -26
  205. package/performance/str-split-join.ts +0 -23
  206. package/performance/str-switch-compare.ts +0 -50
  207. package/performance/str-template.ts +0 -16
  208. package/performance/str-unicode.ts +0 -25
  209. package/performance/typed-array.ts +0 -30
  210. package/performance/union-switch.ts +0 -57
  211. package/performance/union-typeof.ts +0 -40
  212. package/performance/wasm-call.ts +0 -63
  213. package/tsparser/check.go +0 -158
  214. package/tsparser/go.mod +0 -14
  215. package/tsparser/go.sum +0 -22
  216. package/tsparser/main.go +0 -363
  217. package/tsparser/tsparser.exe +0 -4
package/CHANGELOG.md DELETED
@@ -1,1746 +0,0 @@
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
- ## [Unreleased]
9
-
10
- ### Fixed
11
-
12
- - **`size` / `length` on a `Set` or `Map` read as a reference:** `undefined`.
13
- The dynamic-record fast path in reference reads answered a missing data key
14
- before the collection properties were consulted, so any read whose value
15
- escapes the expression — a template interpolation, an argument, a field
16
- chain such as `block.preds.size` — read as undefined while a plain
17
- comparison still worked. The React Compiler example's build failed its
18
- `EnterSSA` entry-block invariant on most fixtures because of it. Such reads
19
- now fall through to `TnGet`, which answers the collection properties.
20
- - **A program's own `assert`:** calls of a declared `assert` were lowered to the
21
- global assertion's panic statement, so the declaration never ran (its Go
22
- function was emitted but called from nowhere) and a failed check surfaced as
23
- `panic: <message>` that a `try` / `catch` could not catch. A function,
24
- variable, parameter or import named `assert` now shadows the builtin, while
25
- an unimported global `assert(...)` keeps the statement form.
26
-
27
- ## [0.7.0] - 2026-11-17
28
-
29
- ### Added
30
-
31
- - **`node:ffi`:** the Node 26 module — `dlopen` / `dlclose` / `dlsym`,
32
- `DynamicLibrary` (`getFunction(s)`, `getSymbol(s)`, `symbols`, `close`,
33
- `using`), wrappers' `.pointer`, `registerCallback` and friends, the
34
- `get*` / `set*` memory accessors, `toString` / `toBuffer` /
35
- `toArrayBuffer`, `export*`, `getRawPointer`, `suffix` and `types`, with
36
- Node's argument checks and error codes. No cgo: `LoadLibrary` on
37
- Windows, the vendored `github.com/ebitengine/purego` on Linux / macOS
38
- (linked only into programs that import `node:ffi`). A JS throw in a
39
- callback is rethrown once the native call returns; Windows callbacks
40
- take integer / pointer arguments only. `getCurrentEventLoop` is 🚫 (no
41
- libuv loop).
42
- - **`node:http`:** connection pooling options on `Agent` (`maxSockets`,
43
- `maxTotalSockets`, `maxFreeSockets`, `keepAlive`, `keepAliveMsecs`,
44
- `scheduling`), request trailers (`req.addTrailers` after a streamed
45
- body, declared or not), `res.statusMessage` and `'checkContinue'` /
46
- `'checkExpectation'`, and the Node 26.3 `httpValidation` option
47
- (`'strict'` / `'relaxed'` / `'insecure'`, also `insecureHTTPParser`).
48
- - **`node:http2`:** frame-level session APIs on the vendored
49
- `golang.org/x/net/http2` — `ping`, `settings`, `goaway`, `altsvc`, the
50
- server's `'session'` event, `type`, `localSettings` / `remoteSettings` /
51
- `pendingSettingsAck`, the peer's `'ping'` / `'localSettings'` /
52
- `'remoteSettings'` / `'goaway'` / `'altsvc'` events, and
53
- `getPackedSettings` / `getUnpackedSettings`. Sessions run x/net's
54
- `ServeConn` / `NewClientConn` over a connection split into frames, so the
55
- session's own frames never land inside one of the library's. Cleartext still uses prior
56
- knowledge (no HTTP/1.1 `Upgrade: h2c` handshake), as in Node.
57
- - **Streams, events and readline (closing the remaining ❌ rows):**
58
- `node:stream` backpressure — `highWaterMark` / `readableHighWaterMark` /
59
- `writableHighWaterMark` (16 KiB or 16 objects by default,
60
- `get/setDefaultHighWaterMark`), `write()` / `push()` returning `false`
61
- at the mark, `'drain'` only after a `false` write, `writableNeedDrain`,
62
- byte-counted `readableLength` / `writableLength`, read-ahead up to the
63
- mark, and transforms holding their writer while their output is unread,
64
- so `pipe` / `pipeline` pause a fast source; `compose` with async
65
- generator functions, source generators and async sink functions;
66
- `duplexPair` (Node 26.1 semantics); `Readable.toWeb` `type: 'bytes'` /
67
- `Duplex.toWeb` `readableType`; and
68
- `readable[Symbol.for('Stream.toAsyncStreamable')]()` (stream/iter
69
- batches). `node:stream/web`: BYOB readers (`getReader({ mode: 'byob' })`,
70
- `ReadableStreamBYOBReader`, `read(view, { min })` filling the caller's
71
- view), byte-stream controllers' `byobRequest` (`view`, `respond`,
72
- `respondWithNewView`) and `autoAllocateChunkSize`, and transferring
73
- streams with `structuredClone(stream, { transfer: [stream] })` (others
74
- throw a `DataCloneError`). `node:events`: an EventEmitter subclass's
75
- `[Symbol.for('nodejs.rejection')]` / `[captureRejectionSymbol]` method
76
- handles captured rejections (`captureRejectionSymbol` is exported), and
77
- a subclass without a constructor passes its options on.
78
- `node:readline`: terminal-mode line editing (`terminal: true`, or stdin
79
- and stdout both terminals, in raw mode) — cursor keys, Emacs-style ctrl /
80
- meta keys, `history` / `historySize` / `removeHistoryDuplicates` with
81
- prefix search and `'history'` events, a sync or callback `completer` on
82
- Tab, `line` / `cursor` / `getCursorPos()`, and `write(data, key)`.
83
- - **`node:crypto` keys beyond Go's standard library:** encrypted private
84
- keys (PKCS#8 PBES2 with PBKDF2 + AES-CBC / 3DES, the legacy `DEK-Info`
85
- PEM headers) and encrypted export (`cipher` / `passphrase`, PEM or DER);
86
- `rsa-pss` (with its hash, MGF1 hash and salt length), `dsa` and `dh`
87
- key types in PKCS#8 / SPKI, `ed448` / `x448` (signing, ECDH, JWK) and
88
- `secp256k1` (`createECDH`, ECDSA, JWK). Ed448 / X448 come from the
89
- vendored `cloudflare/circl`, secp256k1 from `decred/dcrd` (both pure Go),
90
- linked only into programs that read key data or may generate such keys.
91
- `crypto.Certificate` (`verifySpkac` / `exportChallenge` /
92
- `exportPublicKey`) and `crypto.parsePKCS12(bundle, { passphrase })` —
93
- Node 26's `{ privateKey, certificate, additionalCertificates }` — on the
94
- vendored `go-pkcs12`, linked only by `parsePKCS12` and `pfx` options.
95
- - **`node:crypto` MACs and ciphers:** `createMac` gains `gmac`,
96
- `poly1305`, `siphash` (64- / 128-bit), `blake2bmac` and `blake2smac`
97
- (output length, salt, personalization), and `getCiphers` gains AES-SIV
98
- and AES-GCM-SIV (`aes-128/192/256-siv`, `aes-128/192/256-gcm-siv`), all
99
- in pure Go (S2V / CMAC, POLYVAL over GHASH's field).
100
- - **`node:tls` PFX, passphrases and sessions:** `pfx` (a Buffer or
101
- `{ buf, passphrase }` entries) and `passphrase`-protected keys for
102
- servers, clients and secure contexts; session resumption through the
103
- `session` option, `'newSession'` / `'resumeSession'` events,
104
- `getSession()` and `isSessionReused()`; and `tls.rootCertificates`,
105
- Node's 118-certificate Mozilla bundle (linked only when read).
106
- - **`Temporal`:** the Node 26 global — `Instant`, `ZonedDateTime`,
107
- `PlainDate`, `PlainTime`, `PlainDateTime`, `PlainYearMonth`,
108
- `PlainMonthDay`, `Duration` and `Now` — on Go's `time` and embedded
109
- tzdata (the ISO 8601 calendar). Parsing (RFC 9557 / ISO 8601, extended
110
- years, basic format, offsets, `[tz]` and `[u-ca]` annotations, duration
111
- strings with fractional hours and minutes), `with`, `add` / `subtract`,
112
- `until` / `since`, `round` / `total` with all nine rounding modes,
113
- `relativeTo`, DST gap / overlap disambiguation, `getTimeZoneTransition`
114
- and the `toString` options. `Temporal.Now.timeZoneId()` reads `TZ`, the
115
- `/etc/localtime` link or the Windows registry (`TimeZoneKeyName`, mapped
116
- to IANA). Named zones embed `time/tzdata` (+~450 KB, only in programs
117
- that use Temporal); non-ISO calendars throw a `RangeError`, and
118
- `toLocaleString` uses a fixed en-US format. `fs.Stats` gains
119
- `atimeInstant` / `mtimeInstant` / `ctimeInstant` / `birthtimeInstant`
120
- and `Date.prototype.toTemporalInstant` exists.
121
- - **`Intl`:** `NumberFormat` (decimal / percent / currency / unit styles,
122
- compact / scientific / engineering notation, significant and fraction
123
- digits, rounding modes and increments, `signDisplay`, `formatToParts`,
124
- `formatRange`), `DateTimeFormat` (`dateStyle` / `timeStyle`, option bags,
125
- IANA and offset time zones with `time/tzdata` embedded, hour cycles, zone
126
- names, `formatToParts`, `formatRange`), `Collator`, `PluralRules`,
127
- `ListFormat`, `RelativeTimeFormat`, `Segmenter` (UAX #29 graphemes, words
128
- and sentences), `DisplayNames`, `Locale`, `getCanonicalLocales` and
129
- `supportedValuesOf`. Patterns, symbols and names are captured from Node's
130
- own ICU by `npm run gen:intl` for 32 locales (en, en-GB, en-IN, de, fr, es,
131
- es-MX, it, pt-BR, pt-PT, nl, sv, da, nb, fi, pl, cs, ru, uk, tr, el, ja,
132
- zh, zh-Hant, ko, ar, he, hi, id, th, vi); other regions use their
133
- language's data, and unknown languages the default locale's. Language
134
- tags, plural rules, collation and locale case mapping run on
135
- `golang.org/x/text`, now vendored in `govendor/` (it replaces the copy
136
- `String.normalize` took from GOROOT).
137
- - **Locale-aware `toLocale*`:** `Number` / `BigInt` / `Date` / `Array`
138
- `toLocaleString`, `toLocaleDateString` / `toLocaleTimeString` and
139
- `localeCompare` with a locale or options go through `Intl`;
140
- `toLocaleUpperCase` / `toLocaleLowerCase` apply Turkish, Azeri and
141
- Lithuanian casing. Without locales they use the system locale (`LC_ALL` /
142
- `LANG`, the Windows user locale), as Node does.
143
- - **Mixin factories as function declarations:** `function Tagged(superClass:
144
- typeof Base) { return class extends superClass {…} }` works like the arrow
145
- form, and a function returning a subclass of a known class
146
- (`function make() { return class extends Base {…} }`) becomes a class of its
147
- own (`syntax-mixins.ts`). A generic constraint or `class extends f()`
148
- still isn't lowered.
149
-
150
- - **WebAssembly and `node:wasi`:** the `WebAssembly` global (`validate`,
151
- `compile`, `instantiate`, `Module`, `Instance`, `Memory`, `Global`, the
152
- `Module` descriptors and `CompileError` / `LinkError` / `RuntimeError`) and
153
- `node:wasi`'s `WASI` (preview1: args, env, preopens, stdio, `start` /
154
- `initialize`). Both run on [wazero](https://github.com/tetratelabs/wazero),
155
- a pure-Go runtime vendored in `govendor/`, so there is still no cgo and
156
- cross-compiling still works. JS functions can be imports, and memories,
157
- globals and functions can be shared between instances.
158
- - **Plain objects with Map-like keys:** an object's own function property
159
- named like a Map method (`exports.add(…)`, `handlers.get(…)`) calls that
160
- function, and a `Record`'s `.size` reads its `size` key (not an entry count).
161
- `x instanceof ns.Class` works for Node classes reached through a namespace.
162
- - **ES2025 / ES2026 built-ins:** `Math.f16round`, `Array.fromAsync`,
163
- `Iterator.concat`, `Map` / `WeakMap` `getOrInsert` /
164
- `getOrInsertComputed`, `RegExp.escape` and the `d` flag (`hasIndices`,
165
- `indices`), `Error.isError`, `DOMException` / `QuotaExceededError` (AbortSignal
166
- reasons are DOMExceptions), `Reflect.construct`, `Float16Array`,
167
- `BigInt64Array` / `BigUint64Array`, `DataView` `get` / `setFloat16`,
168
- `ArrayBuffer` `transfer`, and `Uint8Array` `toHex` / `fromHex` /
169
- `setFromBase64` / `setFromHex` with the base64 options (strict decoding).
170
- - **Resizable and detached `ArrayBuffer`s (ES2024):** `new ArrayBuffer(n,
171
- { maxByteLength })`, `resize`, `resizable`, `maxByteLength`, `detached`, and
172
- growable `SharedArrayBuffer`s (`grow`, `growable`). Typed arrays and
173
- DataViews made without a length track the buffer's size, fixed-length ones
174
- go out of bounds when it shrinks below them, and `transfer` /
175
- `transferToFixedLength` now detach the source (its views read as empty,
176
- their methods throw a `TypeError`). A buffer is still a Go `[]byte`: its
177
- state lives beside it, so programs that don't resize or transfer don't pay
178
- for it. A typed array's `buffer` / `byteOffset` are now the `ArrayBuffer`
179
- it views and its offset in it.
180
- - **Well-known symbols on classes:** `async *[Symbol.asyncIterator]()` for
181
- `for await`, `[Symbol.toPrimitive](hint)`, a `[Symbol.toStringTag]` getter,
182
- a static `[Symbol.hasInstance]`, and `[util.inspect.custom]()`.
183
- - **Locale-aware strings:** a bare `a.localeCompare(b)` follows a light
184
- approximation of the root collation (base letters, then accents, then
185
- case), so programs that only sort don't link the collation tables; with a
186
- locale or options it is `Intl.Collator`'s (see `Intl` above).
187
- - **Node 25 / 26 APIs:** `fs` `glob` / `globSync` / `fs/promises` `glob`,
188
- `statfs`, `openAsBlob(Sync)`, the `readFile` `buffer` option and `signal`
189
- on `stat`; `process.ref` / `unref`, `execve` and the uncaught exception
190
- capture callbacks; `require()` of modules through `createRequire`,
191
- `module.findPackageJSON` and Node 26's `builtinModules`; `v8` heap space
192
- and code statistics; `util` `getCallSites`, `isPartialDeepStrictEqual`,
193
- `markPromiseAsHandled`, `MIMEType.parse` and hex colours in `styleText`;
194
- printf-style and function messages in `assert`, and
195
- `assert.partialDeepStrictEqual`; legacy `url.parse` / `url.resolve`;
196
- `crypto.randomUUIDv7` and `createMac` (HMAC, KMAC, AES-CMAC); histogram
197
- statistics; symbol event names and `EventEmitterAsyncResource`; real
198
- `executionAsyncId` / `triggerAsyncId` and `createHook` callbacks;
199
- `Buffer.stringLength`, `buffer.isLatin1`, `blob.textStream()`, an `end` for
200
- `buf.indexOf` / `includes` and `Buffer.poolSize`; `tty.ReadStream` /
201
- `WriteStream`; `http` `writeInformation`, `req.signal`, header checks and
202
- WebSocket masking; `node:test` `t.log`, `getTestContext`, tags and mock
203
- call assertions; `node:sqlite` `Database` / `Statement` and statement
204
- `close` / `stat` / `resetStats`.
205
- - **Web globals:** `navigator`, `CustomEvent`, `ErrorEvent`, `Storage`,
206
- `sessionStorage` and a file-backed `localStorage` (`TN_LOCALSTORAGE_FILE`).
207
- - **WebSocket (client):** the WHATWG `WebSocket` global over `net` / `tls`
208
- (RFC 6455), as Node's: the handshake, subprotocols and custom `headers`,
209
- text and binary messages (`Blob`, or `ArrayBuffer` via `binaryType`),
210
- `bufferedAmount`, pings answered with pongs, and the close handshake
211
- (client- and server-initiated) with undici's constructor, `send` and `close`
212
- errors; plus the `MessageEvent` / `CloseEvent` globals.
213
- - **`URLPattern`** (global and `node:url`): string / init inputs, base URLs,
214
- named groups, wildcards, custom regexps, `ignoreCase`, and the component
215
- `groups` of `exec`.
216
- - **`util.debounce` / `util.throttle`:** callable functions with `cancel` /
217
- `flush` / `ref` / `unref` (and `hasImmediateCapacity` on a throttle), over
218
- the event loop's timers.
219
- - **ZIP archives (Node 26.8):** `ZipEntry` (`create(Sync)` / `createStream` /
220
- `createSymlink` / `read`, `content(Sync)` / `contentIterator`),
221
- `ZipBuffer`, `ZipFile` (`open(Sync)`, `get` / `add` / `delete` /
222
- `compact` / `stream`), `createZipArchive(Sync)`, `zipFiles` and
223
- `get` / `setMaxZipContentSize`. Archives are written byte for byte as
224
- Node writes them (`lib/internal/zip`'s layout: local headers, Zip64
225
- extras for streamed or oversized members, data descriptors), entries take
226
- Buffer / TypedArray / ArrayBuffer / DataView (as Node does), and
227
- `method: 'zstd'` compresses with the Zstd codecs.
228
- - **Zstd codecs (Node 26.8):** `zstdCompress(Sync)` / `zstdDecompress(Sync)`
229
- (callback and promisified forms), `createZstdCompress` /
230
- `createZstdDecompress` and the `ZSTD_*` constants, on the vendored
231
- `klauspost/compress` (pure Go, only linked into programs that use it).
232
- Frames interoperate with Node's libzstd ones; decoder errors carry libzstd's
233
- codes (`ZSTD_error_prefix_unknown`, `ZSTD_error_corruption_detected`, …),
234
- and bytes after the last complete frame are ignored as libzstd ignores them.
235
- - **`node:wasi` version `'unstable'`:** the legacy ABI's import module name
236
- (the same WASI functions under `wasi_unstable`, linked by wazero's
237
- function exporter), and `WebAssembly.compileStreaming` /
238
- `instantiateStreaming`: a `Response` (or a promise of one) whose MIME
239
- type is `application/wasm` is read and compiled, with Node's errors for
240
- non-`Response` sources and wrong MIME types.
241
- - **`node:sea` assets:** a `--sea-config <file>` build embeds the config's
242
- assets (`{ assets: { key: path } }`, paths relative to the config) into
243
- the binary, and `sea.getAsset` / `sea.getRawAsset` / `sea.getAssetAsBlob`
244
- read them back; without a config the getters throw
245
- `ERR_SINGLE_EXECUTABLE_APPLICATION_ASSET_NOT_FOUND`, as Node's without an
246
- asset blob.
247
- - **The `windowsHandle` stream option** of `fs.createReadStream` /
248
- `createWriteStream`: a Windows HANDLE (bigint) the stream reads or writes
249
- through, converted into a file at construction as Node's `_open_osfhandle`
250
- does; a non-bigint is a `TypeError` and an unusable handle `EBADF`,
251
- thrown before the path is opened.
252
- - **`node:test` randomized runs:** `--test-randomize` /
253
- `--test-random-seed` (and run()'s `randomize` / `randomSeed` options)
254
- run each parent's siblings in a seeded random order — Node's Mulberry32
255
- pick among those still waiting — with the seed reported before the summary;
256
- `--test-coverage-include-all` lists the working directory's source files
257
- that never ran in the coverage report (their whole file uncovered), and
258
- `t.log` emits a `test:log` event on run()'s TestsStream.
259
- - **IPC handle passing** (`send(msg, socket)`, `serialization: 'advanced'`):
260
- a `net.Socket` travels with the message to a forked child, a cluster worker
261
- or the parent and arrives as the second `'message'` argument, live to the
262
- real peer with its addresses, and the sender's own copy goes silent as in
263
- Node. It is a relay, not descriptor passing: the sender keeps the
264
- connection and relays its bytes over the IPC link, so it must stay alive.
265
- Half-closes, destroys and the socket's addresses propagate.
266
- - **`cluster` `SCHED_NONE`:** with `cluster.schedulingPolicy = cluster.SCHED_NONE`
267
- (writable now) a worker binds the port itself with `SO_REUSEPORT` on Unix,
268
- where the kernel balances the connections (on Windows `SO_REUSEADDR` lets
269
- the workers bind, without balancing); the primary still hears
270
- `'listening'` with the port. `exclusive: true`
271
- listeners bind directly, and dgram sockets with `reuseAddr` share a port.
272
- - **`child_process` `stdio` arrays:** entries past stderr are `ExtraFiles`
273
- (fds 3, 4, …), readable as `child.stdio[3+n]`; Windows, where `os/exec`
274
- has no `ExtraFiles`, serves each entry a named pipe the child opens as a
275
- real file, so `fs.writeSync(3, …)` reaches the parent synchronously.
276
- - **`process.permission`:** `has` / `drop` under `--permission` (from
277
- `NODE_OPTIONS`, with Node's quoting): fs read / write grants matched on
278
- resolved paths at directory boundaries (`..` can't escape a grant),
279
- child process, worker, net, addon and WASI grants. Enforced with Node's
280
- `ERR_ACCESS_DENIED` (`permission`, `resource`) by the fs calls,
281
- `process.chdir`, child_process, workers, `net` and `dgram`;
282
- `process.permission` is `undefined` without the flag, as in Node.
283
- - **`worker_threads` port transfer, `resourceLimits` and `stdout` /
284
- `stderr: true`:** transferred `MessagePort`s relay over the worker link
285
- (both ways, close propagates), a worker's heap limit ends it with
286
- `ERR_WORKER_OUT_OF_MEMORY` and `stackSizeMb` caps goroutine stacks, and a
287
- worker's output is readable on `worker.stdout` / `worker.stderr`.
288
- - **`dgram` source-specific membership:** `addSourceSpecificMembership` /
289
- `dropSourceSpecificMembership` on Linux, macOS, the BSDs and Windows
290
- (`IP_ADD_SOURCE_MEMBERSHIP` / `MCAST_JOIN_SOURCE_GROUP`), with Node's
291
- errors and the unbound-socket bind.
292
- - **25 more performance probes** in `performance/`: object dictionaries,
293
- `Object.keys` / `entries` / `for…in`, spread and destructuring, optional
294
- chaining, Map iteration and number keys, array slicing and `for…of`, string
295
- methods, string `switch`, non-ASCII strings, `typeof` / `instanceof`
296
- narrowing, accessors, rest / spread arguments and `.call` / `.bind`,
297
- generator `.next()`, `Promise.all` / `.then`, regex callbacks, `JSON.parse`
298
- into `any`, `Math.imul` hashing, `bigint`, `Date`, typed arrays, `Buffer` /
299
- base64 / `TextEncoder`, iterator helpers and WebAssembly calls.
300
- `scripts/performance.mjs` now builds each probe in its own temp directory,
301
- so a perf run no longer clashes with a conformance run over `dist/`.
302
-
303
- ### Changed
304
-
305
- - `process.version` reports Node 26 (`v26.0.0`).
306
- - Removed, as in Node 25: `fs.F_OK` / `R_OK` / `W_OK` / `X_OK` (use
307
- `fs.constants`) and the `recursive` option of `rmdir`.
308
- - `assert.strictEqual` follows a custom message with the comparison, as
309
- Node 26 does.
310
- - `concat` on an `any` value spreads a typed array argument instead of
311
- nesting it.
312
-
313
- - **`Record<string, any>` views of `any` objects:** taking the view no longer
314
- lists, sorts and scans the object's keys each time. They are listed the
315
- first time something needs them (`Object.keys`, `for…in`, a delete, a new
316
- key), so a record read only by key costs one allocation. The
317
- `any-record-view` probe goes from 263 ms to 96.5 ms. A key added through
318
- the `any` object before the view's keys are first listed now shows up in
319
- them, as in JS.
320
- - **`push` regression fixed:** since 0.6.1, a single-value `arr.push(v)` was
321
- `arr = TnPush(arr, v)`, which stored the whole slice, with a GC write
322
- barrier, on every push. A push onto a variable or field is now
323
- `TnPushTo(&arr, v)`, which keeps the 2x growth and stores the slice only
324
- when it grows. `arr-push-index` goes from 105 ms back to 49.2 ms (it was
325
- 56 ms before the regression). The new probe `arr-push-local` measures
326
- pushes into short local and field arrays.
327
-
328
- ### Fixed
329
-
330
- - **A typed promise awaited through an unknown-typed value settled with the
331
- loop stopped:** `await somePromiseAsUnknown` (a `Promise<T>` behind an
332
- `unknown` / `any` slot) received from the channel with a raw receive, so
333
- a rejection resolved as `undefined` instead of throwing, and an
334
- asynchronous settle could deadlock the loop (`Promise.all`'s helper had
335
- the same receive). Both now settle with the recorded rejection and keep
336
- the loop running while they wait.
337
- - **A spread array literal used as a statement emitted invalid Go:** a void
338
- arrow's body like `use(() => [...arr])` or a bare ``[...arr];``
339
- statement became a bare `append(...)`, which Go rejects as unused.
340
-
341
- - **The self-hosted compiler's contextual typing is back, so
342
- `npm run bootstrap:check` holds again.** `Array.prototype.slice` / `indexOf`
343
- on a dynamic array (the AST's node lists) now dereference the parser's
344
- slice reference, which had made every callback parameter list look empty in
345
- the native build (`TnSlice` / `TnIndexOf`), and the handler tables and the
346
- compiler's own array/object callbacks are explicitly typed. The Temporal
347
- helper also self-compiles now, so `npm run build:native` works again.
348
- - **`navigator.language` no longer reports `C`:** a `LANG` / `LC_ALL` of
349
- `C.UTF-8` (Git Bash's default) passed the C-locale check before its codeset
350
- suffix was stripped, so the language was the one-letter `C`. The codeset is
351
- stripped first, and `C` / `POSIX` fall through to `en-US`
352
- (`lib-web-globals-node26.ts`).
353
- - **`??` on an array reference no longer turns null into an empty array:** a
354
- `RegExp.exec` miss or a `T[] | null` result used to be boxed as `&slice`,
355
- a non-nil `*[]T`, so `a ?? b` picked the null value. Boxing an array value
356
- into an array-reference slot now goes through `TnSlicePtr`, which keeps a
357
- nil slice nil (`lib-nullish-array-ref.ts`). This also lets the
358
- self-hosted compiler keep its concise `exec(...) ?? exec(...)` in
359
- `pushStatement`, and the bootstrap fixpoint still holds.
360
- - **A push on an array a container returns reaches the container:**
361
- `m.get(k)!.push(x)`, `m.getOrInsert(k, v).push(x)` and
362
- `m.getOrInsertComputed(k, fn).push(x)` now append through the stored
363
- reference instead of a local copy (`semantics-container-array-push.ts`).
364
- Local aliases of Map / Record elements and array fields share the
365
- reference too, and an `any[]` passed to a function is shared with the
366
- callee (`semantics-any-array-param.ts`). The same lowering covers a
367
- generic helper returning `V` bound to an array and an Array subclass's
368
- `push` (through its `TnItems()` reference), which also unbreaks the
369
- react-compiler example build.
370
- - **Optional access on a missed match:** `re.exec(s)?.[i]` is `undefined`
371
- when there is no match (the Go value is a nil `[]string`), not `''`, so a
372
- following `??` applies. It is also typed as nullable, so a variable holds
373
- the boxed value (`lib-nullish-array-ref.ts`).
374
- - **Key order of an `any`-typed object literal:** `const o: any = { b: 1, a: 2 }`
375
- now keeps the source order in `Object.keys`, `for…in`, `Object.entries`,
376
- spread and `JSON.stringify` (it became a Go map, whose keys come out
377
- sorted) (`semantics-any-literal-key-order.ts`).
378
- - **A missing key of a `Record` / `Map` of primitives reads `undefined`:**
379
- `rec[k] === undefined` and `map.get(k) === undefined` test key presence,
380
- not the value type's zero value (`semantics-record-missing-key.ts`).
381
- - **`x?.m()` on an `any` value with a primitive result:** a nullish receiver
382
- gives `undefined` (so `?? fallback` applies and `=== undefined` holds)
383
- instead of the type's zero value (`semantics-optional-any-call.ts`).
384
- - **`arr?.length` on an absent array is `undefined`:** a nil array is not a
385
- zero-length array, so `?? fallback` applies; a set-but-empty array reads
386
- `0` (`semantics-optional-array-length.ts`).
387
- - **An array read from an `any` object and pushed through an alias reaches
388
- the object:** `const l = o.list; l.push(x)` and `const l: any = o.list`
389
- share the object's array, as JS arrays do (`semantics-any-array-alias.ts`).
390
- - **Bigint–number loose comparisons:** `5n == 5`, `5n == '5'` and
391
- `false == 0n` compare by value through dynamic values; `===` stays false
392
- (different types), and the relational operators compare exactly, with NaN
393
- never ordered (`semantics-bigint-loose-ops.ts`).
394
- - **Destructuring past the end of an array is `undefined`** (the binding got
395
- the element type's zero value); a default still fills a missing element
396
- (`semantics-destructure-past-end.ts`).
397
-
398
- ## [0.6.2] - 2026-11-15
399
-
400
- ### Fixed
401
-
402
- - **Self-hosted native build:** `npm run build:native` failed with `cannot use
403
- typedClass (variable of type bool) as string value`. The transpiler typed
404
- `a && b` by its left operand, so a getter-lookup helper written as
405
- `leftGoType?.startsWith('*') && leftGoType.slice(1)` became a `bool` in the
406
- Go build. It is now written as a ternary that yields a string or
407
- `undefined`.
408
- - **`replace` with an inline `new RegExp(…, 'g')`:** only the first match was
409
- replaced, because the `g` flag was only seen on a regex literal or a
410
- `RegExp` read from a variable. Flags written out in `new RegExp(p, 'flags')`
411
- are now read at compile time, and any other `RegExp` expression (a call's
412
- result, flags computed at run time) is evaluated once and its `g` flag
413
- tested at run time. The self-hosted compiler relied on this to map string
414
- enums to `string` in `tnCallValueTyped`, so its build of
415
- examples/react-compiler failed with `duplicate case func(string,
416
- MemoizationLevel) MemoizationLevel in type switch`.
417
-
418
- ### Changed
419
-
420
- - **tsparser:** `github.com/go-json-experiment/json` bumped to v1.27.2.
421
-
422
- ## [0.6.1] - 2026-11-15
423
-
424
- ### Changed
425
-
426
- - **examples/react-compiler: faster than Node at 64 KB.** The React Compiler
427
- now runs a 64 KB component file in 615 ms vs Node's 1,030 ms (1.7x faster;
428
- it was 3.5x slower), and per call is 3.5x faster (100 vs 349 ms). Plain
429
- functions assigned to `NodePath.prototype` declare `this: NodePath`; that
430
- now types `__this` as the class, so Babel's per-node path maintenance
431
- (`visit`, `setScope`, `setContext`, `parentPath` walks) is direct field
432
- access instead of dynamic plan lookups. Dynamic calls of the program's own
433
- function types go through a generated `tnCallValueTyped` case per Go func
434
- type (no `reflect.Value.Call`), and optional calls to prototype methods
435
- added at run time are guarded dynamic calls. For large files the example
436
- compiles independent top-level functions in parallel worker processes and
437
- joins their output; under Node each worker re-imports the compiler, while a
438
- TypeNative worker starts from the compiled binary.
439
- - **Iterating class iterators through dynamic values:** `TnToArray` (used by
440
- spread, `Array.from`, destructuring and `for…of` on a dynamically typed
441
- value) recognizes a class's generator push form directly
442
- (`Symbol_iterator__seq`) and iterates it in place instead of finding
443
- `*[Symbol.iterator]()` through reflection, calling it and draining its
444
- channel on a goroutine. An interface-yield channel method also gets a direct
445
- type assertion. This is what Angular's `OpList` hit through an op's dynamic
446
- `handlerOps` / `trackByOps` fields; angular-templates' 64 KB run fell from
447
- about 600 ms to 305 ms (now 1.2x faster than Node), and per-call latency is
448
- 4.4x Node's (50 vs 219 ms).
449
- - **yaml-cli throughput:** `yaml --json` on a large, plain stream is split
450
- before the `---` lines that start its documents, and up to six worker
451
- processes compose runs of them and print their JSON arrays, which the main
452
- process joins. Directives, errors, warnings, CR line endings and
453
- collection-valued keys fall back to the normal `cli()` path (the example
454
- runs under Node too). On the 10 MB benchmark the complete process run is
455
- now 754 ms vs Node's 851 ms (median, 1.1x); the single-process path also
456
- got faster.
457
- - **Object conversions and dynamic writes:** conversion identity holds one
458
- weak pointer per conversion, sweeps dead entries in batches and keeps a
459
- recent cache; a fresh local object converted once is copied without an
460
- identity entry (`TnAsCopy`), and a conversion between two statically known
461
- struct types is emitted as a struct literal. `Object.assign({ defaults },
462
- typedSource)` sets the target's fields directly instead of through
463
- reflection, `obj[key] = v` on a plain object skips reflection
464
- (`TnSetProp`), and `s += chunk` for an untyped chunk appends in place
465
- instead of copying the whole string.
466
- - **List building:** a single-value `push` grows the backing slice by 2x
467
- (`TnPush`) rather than Go's 1.25x, whose repeated copies add up to about
468
- five times a long list's final memory.
469
- - **marked-cli throughput:** large markdown documents are parsed in up to six
470
- worker processes, one contiguous run of top-level sections each, with a
471
- sequential fallback (small inputs, reference link definitions, raw HTML
472
- blocks, CRLF, `--tokens`). On the example's 10 MB benchmark the complete
473
- process run is now 1.2x faster than Node (512 ms vs 596 ms); parity stays
474
- 2,859/2,859. The single-process parse also got faster: `[...s].length` /
475
- `[...s][i]` / `[...s].at(i)` no longer build rune arrays, truthiness-only
476
- `re.exec` runs `re.test`, nullable regex results box only on a match, greedy
477
- `[^x]+` runs use `IndexByte`, and the long-string ASCII cache and regex
478
- replacement builders no longer allocate per token.
479
-
480
- ### Fixed
481
-
482
- - **process.stdin:** `TnStdin` sets its `_stdinRef` hook through `setHook`
483
- again after the lazy emitter/hook state change; reading stdin no longer
484
- panics with `assignment to entry in nil map`.
485
- - **events.errorMonitor:** with only the two inline listeners, an `'error'`
486
- event calls an `errorMonitor` listener before the error listeners again (the
487
- lazy listener path skipped it, so the conformance probe saw `handler` first).
488
-
489
- ## [0.6.0] - 2026-11-13
490
-
491
- The React Compiler itself (`babel-plugin-react-compiler` + Babel + zod, ~470 vendored files)
492
- compiles React components and hooks to their auto-memoized form, natively, and an
493
- OpenAI-compatible chat client streams answers token by token. Getting there drove the round's
494
- transpiler fixes: JS object identity and callee write-back across Go conversions, one
495
- backtracking regex VM with JS semantics for every pattern, and module initialization in the
496
- import graph's evaluation order. TypeNative now requires Node.js 26. A `--profile` flag
497
- and two rounds of hot-path fixes (bitwise and `%` arithmetic, generators, Map / Set deletes,
498
- class dispatch, async functions and `JSON.parse`) narrow the gap with Node on the large
499
- examples: react-compiler runs 26% faster at 64 KB and angular-templates 17% faster.
500
-
501
- ### Added
502
-
503
- - **`--profile`:** the built program writes a CPU profile (`runtime/pprof`) to
504
- `$TYPENATIVE_CPUPROFILE` (default `cpu.pprof`) when it exits, on every exit
505
- path, for `go tool pprof`
506
- - **Performance probes:** `num-bitwise`, `num-mod-int`, `map-delete`,
507
- `gen-for-of`, `str-short-scan`, `str-concat-plus`, `regex-site`,
508
- `events-emit`, `async-await` and `exc-throw-rare`, covering what the large
509
- examples stress; `performance/README.md` lists each fixed and open cause
510
- - **examples/react-compiler:** the React Compiler (`babel-plugin-react-compiler` + Babel 7.29 parser/traverse/generator + zod 4, ~470 vendored files) compiling
511
- React components and hooks to their auto-memoized form, natively. The build
512
- drove a series of transpiler and runtime fixes (below); every fixture in
513
- `parity.mjs` — components, hooks, the compiler's pragmas, JSX outlining,
514
- TypeScript syntax and the error paths — now matches Node byte for byte,
515
- output, `// CompileSuccess` counts and error code frames included, and
516
- `bench.mjs` reports per-call latency and scaling
517
- - **JS object and array identity across Go conversions:** converting one
518
- object to another struct type gives the same converted object every time
519
- (Set / Map keys and `===` find it), and union and intersection members are
520
- views of the same memory; arrays stay shared through any-typed fields,
521
- getters, dynamic calls and `splice`; a callee's changes to a converted
522
- argument — an array, a Map or Set, an object's fields, through an
523
- override too — are written back to the caller's; `slice` copies
524
- - **JS semantics at the edges:** object-literal getters stay live (also when
525
- a function returns the literal as `{ value: T }`); `Object.prototype`
526
- methods read as values (`const toString = {}.toString`) run through
527
- `call` / `apply`; default parameters apply to an explicit or forwarded
528
- `undefined`; `null` stays apart from `undefined` where a function tests
529
- both; Map misses and unset optional enum fields fall back with `??`; keys
530
- written as `undefined` are own keys for `Object.keys`; `x.at(i)` and
531
- `?.push` work on arrays held as any
532
- - **Regex `v` flag (`unicodeSets`):** the backtracking VM now reads v-flag
533
- class set expressions: subtraction (`[\p{L}--[aeiou]]`), intersection
534
- (`[\p{Lu}&&[A-F]]`), nested and negated classes, and `\q{…}` strings, which
535
- are tried longest first. With `i`, each operand is case-folded before the set
536
- operation, as in JS. `v` implies unicode mode, and `re.unicodeSets` reports
537
- the flag. Until now these patterns went to RE2, which misread the class and
538
- matched the wrong text. Properties of strings (`\p{RGI_Emoji}`) aren't
539
- supported.
540
- - **examples/openai-chat:** a chat client for any OpenAI-compatible
541
- `/v1/chat/completions` API. Answers stream into the terminal token by token:
542
- `fetch` with a streaming response body (`response.body.getReader()`),
543
- hand-parsed server-sent events (`data:` lines, `[DONE]`, ignored keep-alive
544
- comments), an `AbortController` timeout, Ctrl+C aborting the answer in flight,
545
- and a `for await` readline REPL with `/clear` and `/system`. Targets the free
546
- OpenRouter API by default (`google/gemma-4-31b-it:free`), and OpenAI, Ollama
547
- or any other compatible server through `--base-url`. `bench.mjs` stands up a
548
- local mock SSE API, checks Node and TypeNative stdout byte for byte, then
549
- times full one-shot runs (1.2x faster per answer, 716 vs 875 ms median — both
550
- runtimes mostly wait on the mock's paced chunks). The example works around
551
- two catch-block sharp edges (`return`/`continue` inside `catch` compiles
552
- wrong or not at all), documented in its README
553
- - **conformance:** `lib-regex-engine`, `lib-string-long-slices` and
554
- `semantics-dynamic-field-access`, with expected values checked against Node
555
-
556
- ### Changed
557
-
558
- - **Node 26 and ES2025:** TypeNative now requires Node.js 26 or newer
559
- (`engines`), and CI runs on Node 26. Scaffolded projects (`--new`) and the
560
- default type-check (no `tsconfig.json`) target `es2025` instead of `es2020`,
561
- so target-gated syntax such as the regex `v` flag, regex modifiers and
562
- duplicate named groups type-checks. `useDefineForClassFields: false` is set
563
- alongside it to keep TypeScript's classic field order (parameter properties
564
- before field initializers), which is what TypeNative compiles. Existing
565
- projects that keep `target: es2020` are unaffected.
566
- - **Regex engine:** every `TnRegex` now runs on one backtracking VM with JS
567
- semantics (`src/regex_vm.ts`), replacing the closure-based backtracker and RE2
568
- as the first choice. Programs compile lazily and once per pattern and flags. A
569
- match allocates only its result, and first-byte sets, literal prefixes and
570
- anchors reject most calls without running anything. RE2 stays as a fallback
571
- for patterns it can run that exhaust the VM's step budget, so those keep their
572
- linear-time guarantee. Regex literals used inline get the same engine; only
573
- Node built-ins' arguments and `/(?<name>…)/.exec(s)` stay on plain RE2
574
- - **Dynamic values:** property reads and writes on objects held as any go through
575
- plans cached per type and key instead of reflection; a read consumed on the
576
- spot doesn't box its value; `obj.list.push(x)` appends in place instead of
577
- converting the array on every push; object-type conversions are compiled per
578
- pair of types; `Object.assign` between objects uses the same plans; `switch`
579
- on a dynamic value over string literals is a Go string switch
580
- - **Strings:** long strings grown with `+=` on a dynamic value are amortized;
581
- short ASCII strings need no code-point index
582
- - **Performance:** on 10 MB of input, examples/marked-cli went from 5.5x to 1.6x
583
- slower than Node and examples/yaml-cli from 3.8x to 1.9x (the native binary
584
- now finishes first up to about 1–2 MB per run), and marked's ReDoS inputs from
585
- over 72 s to 4.7 s in total
586
- - **Hot paths:** bitwise operators no longer call `math.Mod` (`TnInt32`
587
- converts in-range values directly, literal operands fold, nested bitwise
588
- expressions stay int32); `%` on integers is an `int64` remainder; a sync
589
- generator iterated by `for…of` runs as a Go range function instead of a
590
- goroutine in lockstep (break and throw keep JS's `finally` / `catch`
591
- semantics); `Map` / `Set` deletes are O(1) and key handling takes no
592
- reflection; `s = s + …` appends in place like `s += …`; `charCodeAt` over
593
- short strings no longer rescans the string; `toFixed` skips exact
594
- 1100-digit formatting except on ties; any-typed objects read their map
595
- first; `Record<string, any>` views of an any object share its map;
596
- common listener shapes are called without reflection; regex literals
597
- share their compiled program per site. Probe medians: bitwise 2160 →
598
- 129 ms, `%` loops 4527 → 162 ms, generators 1843 → 12 ms (now 4.4x faster
599
- than Node), `Set` churn 1556 → 97 ms. examples/react-compiler at 64 KB
600
- runs 26% faster (7.5 s → 5.6 s, interleaved against the previous build)
601
- - **Dispatch, async and JSON hot paths:** a generator method called on a
602
- value typed as a base class or interface (`unit.ops()`) runs its push form
603
- through `TnCallSeq_<m>`, lazily as JS does (it used to collect every value
604
- before the loop ran), and spread / `Array.from` of a generator collect its
605
- push form into a typed slice; a method call through a class or interface
606
- hierarchy whose implementations share a signature goes through a typed
607
- dispatcher, without boxing; async functions that never wait on anything
608
- pending run on the caller's goroutine, and settling a promise no longer
609
- allocates when nobody waits; `JSON.parse(text) as T[]` decodes straight
610
- into `T` when the text matches it; `for` loop counters and bitwise-result
611
- consts are Go integers. Probe medians: `async-await` 1985 → 201 ms,
612
- `class-dispatch` 709 → 124 ms, `json-roundtrip` 347 → 97 ms, `num-bitwise`
613
- 128 → 114 ms; examples/angular-templates at 64 KB runs 17% faster (721 →
614
- 601 ms, interleaved against the previous build)
615
-
616
- ### Fixed
617
-
618
- - **`null` is not `undefined`:** `typeof null` is `"object"` (it gave
619
- `"undefined"`), `String(null)` and `null` in `+` / template strings give
620
- `"null"` (`String(null)` printed `<nil>`), and `null` declared or assigned
621
- into an `any` / `unknown` variable stays JS null
622
- - **Classes with `*[Symbol.iterator]()`:** instances destructure
623
- (`const [a, b] = bag`, reading only as many values as are bound, so an
624
- endless iterator ends and its `finally` runs), spread into call and `new`
625
- arguments (`Math.max(...bag)`, `f(...bag)`), and `bag[Symbol.iterator]()`
626
- is a generator of its own; subclasses inherit all of it. Spreads that are
627
- not the only argument of a rest parameter (`f(1, ...xs, 2)`,
628
- `f(...xs, ...ys)`) now compile, for arrays too
629
- - **Spread of a generator into arguments:** `f(...gen())` into a rest
630
- parameter failed to compile, and `xs.push(...unit.ops())` through a
631
- dynamic receiver asserted the generator's channel to an array
632
- - **`(-Infinity).toFixed(n)`** returns `"-Infinity"` (it printed `-Inf`)
633
-
634
- - **Namespaces of types only:** `namespace Tokens { export interface Def … }`
635
- is flattened like any namespace (`Tokens_Def`) instead of being dropped, so
636
- `Tokens.Def` resolves to its declaration (an unmatched regex group stored in
637
- one of its `string` fields stays `undefined` and `JSON.stringify` leaves it
638
- out: marked's `--tokens` printed `"title": ""` for a link definition without
639
- a title). Only type references `Ns.T` are rewritten for such a namespace, so
640
- a class merged with it keeps its value reads (`Scope.x`, `typeof Scope.x`)
641
-
642
- - **Converting an object to a wider struct no longer reads or writes past
643
- it:** a conversion whose source struct's fields are a prefix of the
644
- target's (a member held in a merged union's slot) used to view the source's
645
- memory as the target, so the target's extra fields lay past the object — in
646
- the next object, or in size-class slack the garbage collector doesn't scan
647
- for pointers. Such a view is now made only where the object's memory is
648
- known to cover the target: a union narrowed to a member and widened back,
649
- or an object literal allocated union-sized (an object literal whose struct
650
- is a strict prefix of merged unions now gets room for their fields, with
651
- the pointer layout they share, so a member held in a union's slot stays the
652
- one object). Every other such conversion copies, through the identity
653
- cache. (A literal's struct read as the interface it matches plus the
654
- interface's key list `__keys` read the key list from whatever followed
655
- the literal: `JSON.stringify` crashed on marked's table cells)
656
- - **Module initialization order:** a program's module-level code now runs in
657
- the import graph's evaluation order, as JS evaluates it — each module after
658
- the modules it imports, with an import cycle's back edge not waiting (the
659
- way Node starts evaluating a cycle mid-way through a module). It used to be
660
- the emission order, which a cycle (the React Compiler's entrypoint barrels,
661
- zod's) evaluates differently, leaving re-exported values uninitialized.
662
- Imports whose bindings the code never uses as values — which tsc's emit
663
- elides — no longer order inits either
664
- - **`new F(…)` on a constructor-function value** now has JS `new` semantics:
665
- the function runs with `this` a fresh object, which it may return or fill
666
- (zod's `$constructor` factories read `this`); it used to be a plain call,
667
- so a function reading `this` saw nothing
668
- - **`fn.bind(…)` on a function value held as any** returns a bound function
669
- (with the bound `this` and prepended arguments) instead of failing with
670
- "bind is not a function"
671
- - **`Object.assign(fn, props)`** copies the properties onto the function
672
- value, where `fn.prop` reads them, instead of dropping them
673
- - **`C.prototype[k] = fn` with a computed key** adds the method to the
674
- class's prototype (its instances call it with `this` the instance) instead
675
- of failing
676
- - **A dynamic array method whose name a class or object literal declares
677
- too** (`values.map(…)` beside a `Result.map`) runs the array method on
678
- arrays and dispatches to the class on class instances, decided at run time
679
- - **`x ??= v` on a nullable array variable** tests the reference itself
680
- instead of dereferencing it, which panicked when it was unset
681
- - **An empty object literal (`{}`) is no longer a zero-size Go value** — Go
682
- gives every zero-size value the same address, which made every `{}` in a
683
- program one shared object (each zod schema's internals landed in one place,
684
- every schema reading the last-written definition)
685
- - **Properties set on dynamic objects** are keyed by the object itself, so a
686
- garbage-collected object's address being reused cannot hand its properties
687
- to the new object
688
- - **`Object.assign`/spread into a fresh object** skips a struct's internal
689
- `__`-prefixed fields
690
- - **A property assigned a value its field's Go type can't hold** now replaces
691
- the property, as in JS: the field reads as undefined and the value is kept
692
- beside the object (`Object.defineProperty`-style visitors — Babel's traverse
693
- `explode` replaces a visitor function with `{ enter: fn }`) instead of
694
- leaving the stale value readable and dropping the assignment. Reads fall
695
- through a nil reference field to what was set beside the object, and
696
- `Object.defineProperty` with a getter/setter now defines a real accessor on
697
- class instances too (Babel's ParseError computes its `message` in a getter
698
- that self-assigns); it used to silently support them only on dynamic objects
699
- - **A call's argument converted to a copy the callee changes** is written back
700
- at every statement position (plain calls, `x = f(op)`, `const x = f(op)`,
701
- `return f(op)`), including arguments written `node as SomeType` and calls
702
- through a mixin's virtual table, when the callee mutates the parameter's
703
- fields — directly or by passing it on to a function that does. The fields it
704
- changes are copied back to the original object, and ones the original's type
705
- has no slot for are kept beside it (Babel's parser passes its nodes between
706
- `parseExport`/`maybeParseExportDeclaration` and reads the fields back on the
707
- original); the copy's changes used to be lost, emptying the parse result
708
- - **`arr.push(x)` on an array read out of a container** (`aliases[k].push(x)`,
709
- a Map's array value) stores the appended array back into the container, as
710
- push mutates it in JS; it used to append to a copy and drop it, which left
711
- @babel/types' alias tables empty and its node validators rejecting every node
712
- - **A class instance passed where an interface type is expected** converts
713
- with the properties it carries beyond its class filling the interface's
714
- fields (Babel's parser keeps `imported`/`local` of an import specifier on a
715
- bare Node); the conversion used to build a zero-filled struct
716
- - **`f?.call(thisArg, …)` on a function value** calls nothing when f is unset
717
- (an optional callback parameter's Go func type is nil); it used to deref nil.
718
- A `do { … = this.parseSubscript(…, state) } while (!state.stop)` also no
719
- longer loops forever: the state object the callee writes through the
720
- converted parameter is written back
721
- - **An intersection type alias** (`ParseResult<File> = File & { … }`) compiles
722
- to a struct with every member's fields, and an interface renamed for a
723
- cross-module name collision still resolves its fields (and shadows a Node
724
- global's type) through the original name — the parser's `File` used to
725
- convert to a 3-field struct and Node's `File` global type leaked into Babel's
726
- - **A nullable array parameter with a default** (`tokens: Token[] | null =
727
- null`) reads as nil when absent instead of dereferencing nil
728
- - Optional chain calls guard the receiver, and a function's result type drives
729
- `return f(…)` conversions again after the write-back change
730
- - **A destructured binding of an object's array field** binds the array
731
- itself, as in JS: push/pop/splice through it mutate the field's array
732
- (`const { context } = this.state` then `context.push(…)` in Babel's JSX
733
- tokenizer); it used to bind a copy and drop every mutation, flattening the
734
- tokenizer's element context stack
735
- - **An array stored into a dynamic object is kept as a reference**, as JS
736
- arrays are shared: a push through any binding of the value reaches the
737
- object's entry (`(ids[name] = ids[name] || []).push(…)` building Babel
738
- traverse's Scope binding tables); the push used to append to a copy and
739
- never register a binding, which rejected every node in Scope's validators.
740
- `push`/`pop`/`shift`/`unshift` work on such references held as any
741
- - **`x.push(…)` on an expando-stored array** (a bare parser Node's `body`)
742
- appends to the array the object holds; it used to append to a copy and drop
743
- it, which emptied every statement list the compiler's lowering walked
744
- - **A mixin virtual method call returns its implementations' result** even
745
- when an abstract declaration types it `: void` (Babel:
746
- `return this.parseObjPropValue(prop, …)` over an
747
- `abstract parseObjPropValue(…): void`); the returned node used to be
748
- dropped, which made the compiler lower every function body to nothing
749
- - **conformance:parallel:** example builds get the 10-minute budget the
750
- sequential runner already gave them (the vendored-package examples
751
- transpile tens of thousands of lines and go build the result — the React
752
- Compiler example used to be killed at 90 s and reported as a bare `exit 1`),
753
- and the largest example runs alone before the pack
754
- - `.`, `^` and `$` follow JS's line terminators in every regex, `[]` and `[^]`
755
- mean what they do in JS, captures reset on each loop iteration, and `\p` is a
756
- property only with the `u` flag
757
- - `\k<name>` in a regex literal panicked in RE2
758
- - Slices of a long non-ASCII string rebuilt its whole index each time, making a
759
- lexer over non-ASCII input quadratic
760
-
761
- ## [0.5.0] - 2026-11-01
762
-
763
- The `yaml` package's own CLI, compiled from its unmodified TypeScript source, as the first
764
- flagship example: 100% output parity with Node on the yaml-test-suite in all four modes. Getting
765
- there took transpiler fixes across the board, each with a conformance probe.
766
-
767
- The second flagship example is the `marked` package's own CLI, compiled from marked's unmodified
768
- TypeScript source: 100% output parity with Node on marked's spec suites (CommonMark, GFM and its
769
- own tests, ReDoS inputs included) in three modes. Its fixes are listed under **marked** below.
770
-
771
- ### Added
772
-
773
- - **Native app windows:** programs can open webview windows through the
774
- `@webviewjs/webview` API, so the same source runs under Node.js (the npm package) and compiled
775
- (built in). Windows embeds the system WebView2 through the vendored, pure-Go
776
- `jchv/go-webview2`; macOS and Linux, and Windows without the WebView2 runtime, open Chrome, Edge
777
- or Chromium in app mode. No cgo, and cross-compiling still works. The macOS and Linux path builds
778
- in CI but has not been run on those systems
779
- - **`--gui`:** builds a windowed app with no console window on Windows (ignored for other targets)
780
- - **examples/marked-cli:** marked v18.1.2 vendored unpatched (`vendor/marked/VENDOR.md`),
781
- `main.ts` porting upstream's `bin/main.js`, `parity.mjs` (2,859 cases: marked's commonmark,
782
- gfm, new, original and redos specs in default, `--no-gfm` and `--tokens` modes, compared byte
783
- for byte with Node) and `bench.mjs` (per-call latency on marked's README, throughput on ~10 MB
784
- of generated markdown)
785
- - **marked:** function declarations inside functions and blocks (hoisted; async and generator
786
- ones too); `f.apply` / `f.call` on functions held as `any`; `Ns.T` of a namespace another
787
- module declares; generic interfaces used without type arguments, interfaces extending
788
- `Omit<>` / `Pick<>` / `Partial<>`, open object types and array types with properties
789
- (`T[] & { links: L }`); `process.stdout.write(data, callback)`; `split(sep, limit)` with a
790
- RegExp
791
-
792
- - **examples/yaml-cli:** yaml v3.0.0-2 vendored unpatched (`vendor/yaml/VENDOR.md`), `main.ts`
793
- porting upstream's `bin.js`, `parity.mjs` (1,608 cases from yaml-test-suite data-2022-01-17
794
- in default, `--json`, `valid` and `lex` modes, compared byte for byte with Node) and
795
- `bench.mjs` (per-call latency on a docker-compose.yml, throughput on ~10 MB of generated
796
- Kubernetes manifests)
797
- - `new Map(iterable)` from Maps, iterators, generators and `Object.entries`; plain objects and
798
- arrays as Map keys and Set members, by identity (they panicked as unhashable); generic type aliases
799
- (`type WithId<T> = T & { id: number }`); instantiation expressions (`g<number>`) and explicit
800
- type arguments in call results; `typeof f` as a function type
801
- - `emitWarning(warning, type)`; `JSON.stringify(buffer)` as `{ type: 'Buffer', data }`
802
-
803
- ### Changed
804
-
805
- - **examples/desktop-notes:** the UI now opens in a real webview window under both Node.js and
806
- TypeNative, instead of launching Edge or Chrome with `--app`. Closing the window ends the app
807
- directly, so the `/api/bye` beacon and the heartbeat timeout are gone. Running it under Node.js
808
- now needs `npm install` in the example folder
809
-
810
- ### Fixed
811
-
812
- - **marked — arrays:** arrays are shared as in JS: an object type's array field, an `any[]`
813
- variable and a parameter holding one array see each other's pushes, also through `any`
814
- (`tok.tokens.unshift(…)`); a method returning its array argument returns that array
815
- - **marked — regexes:** JS escapes (`\xHH`, `\u{…}`, `\cJ`, `\p{…}`, `\k<name>`) and JS's
816
- Unicode `\s` in every pattern, also in the backtracking engine; RegExp values stored in
817
- objects, built at run time and called through `any`; regexes that look behind the match
818
- (`^`, `\b`) at a non-zero offset; unmatched groups stay `undefined` through consts,
819
- conditionals and `string` fields (left out of JSON)
820
- - **marked — strings and objects:** `toUpperCase` / `toLowerCase` map case as JS does (`ß` →
821
- `SS`, `İ` → `i̇`, final `ς`); `trim` uses JS's whitespace; `replace` with a `string | RegExp`
822
- pattern or a function value; JSON key order of object literals that list keys in another
823
- order than their type; `string | null` fields keep `null` and `undefined` apart (an optional
824
- one is an any field; a required one is written as `null` by `JSON.stringify`)
825
- - **marked — type inference:** `let x;` assigned on every path holds its value type; long call
826
- chains on a fluent builder (`edit(re).replace(…).replace(…)…`) no longer take exponential time
827
- (inference is memoized per query); module-level names a local shadows; a `for…of` whose body
828
- never reads its variable compiles
829
- - **marked — performance:** the regex backtracker works on byte offsets (no rune conversion of
830
- the input per match), repeats a single character class without allocating and tests ASCII
831
- against a table; regexes skip ahead with a first-byte prefilter (an anchored one fails at
832
- once) instead of running RE2 over the rest of a long input; strings built with `+=` in a loop
833
- are `strings.Builder`s. Rendering is now linear in the input
834
- - **marked — self-hosting:** the native compiler builds and `npm run bootstrap:check` holds
835
- with this round's changes: a function literal stored where a function type is expected takes
836
- that type's (plain slice) array parameters, and a function value with array-reference
837
- parameters is adapted where plain slices are expected; a string-method name that some object
838
- literal's function also has (`x.startsWith(…)` on an any value) runs the string method on a
839
- string; functions in a `Record<K, F>` dictionary no longer count as such methods; a `+=`
840
- string accumulator used in a closure stays a plain string
841
- - **Regexes:** unmatched groups are `undefined`; `new RegExp(src, 'g' | 'y')` keeps its flags;
842
- `$&`, `` $` ``, `$'`, `$<name>` and `$$` replacements; replacer callbacks get the match offset
843
- and the input
844
- - **Objects:** `Object.assign({}, typed, overrides)` keeps the type and its function fields, and
845
- an explicit `undefined` override clears; integer-like keys of plain objects come first;
846
- `x.constructor` on any values; `null` in JSON and `any` data stays `null` (not `undefined`)
847
- - **Classes:** a class picked at run time or passed as `new (…) => T` constructs; `this.name` in
848
- an Error subclass; optional array parameters passed on to defaulted ones (`super(items)`);
849
- `x as unknown as T[]` returns the value as is
850
- - **Numbers:** `toFixed` rounds ties away from zero, also on `any` values and in callbacks
851
- - **Control flow:** `for (; …; a, b)` with no initializer; function properties assigned twice;
852
- unread `for (const [k, v] of map)` bindings; `instanceof Date` narrowing
853
- - **Type inference:** user-defined type guards (`(t): t is string`) narrow their argument; a
854
- conditional's branches are typed with the condition's narrowing; array callbacks' locals are
855
- typed from their own declarations; `o?.m()` and `o?.push(x)` on any values don't call through
856
- a nullish `o`; `flatMap` callbacks returning any values; a function declared to return
857
- `T[] | undefined` keeps `undefined` (it was an empty array); `xs[i] ?? d` over
858
- `(T | undefined)[]` elements; object literals assigned into any
859
- slots stay extensible
860
- - **Self-hosting:** the native compiler builds again (`npm run build:native`; it also failed on
861
- 0.4.2's coverage code) and `npm run bootstrap:check` holds: it turns its own source into the
862
- same Go as the Node CLI. The compiler's code no longer reads missing `Map` / `Record` keys
863
- as `undefined` (natively they read as `''`)
864
- - **Performance:** string positions on long inputs no longer rebuild their code-point index per
865
- regex match (quadratic lexing); struct field lookups and struct-to-struct copies are cached
866
-
867
- ## [0.4.2] - 2026-10-28
868
-
869
- `node:test` reporters, `run()`, coverage, snapshots and member mocks; four runnable examples
870
- with Node-vs-TypeNative benchmarks, examples type-checked and built by the conformance suite,
871
- and compiler fixes for names that shadow Go types, rest destructuring, number formatting, and
872
- `Number()` on optional values.
873
-
874
- ### Added
875
-
876
- - **`node:test`:**
877
- - `run({ files })`: files with literal paths compile in as entry points and run as child
878
- processes; their events stream back on a TestsStream — top-level numbering continues across
879
- files, child output becomes `test:stdout` / `test:stderr`, per-file summaries and coverage
880
- merge, and listeners get typed data (`run(…).on('test:fail', (data) => …)`)
881
- - coverage with `--experimental-test-coverage`: programs that import `node:test` count what
882
- runs over V8-style source ranges (functions, blocks, ternary arms, `&&` / `||` / `??`
883
- operands, class field initializers), with `node:coverage ignore` comments, `--test-coverage-include` /
884
- `-exclude` and the `-lines` / `-branches` / `-functions` thresholds; the lcov records and
885
- the tap / spec coverage table match Node's output
886
- - snapshots: `t.assert.snapshot` / `t.assert.fileSnapshot` with `--test-update-snapshots`
887
- (Node's `<test file>.snapshot` format), `snapshot.setDefaultSnapshotSerializers` /
888
- `setResolveSnapshotPath`; a missing file or entry names the update flag
889
- - `mock.method` / `mock.getter` / `mock.setter` on object literals, class instances
890
- (inherited members included, other instances unaffected) and namespace functions
891
- (`console.log`, `Math.random`, …); `.mock` reads the call record, `t.mock` restores after
892
- each test
893
- - failing tests report their `location` (`file:line:col`) in TAP, spec and junit
894
- - `--test-reporter-destination` pairs with `--test-reporter` (a file, `stdout` or `stderr`)
895
- - **`node:test/reporters`:** `tap` / `dot` / `junit` as generator functions over an event
896
- source (an array, an async generator, a stream such as `run()`'s) and `spec` / `lcov` as
897
- Transform streams for `compose()` — Node's output, byte for byte
898
- - **Streams:** `compose()` (pipe into a stream, or hand the source to a function — an async
899
- generator over the chunks, a reporter), and `.on()` / `.once()` return the stream, for
900
- chaining as in Node
901
- - **Types:** `AsyncIterable<T>` / `AsyncIterableIterator<T>` / `AsyncGenerator<T>` map to
902
- channels (like `Promise<T>`), so async-iterable parameters type-check
903
- - **Examples:** `todo-cli`, `dupe-finder`, `mandelbrot-png` and `desktop-notes` (a notes app in an
904
- Edge/Chrome app window), each with a Node-vs-TypeNative benchmark
905
- - **Conformance:** every `examples/*/main.ts` is type-checked and built by the suite as
906
- `example-<name>`
907
-
908
- ### Changed
909
-
910
- - `conformance.md` lists npm packages published only as JavaScript/CommonJS as 🚫 (their
911
- implementations have no types to compile from), not ❌
912
-
913
- ### Fixed
914
-
915
- - **Object-literal methods:** reading one as a value (`const f = obj.method`) no longer calls
916
- it; getters still run on read, including when destructured (`const { double } = calc`)
917
- - **`node:stream`:** programs that use streams but not `util.inspect` compile again (a
918
- `compose()` error message referenced `util.inspect`'s helper)
919
- - **Names:** variables and parameters named like Go types (`string`, `bool`, `int32`, ...) no
920
- longer shadow the type; methods named like Go builtins (`copy()`, `len()`, `static make`) are
921
- callable (the declaration was renamed, the call wasn't), and inherited methods named like Go
922
- keywords (`range()`) compile
923
- - **Destructuring:** `const [a, ...rest] = arr` gives `rest` the remaining elements (it compiled to
924
- a single element)
925
- - **Numbers:** `String(n)`, templates and `JSON.stringify` print non-integers in plain notation
926
- from `1e-6` up to `1e21` (`1761603012345.678`, not `1.761603012345678e+12`), and exponents
927
- without padding (`1e-7`, not `1e-07`)
928
- - **`Number()`:** converts optional strings and booleans (`Number(s)` with `s: string | undefined`
929
- gave `NaN`)
930
- - **Conformance:** the detached child-process probe no longer spawns Unix `sleep` on Windows
931
-
932
- ## [0.4.1] - 2026-10-24
933
-
934
- Node-accurate JSON (`stringify` with spacing and replacers, `parse` with a reviver, and JSON
935
- modules), regexes with JS semantics that no longer re-scan the whole string on global matches,
936
- `Date` and error-stack parity, generator iterator helpers, `go:embed` and
937
- `go:runtime/coverage`, seven more Go bridge packages, and `async` calls that start when the
938
- statement runs.
939
-
940
- ### Added
941
-
942
- - **`JSON.stringify`:**
943
- - `space` (number or string) with Node's layout
944
- - replacer functions and key lists
945
- - `toJSON()` methods
946
- - Dates as ISO strings, `Map` / `Set` as `{}`
947
- - `TypeError`s for circular structures and bigints
948
- - **`JSON.parse`:** reviver, and a `SyntaxError` for invalid JSON (it returned `null`)
949
- - **Arrays:** writing past the end grows the array
950
- - **Classes:** polymorphic `this` return types (fluent builders), and `obj[key]` on class
951
- instances and typed objects
952
- - **Generators:** iterator helpers (`map`, `filter`, `take`, `drop`, `flatMap`, `toArray`,
953
- `forEach`, `some`, `every`, `find`, `reduce`), `Iterator.from` and `next()`
954
- - **Weak references:** `WeakRef` / `FinalizationRegistry`
955
- - **`Date`:**
956
- - `new Date(string)` (ISO and the formats `toString` / `toUTCString` produce), and
957
- `new Date(y, m, d, …)` in local time
958
- - `Date.parse`, the setters (`setHours`, `setUTCDate`, …), `getTimezoneOffset`
959
- - `toUTCString`, `toLocale*String` (en-US)
960
- - Node's `toString` format for `String(date)` and templates
961
- - Invalid Dates (`getTime()` is `NaN`)
962
- - **Errors:** `err.stack` lists the TS frames (`at fn (file.ts:line)`); `AggregateError`
963
- - **Functions:** `fn.bind`, `fn.name`, `fn.length`; `apply` on non-variadic functions, and
964
- `call` / `apply` on function declarations
965
- - **Statics:** `Promise.withResolvers`, `Promise.try`, `Object.is`, `Object.groupBy`,
966
- `Map.groupBy`, `Array.of`, `Symbol.for` / `keyFor` / `description`, `BigInt()`,
967
- `BigInt.asIntN` / `asUintN`
968
- - **`Number`:** `toExponential`, `isSafeInteger`, `parseInt` / `parseFloat`, `MIN_VALUE`,
969
- `NEGATIVE_INFINITY`
970
- - **`Math`:** `fround`, `imul`, `clz32`, `asinh` / `acosh` / `atanh`, `sumPrecise`
971
- - **`String`:** `codePointAt`, `String.fromCodePoint`, `substr`, `trimLeft` / `trimRight`,
972
- `isWellFormed` / `toWellFormed`, `toLocaleUpperCase` / `toLocaleLowerCase`, `split` limit,
973
- `lastIndexOf` position
974
- - **`process`:** `stdout.columns` / `rows` / `getWindowSize()` (and `stderr`),
975
- `stdin.setRawMode` / `isRaw` (undone at exit), `umask`, on Linux, macOS, FreeBSD and Windows
976
- - **`node:readline`:** `emitKeypressEvents` and `'keypress'` events (Node's key decoder)
977
- - **`node:child_process`:** `spawn` `detached`, `child.unref()` / `ref()`
978
- - **`node:dgram`:** multicast (`addMembership` / `dropMembership`, `setMulticastInterface`), and
979
- `setBroadcast` / `setTTL` / `setMulticastTTL` / `setMulticastLoopback` take effect (they were
980
- accepted and ignored)
981
- - **Errors:** `err.errno` and `util.getSystemErrorName` / `Message` / `Map` use Node's numbers for
982
- the target OS (libuv's table: `ENOENT` is `-4058` on Windows, `ECONNREFUSED` `-61` on macOS) and
983
- libuv's messages; `getSystemErrorMap` has all 85 entries in Node's order
984
- - **`node:dns`:** `resolveAny` / `resolveCaa` / `resolveNaptr` / `resolvePtr` / `resolveSoa`,
985
- `resolve4` / `resolve6` with `{ ttl: true }`, and the `Resolver` `tries` option
986
- - **`node:module`** (`builtinModules`, `isBuiltin`), **`node:v8`** (`getHeapStatistics`,
987
- `serialize` / `deserialize`) and **`node:sea`** (`isSea`)
988
- - **`node:crypto`:** `Hash` / `Hmac` as streams; AES key wrap ciphers (`id-aes*-wrap`,
989
- `id-aes*-wrap-pad`)
990
- - **`node:http`:** `res.addTrailers()`
991
- - **JSON modules:** `import data from './x.json' with { type: 'json' }` and
992
- `createRequire(import.meta.url)('./x.json')`, read at compile time
993
- - **Workers and `fork` for another file:** `new Worker('./worker.ts')` / `fork('./child.ts')` compile
994
- that file into the binary as a second entry point, run in the child process
995
- - **`node:test`:** `--test-name-pattern`, `--test-skip-pattern`, `--test-only` and
996
- `--test-reporter` (`tap`, `spec`, `dot`, `junit`) from `NODE_OPTIONS`; Node's notice for `.only`
997
- without `--test-only`
998
- - **`node:stream`:** `'readable'` events and Node's `read()` / `read(size)`
999
- - **`node:sqlite`:** statements are finalized once garbage-collected (they lived until
1000
- `db.close()`); `db.serialize()` / `db.deserialize()`
1001
- - **Go bridges:** a probe for every bridged `go:` package, new ones for `debug/*`, `log/syslog`,
1002
- `math/cmplx`, `net/http/fcgi`, `net/rpc`, `net/rpc/jsonrpc`, `net/smtp`, `testing/cryptotest`,
1003
- `testing/slogtest` and `testing/synctest`. Along with them:
1004
- - `pkg.T` in type annotations is the Go type (`let d: dwarf.Data | null = null`,
1005
- `(t: testing.T) => …`)
1006
- - `ref.value` can be written (`r.value = x`), also through `GoRef<T>` parameters, so TS classes
1007
- can be `net/rpc` services
1008
- - `chan<T>()` makes a `chan T`
1009
- - TS records pass where Go takes a `map[K]V`
1010
- - callbacks whose Go signature returns `(T, error)`
1011
- - **`go:embed`:** `embed.string(path)`, `embed.bytes(path)` and `embed.files(...patterns)` (an
1012
- `embed.FS`) compile to `//go:embed` vars; the CLI copies the files next to the Go sources
1013
- - **`go:runtime/coverage`**, with a `--cover` CLI option that builds with coverage counters. Probes
1014
- can pass CLI options with a first line like `// conformance-flags: --cover`
1015
-
1016
- ### Fixed
1017
-
1018
- - **Regex performance:** global `replace` / `split` / `matchAll` and backreference or
1019
- lookaround patterns no longer re-scan the whole string for every match (quadratic on long
1020
- input); the self-hosted compiler builds itself ~10× faster
1021
- - **Regex empty matches:** `/g` patterns can match empty at the end of input
1022
- (`'abc'.replace(/x*/g, '-')` is `-a-b-c-`)
1023
- - **Regex `split`:** follows JS: capture groups are included (`'a1b'.split(/(\d)/)` is `a`,
1024
- `1`, `b`), `limit` is honored, and empty matches split like JS
1025
- (`'aXbXXc'.split(/(?<=X)/)` is `aX`, `bX`, `X`, `c`)
1026
- - **Match `.index`:** `exec`, `match` and `matchAll` results have `.index` (a compile error
1027
- before); `search` returns a character index (it returned a byte offset)
1028
- - **`match` with `/g`:** returns every match (it returned the first match's groups)
1029
- - **Arrays as strings:** `arr.toString()`, `String(arr)` and `` `${arr}` `` join elements with
1030
- commas (they printed Go's `[a b]`)
1031
- - **`node:dns`:** `resolve(name, 'PTR')` queries the name's PTR records (it did a reverse lookup)
1032
- - **Templates:** `${err}` on an `Error` builds and prints `Name: message` (`null` when null)
1033
- - **`Date` annotations:** `let d: Date`, `Date` parameters, return types, fields and `as Date`
1034
- compiled to an undefined Go type
1035
- - **Named imports of Node values:** `import { METHODS } from 'node:http'` keeps its array type
1036
- (`METHODS.includes(…)` compiled as a string method)
1037
- - **`console.log` / `inspect`:** Maps and Sets nested in objects print as `Map(n) {…}` /
1038
- `Set(n) {…}` (string-keyed Maps printed as plain objects)
1039
- - **Worker messages / `v8.deserialize`:** Sets arrive as Sets and both pass `instanceof`
1040
- - **`Array<T>` / `ReadonlyArray<T>` annotations** compiled to an undefined Go type
1041
- - **`stream.push(cond ? text : null)`:** a nullable string is a chunk or the end of the stream
1042
- (`null` through it never ended the stream)
1043
- - **`hmac.digest()` a second time** returns an empty result, as in Node (it threw)
1044
- - **Destructured callback parameters** (`([k, v]) => …`, `({ a }) => …`) in `map` / `filter` & co.
1045
- were unsupported syntax
1046
- - **`[...map]`, `map.entries()`** and **`{ ...record, k: v }`** (such as `{ ...process.env }`)
1047
- did not build
1048
- - **`+` on two dynamic values** concatenates when one is a string (`'a' + 1` gave `1`)
1049
- - **`Object.keys` / `values` / `entries` and `for...in`** on typed objects (interfaces, object
1050
- literals, class instances) did not build
1051
- - **`JSON.parse`:** objects keep the text's key order (they came out sorted)
1052
- - **Indexing a typed array held as `any`** (`record.list[1].id`) gave `undefined`
1053
- - **Worker / IPC messages and `v8.deserialize`:** objects keep their key order (they arrived
1054
- sorted), records arrive as plain objects rather than `Map`s, and both convert to typed
1055
- `Record` fields
1056
- - **Optional method calls as statements** (`port?.postMessage(x)`) on `void` methods, and
1057
- `process.send?.(…)` / `process.disconnect?.()`, did not build
1058
- - **Dates:** local getters on `new Date(ms)` used UTC
1059
- - **Async arrows:** async arrows kept as values return promises (`return` of a plain value didn't
1060
- build)
1061
- - **`.then` on async calls:** the call starts when the statement runs, like JS (it started inside
1062
- the background goroutine, where `exec()` registering its listeners off the event loop could
1063
- race it)
1064
- - **Maps:** `[...map.keys()]` / `[...map.values()]` build
1065
- - **Optional chains:** comparing an optional chain or an `any` value with `null` / `undefined`
1066
- sees a nil pointer inside it
1067
- - **`length` fields:** `obj.length` on an object with its own `length` field read it (it compiled
1068
- to Go's `len()`)
1069
- - **Error casts:** `(err as Error)` works on instances of custom error classes
1070
- - **`any` variables:**
1071
- - a variable declared `any` / `unknown` with a primitive initializer is dynamic:
1072
- `const s: any = '6'; s - 1` builds, and reassigning another type works
1073
- - `==` between `any` values coerces like JS
1074
- - `<T>x` converts like `x as T`
1075
- - **Class members:**
1076
- - `#x` and `x` in one class no longer collide
1077
- - private fields and static properties stay out of `JSON.stringify`
1078
-
1079
- Programs that built Go that didn't compile, or computed a wrong value, with no TypeNative error:
1080
-
1081
- - **Classes:**
1082
- - methods without a return-type annotation compiled as returning nothing; they now infer it
1083
- like functions do, including returns nested in `if` / loops / `switch` / `try`
1084
- - field initializers ran before `super()` and the parameter properties, so
1085
- `d = this.k * 2` read `0`
1086
- - static members and getters / setters are inherited (`Child.make()`, `super.v`)
1087
- - private accessors (`get #x()`), `static #x` and `#x in obj` work
1088
- - async methods are lowered like async functions
1089
- - `instanceof Map` / `Set` / `Date` / `Array` work, and `instanceof Parent` is true for
1090
- subclass instances
1091
- - **Control flow:**
1092
- - a `switch` that covers every case without `default` builds; so does any statement after a
1093
- `switch`
1094
- - labeled blocks support `break label`
1095
- - **Async:** `return otherPromise()` in an async function settles with the awaited value, and
1096
- unannotated async functions build
1097
- - **Values and operators:**
1098
- - numeric enum reverse mapping (`Color[0]`)
1099
- - string enum members concatenate and print as strings (`console.log` printed `'a'`)
1100
- - bigint bitwise and shift operators
1101
- - Date arithmetic and ordering (`b - a`, `+d`, `a < b`)
1102
- - `any` operands of `-` / `*` / `/` convert like JS (`'6' - 1` is `5`)
1103
- - **Objects:**
1104
- - object-literal setters (they were dropped)
1105
- - repeated interfaces / enums, and an interface named like a class, merge
1106
- - `Object.hasOwn` / `defineProperty` with a computed key build instead of crashing the
1107
- compiler
1108
- - unsupported decorators and descriptors are reported as diagnostics instead of crashes
1109
- - **Go bridges:** a blocking call (`time.Sleep`) inside a callback failed to build, a panic in
1110
- one was swallowed, and `time.Sleep` hung inside a `synctest` bubble
1111
- - **`for (;;)`** without an initializer or update crashed the compiler
1112
-
1113
- ### Documentation
1114
-
1115
- - `conformance.md` separates ❌ (not implemented yet, feasible) from 🚫 (will not be implemented)
1116
- and explains why for each row. Several rows that were ❌ for "impossible" reasons are now
1117
- marked feasible: terminal size and raw mode, `umask`, `getCallSites`, workers and `fork` for
1118
- another file, and freeing SQLite statements on GC
1119
- - Rows for gaps the matrix didn't list, each checked by compiling a small program. Among them:
1120
- - Date parsing, setters and arithmetic
1121
- - `JSON.stringify` `space` / replacer / `toJSON`
1122
- - `err.stack`, `bind`, `Intl`, `Temporal`, `WeakRef`
1123
- - class methods without a return-type annotation
1124
- - field initializers that run too early
1125
- - `instanceof Map` / `Date`
1126
- - static and accessor inheritance
1127
- - A "Roadmap: known limitations" section, which the link in CONTRIBUTION.md pointed to
1128
- - The Go bridges table has no ⚠️ ("typed, no probe yet") status any more. A probe that can't run on
1129
- a platform opts out with a first line like `// conformance-skip: win32 (reason)`
1130
- - `go:plugin`, `go:unsafe`, `go:runtime/race` and `go:runtime/cgo` are 🚫 (cgo or raw memory),
1131
- each with the reason
1132
-
1133
- ## [0.4.0] - 2026-10-19
1134
-
1135
- A fuller CLI (`--target` cross-compilation, `--release`, `--emit-go`), typed arrays, Brotli and
1136
- `fs.watch`, and TS classes that satisfy Go interfaces such as `heap.Interface`. Three sample apps
1137
- now run as tests.
1138
-
1139
- ### Added
1140
-
1141
- - **CLI**: `--help`, `--version`, `--target <os/arch>` (cross-compiles through `GOOS` /
1142
- `GOARCH`; `--script` refuses foreign targets), `--release` (`-trimpath -ldflags="-s -w"`),
1143
- `--emit-go <dir>` (writes the Go sources and `go.mod` and stops), the entry file as a bare
1144
- argument, and `--flag=value`. Unknown options exit with code `2`, and a missing or older Go
1145
- toolchain (below 1.26) is reported before anything is built
1146
- - **Typed arrays**: `Int8Array`, `Uint8ClampedArray`, `Int16Array`, `Uint16Array`,
1147
- `Int32Array`, `Uint32Array`, `Float32Array`, `Float64Array` (indexing, `from` / `of`,
1148
- `fill` / `set` / `subarray` / `slice`, the callback methods, `sort`, `join`, iteration),
1149
- `ArrayBuffer` (`slice`, `isView`) and `DataView`. Views made on an `ArrayBuffer` share its
1150
- memory, and writes convert like JS; `new Uint8Array(arrayBuffer)` is a view too
1151
- - **Go interfaces**: a TS class passed where Go expects an interface (`heap.Interface`,
1152
- `sort.Interface`) gets an adapter with the exact Go method signatures, so `go:container/heap`
1153
- works and `sort.Sort` takes classes
1154
- - **Brotli** in `node:zlib`: `brotliCompressSync` / `brotliDecompressSync`, the callback and
1155
- promisified forms, `createBrotliCompress` / `createBrotliDecompress` and `constants.BROTLI_*`,
1156
- on the vendored `github.com/andybalholm/brotli` (byte-identical to Node's output)
1157
- - **`fs.watch`** (`recursive`, `persistent`, `signal`, `ref` / `unref`), `fs.watchFile` /
1158
- `unwatchFile` and `fs/promises` `watch`, on the vendored `github.com/fsnotify/fsnotify`
1159
- - `x instanceof Int32Array` / `URL` / any Node global class
1160
- - Three sample apps run as tests (`conformance/app-*.ts`): a `wc`-style CLI, a JSON API on
1161
- `node:http` + `node:sqlite`, and a stream pipeline with gzip / Brotli
1162
-
1163
- ### Changed
1164
-
1165
- - Every build goes through `dist/go.mod` (`go build -C dist`), and generated Go files start
1166
- with Go's `// Code generated … DO NOT EDIT.` header
1167
- - Vendored Go modules are linked only into programs that import them (`npm run vendor:go`
1168
- now vendors sqlite, Brotli and fsnotify)
1169
-
1170
- ### Fixed
1171
-
1172
- - A subclass without a constructor takes its parent's constructor arguments (it compiled to a
1173
- constructor with no parameters)
1174
- - `new C([1, 2])` passes array literals to constructors whose array parameter is a shared
1175
- reference
1176
- - `this.field` has the field's type inside class bodies, so `Map` / `Set` fields dispatch their
1177
- methods (`this.counts.set(k, v)` called a Go method `set` that doesn't exist)
1178
- - Tuple elements read with their declared types (`pair[0]` of a `[string, number]` is a
1179
- string), including in the callbacks of `sort` / `map` / … on tuple arrays
1180
- - `rows.map((r) => ({ … }))` and `reduce` accumulators take the contextual type (a function
1181
- returning `Note[]` builds `Note`s, not anonymous structs)
1182
- - Object literals with computed keys (`{ [constants.BROTLI_PARAM_QUALITY]: 4 }`) are objects keyed
1183
- by the computed value (they compiled to a struct field named `undefined`)
1184
- - `(x as T)` on a Go `any` result (`heap.Pop(h) as Task`) asserts the type, and so does
1185
- `this.items.push(x as T)`
1186
- - Timers fire in deadline order (then creation order) when several expire together, as in
1187
- Node; timer goroutines that woke at once on a busy loop or coarse OS clock could run out of
1188
- order
1189
-
1190
- ## [0.3.1] - 2026-10-18
1191
-
1192
- ### Fixed
1193
-
1194
- - `node:tls` on macOS: an untrusted certificate chain reports Node's codes
1195
- (`DEPTH_ZERO_SELF_SIGNED_CERT`, `SELF_SIGNED_CERT_IN_CHAIN`,
1196
- `UNABLE_TO_GET_ISSUER_CERT_LOCALLY`) like on other platforms; the platform verifier returns
1197
- a plain error, not `UnknownAuthorityError`
1198
- - `go build` runs with `-trimpath`, so vendored packages (the ~5 MB sqlite driver) are cached
1199
- once instead of recompiled for every project directory, and builds are reproducible
1200
- - `conformance-parallel.mjs` builds one sqlite probe first so a cold cache doesn't time out
1201
- every sqlite probe at once on small runners; the `node:sqlite` `location()` probe compares
1202
- canonical paths (symlinks, Windows 8.3 short names)
1203
-
1204
- ## [0.3.0] - 2026-10-18
1205
-
1206
- Errors now point at your TypeScript. Programs are type-checked before they're transpiled, code
1207
- TypeNative can't compile stops the build with its position, and Go build errors and panics
1208
- report `.ts` lines. CI runs the suite on Linux, Windows and macOS, and all 398 probes pass on
1209
- Windows (four failed there before), through both the Node CLI and the self-hosted compiler.
1210
-
1211
- ### Added
1212
-
1213
- - **Type-checking**: the CLI type-checks the entry file and its imports before transpiling,
1214
- using the nearest `tsconfig.json` (or `lib: []` plus the bundled `typenative` declarations),
1215
- and stops on errors (`main.ts:4:7: error TS2322: …`); `--no-typecheck` skips it. The
1216
- self-hosted compiler runs the same check on typescript-go (`tsparser --check`)
1217
- - **Line directives**: generated Go carries `/*line file.ts:line:col*/` directives, so
1218
- `go build` errors and panic stack traces report TypeScript files and lines; runtime helpers
1219
- keep their own `dist/code.go` positions. Both parsers emit `line` / `column` on AST nodes
1220
- - `TranspileResult.diagnostics`, and `fileName` / `goFile` / `goos` transpile options
1221
- - `npm run bootstrap:check`: the self-hosted compiler must emit byte-identical Go for
1222
- `src/main.ts` to the Node CLI's; `conformance-parallel.mjs --native`
1223
- - CI on Ubuntu, Windows and macOS, `check:go-types` in CI, and a self-hosted compiler job
1224
- (bootstrap fixpoint + the suite through it)
1225
-
1226
- ### Changed
1227
-
1228
- - Unsupported syntax and unsupported `node:` modules are errors with a position
1229
- (`main.ts:2:1: error: Unsupported syntax: WithStatement`) instead of warnings followed by
1230
- broken Go; `;` and `debugger` statements compile to nothing
1231
- - Generated Go is deterministic: temp and renamed identifiers come from a generator seeded per
1232
- transpilation instead of `Math.random`, so the same source always gives the same Go
1233
- - Code typed into `--script`'s prompt is saved as `dist/script.ts` (type-checked, and named in
1234
- errors)
1235
- - Scaffolded `tsconfig.json` sets `skipLibCheck`
1236
- - `node:sqlite` `function()` / `aggregate()` callbacks are typed `(...args: any[])`: arguments
1237
- convert to the types the callback declares
1238
- - The release workflow builds `bin/` before testing and publishing; `conformance-parallel.mjs`
1239
- sizes its worker pool to the machine
1240
- - Probes that depend on the OS (`lib-node-dns-resolver`, `lib-node-util-parse-args`) hold on
1241
- Windows, and the conformance probes type-check (`conformance/tsconfig.json` sets
1242
- `skipLibCheck`)
1243
-
1244
- ### Fixed
1245
-
1246
- - Windows: `os.totalmem()` / `os.freemem()` / `os.uptime()` read the OS (they returned the
1247
- process's own memory, `0` and `0`); `performance.now()` keeps increasing between calls, so
1248
- marks taken in a row keep their order (Go's Windows clock repeats readings)
1249
-
1250
- ## [0.2.0] - 2026-10-18
1251
-
1252
- The Go standard-library bridge (`go:*` imports) goes from 73 to 154 probed packages, with 16
1253
- left typed-only and 6 excluded. Most of the new coverage came with bridge fixes found by the
1254
- probes: callbacks, generics, tuples, struct fields and constants now behave the way the
1255
- generated types say they do.
1256
-
1257
- ### Added
1258
-
1259
- - **Go probes**: compress (flate, zlib, lzw, bzip2), archive/tar, encoding (json, base32,
1260
- ascii85, asn1), mime/quotedprintable, unicode/utf16, hash (adler32, crc64, maphash), crypto
1261
- (sha3, hkdf, pbkdf2, des, rc4, fips140, ecdh, ecdsa, elliptic, mlkem, mlkemtest, x509, pkix,
1262
- tls metadata, dsa, hpke), fmt, path, io/fs, io/ioutil, maps, iter, unique, weak, structs,
1263
- image (color, palette, draw, gif, jpeg), go/* (parser, ast, scanner, printer, constant,
1264
- build, build/constraint, doc, doc/comment, types, importer), html/template,
1265
- text/template/parse, regexp/syntax, reflect, net (loopback TCP, textproto, cookiejar,
1266
- httputil, httptrace, pprof, cgi), runtime (metrics, pprof, trace), time/tzdata, os/user,
1267
- debug/buildinfo, math/big, testing (testing, fstest, iotest, quick), database/sql (+driver),
1268
- syscall
1269
- - **Go generics**: type args are inferred recursively from the arguments and through constraint
1270
- core types (`Map ~map[K]V`); callback params of generic functions and methods on generic
1271
- receivers (`unique.Handle[T].Value`) are concrete
1272
- - **Go callbacks**: TS closures passed to Go (params or struct fields) get the exact Go
1273
- signature — int params read as numbers, block bodies work, returns convert to the result type
1274
- - `for (const [k, v] of seq2)` over `iter.Seq2`; destructuring multi-value Go calls types each
1275
- element; printf-style calls pass numbers to `%d %x %o %b %c %U` as `int64`
1276
- - `String.indexOf(search, fromIndex)`
1277
- - `npm run check:go-types` type-checks the `go:*` probes against `types/typenative-go.d.ts`
1278
- - **Node networking**: `node:net` (TCP / Unix servers and sockets as duplex streams, Node's
1279
- `ECONNREFUSED`-style errors, `isIP`), `node:dns` (+ `dns/promises`), `node:http` /
1280
- `node:https` (servers on `net/http`, `request` / `get`, `STATUS_CODES`, `METHODS`),
1281
- `node:tls` (Node's certificate checks and error codes, `getPeerCertificate`), `node:dgram`,
1282
- and the global `fetch` with `Headers` / `Request` / `Response`
1283
- - **`node:async_hooks`**: `AsyncLocalStorage` and `AsyncResource`; the event loop carries an
1284
- async context through timers, `nextTick`, microtasks, promise callbacks, awaits, fs / dns
1285
- callbacks, streams and servers
1286
- - **`node:test`**: `test` / `describe` / `it` with hooks, subtests, skip / todo, timeouts and
1287
- `mock.fn`; Node's TAP (or, on a terminal, spec) report and exit code
1288
- - **`node:worker_threads`**: workers re-run the program as child processes linked over
1289
- loopback TCP (structured-clone messages, `workerData`, `terminate`, errors), plus
1290
- `MessageChannel` / `MessagePort` / `BroadcastChannel`; globals `__filename` / `__dirname`
1291
- - `new Promise((resolve) => setTimeout(resolve, ms))`: `resolve` / `reject` can be passed as
1292
- values
1293
- - **`node:stream/web`**: `ReadableStream` / `WritableStream` / `TransformStream` with readers,
1294
- writers, controllers, queuing strategies, `tee` / `pipeTo` / `pipeThrough` and `for await`;
1295
- `TextEncoderStream` / `TextDecoderStream`, `CompressionStream` / `DecompressionStream` (also
1296
- globals); `Readable.toWeb` / `fromWeb` & co. and `stream.compose`
1297
- - `Blob` / `File` (`node:buffer` and globals) and `FormData`; fetch streams bodies
1298
- (`response.body`, `ReadableStream` uploads), sends Blob / FormData bodies and reads
1299
- `blob()` / `formData()`
1300
- - `TextDecoder#decode(bytes, { stream: true })`
1301
- - **`node:crypto`**: `scrypt` / `scryptSync`; callback forms of `pbkdf2`, `hkdf`,
1302
- `randomBytes`, `randomFill`; `KeyObject` with `createPrivateKey` / `createPublicKey` /
1303
- `createSecretKey` and PEM / DER / JWK import and export; `generateKeyPair(Sync)` (RSA, EC,
1304
- Ed25519, X25519) and `generateKey(Sync)`; `sign` / `verify`, `createSign` / `createVerify`
1305
- (PKCS#1 v1.5, PSS, ECDSA DER / P1363, Ed25519); `publicEncrypt` & co.; ECDH and classic
1306
- Diffie-Hellman (MODP groups); `generatePrime` / `checkPrime`; `X509Certificate`; and
1307
- `crypto.subtle` (digest, keys, sign / verify, AES-GCM / CBC / CTR, RSA-OAEP, PBKDF2 / HKDF /
1308
- ECDH / X25519 derivation, wrap / unwrap)
1309
- - **`child_process.fork`** with an IPC channel (`send` / `'message'` / `disconnect`;
1310
- `process.send` / `process.on('message')` in the child) and **`node:cluster`**: workers share
1311
- listening ports through the primary, which relays connections round-robin; cluster and worker
1312
- events, `disconnect`, `setupPrimary`
1313
- - **`node:http2`** on `net/http`'s HTTP/2: h2c and TLS servers with the `'stream'` API
1314
- (`respond`, `respondWithFile`) and the compatibility `(req, res)` API; `connect()` client
1315
- sessions whose `request()` streams emit `'response'` with `:status`
1316
- - `path.matchesGlob`; Buffer `read/writeBig(U)Int64LE/BE`, `swap16/32/64`, `buffer.isUtf8` /
1317
- `isAscii` / `transcode`; `util.parseArgs`, `getSystemErrorName` / `Message` / `Map`,
1318
- `MIMEType`, `parseEnv`, `aborted`, `debuglog`, `toUSVString`; `process.loadEnvFile`
1319
- - `process.on('uncaughtException' | 'uncaughtExceptionMonitor' | 'unhandledRejection' |
1320
- 'beforeExit')`, `process.cpuUsage` / `resourceUsage` / `availableMemory`; `os.totalmem` /
1321
- `freemem` / `uptime` / `loadavg` / `release` / `version`; timer handles with `ref` / `unref` /
1322
- `hasRef` / `refresh` / `close`; `PerformanceObserver`, `performance.timerify` /
1323
- `eventLoopUtilization`, `createHistogram`, `monitorEventLoopDelay`; `events.errorMonitor`,
1324
- `captureRejections`, static `getMaxListeners` / `setMaxListeners`, `addAbortListener`
1325
- - zlib callback forms (`gzip(buf, [options], cb)` & co.) and `util.promisify` of them;
1326
- `readline.cursorTo` / `moveCursor` / `clearLine` / `clearScreenDown`;
1327
- `diagnostics_channel.tracingChannel` (`traceSync` / `tracePromise` / `traceCallback`) and
1328
- `channel.bindStore` / `runStores`; `net.BlockList` / `SocketAddress`; `dns.Resolver` (own
1329
- servers, `timeout`, `cancel`), `setServers`, `lookupService`; `tls.checkServerIdentity` (and
1330
- the `connect` option); HTTP `'upgrade'` / `'connect'` on servers and clients; node:test
1331
- `t.assert` and `mock.timers`; `console.table`
1332
- - `new Error(message, { cause })` / `err.cause`; fetch refuses the Fetch standard's bad ports;
1333
- `net.Stream` and the `autoSelectFamily` defaults
1334
- - **`node:sqlite`**: `DatabaseSync` / `StatementSync` (`run` / `get` / `all` / `iterate`, named
1335
- and bare parameters, `readBigInts`, `returnArrays`, `columns()`, `expandedSQL`), `function()`,
1336
- `aggregate()` (window functions), `setAuthorizer`, `limits`, `createTagStore()`, `backup()`,
1337
- and Node 24's error codes and messages. SQLite comes from github.com/ncruces/go-sqlite3 (Wasm
1338
- translated to Go: no cgo), vendored in `govendor/` by `npm run vendor:go` so builds need no
1339
- network. `loadExtension`, sessions and `serialize` are not available
1340
- - conformance.md gives each unsupported Node module (`vm`, `repl`, `inspector`, …) its own section
1341
-
1342
- ### Fixed
1343
-
1344
- - **Go types**: void functions were typed as returning `GoError`; params now accept what the
1345
- bridge converts (`number[]` for `[]byte`, one-char strings for `byte`/`rune`, `null` for
1346
- nil-able types, an array for variadics, an optional trailing `error`); pointers to basics are
1347
- `GoRef<T>`; typed constants keep their named type; aliases resolve (`os.FileMode`); named
1348
- slice/map types keep their methods (`net.IP`); `iter.Seq` is iterable; unimportable
1349
- `*/internal` packages are dropped and `runtime/cgo` is excluded
1350
- - **Go bridge**: path-qualified types (`net/http.Cookie`) are localized and imported; unused
1351
- type-only imports are dropped and `import 'go:pkg'` emits `import _`; field reads/writes
1352
- convert numbers on any receiver; `null` comparisons on nil-able Go values are real nil checks;
1353
- `===` with typed constants coerces; `ref<T>().value` dereferences; `json.Unmarshal` fills a
1354
- `Record` ref
1355
- - `npm run gen:go` runs from the repo root again
1356
- - The self-hosted compiler (`npm run build:native`) builds again; the `src/go/*` modules are
1357
- transpilable by TypeNative
1358
- - Object literals whose keys aren't identifiers (`{ 'Content-Type': … }`) compile (as records)
1359
- - `const { a, b } = f()` evaluates `f()` once
1360
- - `await` inside async arrow callbacks no longer blocks the event loop (every `await` goes
1361
- through `TnAwait`)
1362
- - `JSON.parse` assigned to an interface type converts into its struct (it was `nil`); typed
1363
- callback parameters accept decoded JSON-like values
1364
- - `for await` over a stream that errors throws the error (it ended the loop silently)
1365
- - `const { value, done } = obj` on Node class instances types the bindings (and reads
1366
- accessors); `x as File` asserts dynamic values to Node classes
1367
- - `Response#clone()` of a network body no longer blocks the event loop (both copies stream it)
1368
- - The self-hosted compiler no longer crashes on `const [a, b] = call()`
1369
- - A detached top-level async call with arguments (`run(a, b);`) passes them (they were dropped)
1370
- - A function that only returns `undefined` compiles (its result type was `nil`)
1371
- - `gunzip` of data without a gzip header fails with `incorrect header check`, as in Node
1372
- - Error properties declared by both `NodeJS.ErrnoException` and `AssertionError` no longer hide
1373
- each other (`(e.cause as Error).message` typed the cause as unknown)
1374
- - Negative bigint literals and `-x` on bigints; hex / octal / binary bigint literals;
1375
- `p.then(() => …)` on a `Promise<void>`; `JSON.stringify` of records keeps their keys (it
1376
- printed the map's internals); `String(x)` / template literals use a Node class's `toString()`
1377
- - Top-level variables named like an imported Go package (`rsa`, `pem`, `encoding`, `http`, …) are
1378
- renamed instead of clashing with it; `bigint.toString(radix)`; `ArrayBuffer` annotations and
1379
- `byteLength` on Buffers
1380
- - Object literals with `$` in a key (`{ $id: 1 }`) compile (as records); `rows as Row[]` on an
1381
- array of dynamic values converts each element; records held in dynamic values read their keys
1382
- (`row.name`, `row['name']`, `Object.keys(row)`, `row as Row`); `bytes[i]` on a dynamic
1383
- `Uint8Array`; `x === 1n` when `x` is `number | bigint`
1384
- - `arr.reduce(…)` has a result type (functions returning it compiled without a return value); a
1385
- typed arrow parameter is no longer mistaken for an earlier variable of the same name
1386
- - `(c) => (body += c)` arrow bodies; `console.log(x?.y)` prints optional strings / numbers
1387
- without quotes; the self-hosted compiler no longer crashes on `console.log` arguments of
1388
- unknown type
1389
-
1390
- ## [0.1.3] - 2026-10-15
1391
-
1392
- Decorators and JSX arrive alongside a broad language-surface expansion (`using`, `new.target`,
1393
- `for await`, namespaces, dynamic `import()`), and `types/typenative.d.ts` grows into a complete
1394
- lib replacement. The conformance suite grows to 241 probes — including its first `.tsx` probe —
1395
- and passes fully through the dev CLI.
1396
-
1397
- ### Added
1398
-
1399
- - **Language**: `using` declarations — `[Symbol.dispose]()` runs when the enclosing block or
1400
- function exits, in reverse declaration order; `new.target` (constructors pass the target class
1401
- name through `super()` chains); `for await...of`; the `arguments` object; namespaces; computed
1402
- and heterogeneous enums; callable/construct signatures (`type F = { (): void }` — a class passed
1403
- as a value is its constructor); ambient declarations (`declare const` / `declare function` /
1404
- `declare module`); string, numeric and boolean literal types (single literals, unions,
1405
- literal-union `Record` keys)
1406
- - **Decorators**: standard method and class decorators — decorator factories (`@tag('x')`),
1407
- stacked decorators, static methods — applied where the class is defined; `this` in the wrapper
1408
- is the decorated method's receiver; `f.call` / `f.apply`
1409
- - **JSX**: `.tsx` files render JSX to HTML strings — text is escaped, void tags self-close
1410
- (`<br/>`), components are called with their props, `className` maps to `class`, boolean
1411
- attribute shorthand (`disabled`) and fragments flatten; both parsers take a tsx flag and
1412
- `.tsx` imports resolve
1413
- - **Modules**: re-exports (`export { x } from './y'`), side-effect imports (`import './x'`),
1414
- dynamic `import()` (async), `import x = require('y')`; top-level statements of imported
1415
- modules execute through a generated `init()`
1416
- - **Typing**: rest-parameter function types `(...args: T[]) => R` become variadic Go func types
1417
- - **Library**: `String.normalize` — backed by `golang.org/x/text/unicode/norm`, vendored from
1418
- GOROOT's vendor tree via a `replace` in `dist/go.mod`, so builds need no network; object
1419
- literals of method-bearing interfaces; `new Set([...spread])`
1420
- - **Type definitions**: `types/typenative.d.ts` expands by ~500 lines — `Generator`/`AsyncGenerator`
1421
- and the `Iterable`/`AsyncIterable` families, `Disposable`, `Awaited`, `TemplateStringsArray`,
1422
- `ArrayLike`, real mapped types for `Partial`/`Required`/`Readonly`/`Pick`/`Omit`/`Record`,
1423
- `RegExpExecArray`, constructor interfaces (`Array`/`String`/`Number`) and the `JSX` namespace
1424
- - **Project config**: `types/tsconfig.json` — a standalone `lib: []` project for the
1425
- lib-replacement d.ts, so editors don't load es5 libs alongside it (TS6200, duplicate identifiers)
1426
-
1427
- ### Changed
1428
-
1429
- - The conformance runner picks up `.tsx` probes; scaffolds pin `typenative ^0.1.3`; `dist/`
1430
- cleanup also removes stale `go.mod`/`go.sum`
1431
- - Both parsers emit `declarationKind` (`var`/`let`/`const`/`using`/`await using`) on variable
1432
- declaration lists; tsparser takes `--tsx` and emits `JsxText`
1433
- - README rewritten: requirements, quick start, CLI reference, and expanded language/stdlib tables
1434
-
1435
- ## [0.1.2] - 2026-10-13
1436
-
1437
- The type system and standard library catch up with the conformance matrix: generics gain
1438
- constraints, defaults and generic interfaces; utility types, `keyof`/`typeof`, intersections,
1439
- conditional types and mapped types lower to Go; Promise, timer, Object, collection and math
1440
- built-ins round out. The conformance suite grows to 219 probes (including 15 for rows that
1441
- already worked — `console.error`/`warn`, `Map`/`Set.clear`, `node:url`, `process.cwd`, `split`
1442
- with a RegExp, access modifiers, `const enum`, `import type`, indexed access types, literal
1443
- types, hex/octal/binary literals, `override`, template literal types, `var`) and passes fully
1444
- through the dev CLI; the stage-1/stage-2 bootstrap fixpoint holds.
1445
-
1446
- ### Added
1447
-
1448
- - **Generics**: constraints (`T extends U`), defaults (`T = U`), generic interfaces, class
1449
- expressions, index signatures, `keyof` and mapped types
1450
- - **Type operators**: `keyof T`, `typeof x`, `readonly T[]`, intersections `A & B` (merged into
1451
- one struct), conditional types (`T extends U ? X : Y`) with `infer`, `void`/`never`/`object`,
1452
- the `void` operator, `satisfies`
1453
- - **Utility types**: `Partial`, `Required`, `Readonly`, `Pick`, `Omit`, `NonNullable` (lowered to
1454
- the base type)
1455
- - **Language**: async generators (`async function*` driven by `for await`), labeled tuple
1456
- elements with optional and rest members (`[x: number, y?: string, ...rest: number[]]`),
1457
- overload signatures, `this: T` parameters, `asserts x is T`, optional call `f?.()` (checks the
1458
- function value; the result is nullable), comma-separated declarators/updates in `for` headers
1459
- (`for (let i = 0, j = 10; …; i++, j--)` via Go's parallel forms), import renaming
1460
- (`import { a as b }`), `static { … }` blocks → `func init()`, self-referencing arrow functions
1461
- (`const f = (…) => … f(…) …`)
1462
- - **Promises & timers**: `Promise.prototype.reject`/`catch`/`finally`, combinators
1463
- `race`/`allSettled`/`any`, `Promise.resolve`; `setTimeout` returns a handle that `clearTimeout`
1464
- stops; `setInterval`; `queueMicrotask`
1465
- - **Objects**: `Object.hasOwn`, `Object.defineProperty`, `Object.fromEntries`, integrity methods
1466
- (`freeze`/`seal`/`preventExtensions`)
1467
- - **Collections**: `WeakMap`/`WeakSet`; ES2024 `Set` operations (`union`, `intersection`,
1468
- `difference`, `isSubsetOf`, …); array `concat` (flattens one level), `copyWithin`, `toSpliced`,
1469
- `toSorted`, `toReversed`, `with`, `reduceRight`; `any` receivers accept the newer array methods
1470
- through array-only method casts
1471
- - **Strings, numbers, regex**: `String.raw`, `toPrecision`, `String()`/`Boolean()` with JS
1472
- formatting and truthiness; regex `y`/`u` flags and `.source`/`.flags`
1473
- - **Globals**: `globalThis`, `structuredClone`, `isFinite`, `encodeURIComponent`/
1474
- `decodeURIComponent`; `Math` constants (`PI`, `E`, `SQRT2`, …) and `hypot`/`cbrt`/`expm1`/
1475
- `log1p`/hyperbolics/inverse trig/`atan2`
1476
- - **Date**: `getUTC*` getters and `Date.UTC`
1477
- - **Semantics**: functions stored in `Record`s are called as values — `rec.fn(args)` lowers to
1478
- `rec.Get("fn")(args)` (previously dispatched as a built-in method, so `handlers.sort(x)` ran an
1479
- array sort); names that are also JS `Map` methods stay Map methods unless the receiver is typed
1480
- as a `Record`; dynamic `obj[key] = v` writes; mixed array literals (`[['a', 1]]`) become
1481
- `[]interface{}`
1482
-
1483
- ### Changed
1484
-
1485
- - tsparser emits the raw text of template literals
1486
-
1487
- ### Fixed
1488
-
1489
- - `JSON.stringify` no longer HTML-escapes `<`, `>`, `&` in the reflection path (`json.Marshal`
1490
- produced `\u003c`); stage 1 and stage 2 of the bootstrap generate identical Go again
1491
- - `Date.toISOString` printed the month twice (`2006-01-01` instead of `2006-01-02`)
1492
- - `??` passed to a nullable parameter is boxed; object literals nested in dynamic objects stay
1493
- dynamic; shorthand properties (`{ x }`) read narrowed variables correctly
1494
-
1495
- ## [0.1.1] - 2026-10-10
1496
-
1497
- The conformance suite is fully green: all 147 probes pass (up from 95/147), through both the dev
1498
- CLI (`node bin/cli.js`) and the self-hosted native compiler (`npm run conformance -- --native`).
1499
-
1500
- ### Added
1501
-
1502
- - **Language**: array/object destructuring with defaults and elision, computed keys, `for...in`,
1503
- labeled loops (`continue outer` / `break outer`), `as const`, type guards (`p is T`),
1504
- generators (`function*` / `yield` / `yield*`) and `*[Symbol.iterator]()` custom iterators,
1505
- `async`/`await` with `new Promise`, `.then` and `Promise.all` (lowered to goroutines over
1506
- channels, with pending callbacks and timers drained before exit), `setTimeout`
1507
- - **Modules**: `import.meta.url` — the `file://` URL of the running program
1508
- (`os.Executable` through the `pathToFileURL` lowering)
1509
- - **Classes**: inheritance with `super` (methods copied onto subclasses for `this` dispatch),
1510
- abstract classes, `#private` fields, static members typed from initializers, getters/setters
1511
- (`c.v` reads/writes rewrite to `Get_v()`/`Set_v()`), interface `extends` (inherited properties
1512
- flattened into the derived struct), object-literal methods and getters
1513
- - **Errors**: `throw new Error` / `new Error(message)` produce a real error value — custom error
1514
- classes via `extends Error`, `instanceof` and `.message` on caught values
1515
- - **Typing**: generic functions via Go generics (call sites infer type arguments), numeric enums
1516
- as plain numbers, tagged templates, JS loose equality (`0 == false`) with `bool`/number/string
1517
- coercion, `p is T` predicates returning `bool`
1518
- - **Runtime values**: `bigint` (`2n ** 64n` etc. via `math/big`) and `symbol` (unique pointers,
1519
- usable as record keys)
1520
- - **Library**: array `splice`, `fill`, `entries`, `flatMap`, `findLast`/`findLastIndex`,
1521
- `lastIndexOf`, `new Array<T>(n)`, `Array.from`, `join()` defaulting to `","`, in-place
1522
- `reverse`; `charCodeAt`/`String.fromCharCode`/`localeCompare`; `Date` (`new Date(ms)`,
1523
- `getTime`, `toISOString`, `Date.now()`); `Object.assign`; `.length` counts UTF-8 code points
1524
- and `[...str]` spreads runes
1525
- - **Regex**: `/g` regexes carry `lastIndex` state (`re.exec` loops terminate); named groups
1526
- (`(?<name>` → `(?P<name>`, `exec` returns a match with `.groups`); backreferences and
1527
- lookbehind/lookahead run on a small backtracking engine (RE2 does not support them)
1528
- - **Semantics**: arrays are references — `const b = a; b.push(3)` is visible through `a`
1529
- (array variables hold `*[]T`)
1530
-
1531
- ### Changed
1532
-
1533
- - `JSON.stringify` serializes through reflection, so unexported (auto-generated) struct fields
1534
- are included
1535
- - `Object.assign` copies sources (structs, maps, dynamic objects) into an ordered map
1536
- - `throw` panics with a `TnError` value carrying `.message` instead of a bare string
1537
-
1538
- ## [0.1.0] - 2026-10-09
1539
-
1540
- TypeNative compiles itself: `src/main.ts` builds into a native `typenative` binary that passes the
1541
- whole test suite and regenerates its own Go source identically (stage-1/stage-2 bootstrap).
1542
-
1543
- ### Added
1544
-
1545
- - **Native compiler**: `npm run build:native` builds `native/typenative` and `native/tsparser`
1546
- - **`any` / `unknown` at runtime**: property and index access, truthiness, equality (objects by
1547
- identity), method calls, spreads and conversions to typed values via a small Go runtime
1548
- (`TnGet`, `TnSet`, `TnAs`, …) — no guessed types
1549
- - **Language**: object spread, `??=`, `in`, `typeof`, `continue`, optional and destructured
1550
- parameters, constructor parameter properties, `return` inside `try`/`catch`, object type
1551
- aliases and inline object types → Go structs, `Record<K, V>` and dictionaries → Go maps
1552
- - **Typing**: contextual types for object/array/function literals, narrowing of `T | undefined`,
1553
- JS truthiness, `??` chains, nullable ternaries, optional chains across calls
1554
- - **Library**: `toFixed`, `Math.max(...arr)`, `sort` with comparators, `flat`, typed
1555
- `Object.keys`/`values`, regex `replace` (`/g`, `$1`/`$&`, function replacers), `match`/`split`
1556
- with regexes, `Array.isArray`, `console.warn`, `fs.unlinkSync`, `process.env['X']`
1557
- - Tests 33–50
1558
-
1559
- ### Changed
1560
-
1561
- - **Go 1.23 or newer is required** (generated code uses `slices`/`maps` iterator helpers)
1562
- - `process.platform` reports Node's names (`win32`, `darwin`, `linux`)
1563
- - `JSON.stringify` no longer escapes `<`, `>`, `&` (like JS)
1564
- - Out-of-range array/string reads give zero values instead of panicking (JS `undefined`)
1565
- - Imports and helpers are emitted in sorted order
1566
- - Map, Set and Record keep insertion order (like JS); objects are references (Go pointers)
1567
-
1568
- ### Fixed
1569
-
1570
- - The test suite never ran (scripts called `bin/index.js`, which has no entry point); it now runs
1571
- through `bin/cli.js`
1572
- - Phase 3c regressions (19 tests): AST kind names, missing parent links, `extends` detection
1573
- - Main-file top-level variables were invisible to functions
1574
- - `spawnSync` with `stdio: 'inherit'` dropped its arguments
1575
-
1576
- ## [0.0.21] - 2026-09-06
1577
-
1578
- Self-hosting milestone: the compiler no longer depends on `execa`, `fs-extra`, or `nanoid`, and the
1579
- TypeScript parser is decoupled behind an injectable, normalized JSON AST — produced either by the
1580
- `typescript` npm package (dev CLI) or by the new Go-native `tsparser` tool (self-hosted binary).
1581
- Verified: all 33 test specs transpile identically through both parser paths, and the compiler now
1582
- transpiles its own source all the way to `go build`.
1583
-
1584
- ### Added
1585
-
1586
- - **`node:fs` mappings**: `readFileSync`, `writeFileSync`, `appendFileSync`, `existsSync`, `mkdirSync`, `readdirSync`, `copyFileSync`, `rmSync` → Go helpers (`TnReadFile`, `TnWriteFile`, …)
1587
- - **`node:url` mappings**: `fileURLToPath`, `pathToFileURL`
1588
- - **`node:os` mappings**: `platform` (returns `win32`/`darwin`/linux like Node), `homedir`, `tmpdir`
1589
- - **`node:child_process` mappings**: sync `exec`/`execSync`/`spawnSync` shaped like Node's `spawnSync` (`{ stdout, stderr, status }`); `{ stdio: 'inherit' }` runs with the parent's stdio (`TnRunInherit`); `{ input }` pipes stdin (`TnExecInput`)
1590
- - **`node:readline` mapping**: synchronous `question(prompt)` for interactive native prompts (`TnQuestion`, single buffered stdin reader)
1591
- - **`process.env.X`** → `TnGetenv("X")`
1592
- - **Go helper registry**: node-stdlib helpers are emitted once into the main output file with correct per-file import scoping (helpers register their Go packages lazily; import lists are computed after function bodies are visited)
1593
- - **`tsparser/` Go tool**: parses TypeScript via `github.com/buke/typescript-go-internal` (native Go port of the TypeScript parser — no embedded JS runtime) and emits a normalized JSON AST with TypeScript-API kind and field names
1594
- - **`src/parse-node.ts`**: Node adapter producing the identical JSON AST from the `typescript` npm package; verified byte-identical against `tsparser` on all test specs and all compiler sources
1595
- - **`src/parse-native.ts`**: self-hosted parser client (spawns the `tsparser` binary, `TYPENATIVE_TSPARSER` env override)
1596
- - **Injectable parser**: `transpileToNative(code, { parse, readFile })` — the transpiler no longer imports `typescript`
1597
- - **Unbraced `if`/`else if`/`else` statements**: single-statement branches now emit valid Go blocks
1598
- - **`%` and `%=` on numbers** → `math.Mod`
1599
- - **`./x.js` → `x.ts` import resolution** for ES-style relative specifiers
1600
- - **Tests 31–32**: node-stdlib end-to-end spec (fs round-trip, os platform, shell exec) and subprocess/control-flow spec
1601
-
1602
- ### Changed
1603
-
1604
- - **CLI entry split**: `bin/cli.js` (npm `bin`) keeps inquirer for interactive Node use; the transpilable core lives in `src/index.ts` (`run`/`createProject`), with `src/main.ts` as the self-hosting entry and `src/prompt.ts` (transpilable sync prompts) replacing inquirer in native builds
1605
- - **Transpiler internals**: the `ts` typechecker is replaced by syntactic `typeNodeToText`; node predicates became plain `isX()` kind-string functions; operator tokens map through a kind-name table
1606
- - Dropped runtime dependencies: `execa`, `fs-extra`, `nanoid` (replaced by a local `goSafeId`)
1607
-
1608
- ## [0.0.20] - 2026-03-16
1609
-
1610
- ### Added
1611
-
1612
- - **Spread in array literals**: `[...arr1, ...arr2]` → `append(append([]T{}, arr1...), arr2...)`
1613
- - **Rest parameters**: `function(...args: T[])` → Go variadic `func(...args T)`
1614
- - **Spread in function calls**: `fn(...args)` → `fn(args...)`
1615
- - **Array destructuring**: `const [a, b] = arr` → Go index assignments
1616
- - **Object shorthand**: `{ name }` → `{ name: name }` in struct literals
1617
- - **Static class members**: `static method()` / `static prop` → `ClassName_method()` / `ClassName_prop` package-level declarations; `ClassName.method()` calls correctly resolve
1618
- - **Getters/Setters**: `get prop()` → `Get_prop()` method, `set prop(v)` → `Set_prop(v)` method
1619
- - **`for...in` loops**: `for (const k in obj)` → `for k := range obj`
1620
- - **`Object.entries()` in `for...of`**: `for (const [k, v] of Object.entries(map))` unwraps to `for k, v := range map`
1621
- - **Named function expression IIFEs**: `(function name() { ... })()` → anonymous `func() { ... }()`
1622
- - **`process` global**: `process.argv` → `os.Args`, `process.platform` → `runtime.GOOS`, `process.exit()` → `os.Exit()`, `process.cwd()` → `os.Getwd()`
1623
- - **`JSON.stringify()` / `JSON.parse()`**: mapped to `encoding/json` `Marshal`/`Unmarshal`
1624
- - **`Object.keys()` / `Object.values()` / `Object.entries()`**: map iteration helpers
1625
- - **Array methods**: `findIndex`, `every`, `forEach`, `reduce`, `pop`, `shift`, `unshift`, `reverse`, `sort`, `concat`, `flat`, `at`
1626
- - **String methods**: `padStart`, `padEnd`, `match`, `matchAll`, `search`, `at`
1627
- - **Math methods**: `log`, `log2`, `log10`, `sin`, `cos`, `tan`, `trunc`, `sign`
1628
- - **`console.error()`**: maps to `fmt.Fprintln(os.Stderr, ...)`
1629
- - **`String()` / `Number()` / `Boolean()`** conversion functions
1630
- - **Go reserved words protection**: `getSafeName()` now covers all Go keywords (`break`, `case`, `chan`, `continue`, `default`, `defer`, `else`, `fallthrough`, `for`, `func`, `go`, `goto`, `if`, `import`, `interface`, `map`, `package`, `range`, `return`, `select`, `struct`, `switch`, `type`, `var`)
1631
- - **Default import namespaces from npm/local packages**: `import ts from 'typescript'` registers `ts` as a stripped namespace so `ts.method()` → `method()`
1632
- - **Better unsupported syntax warnings**: `console.warn` with syntax kind name and source snippet instead of `console.log`
1633
- - **Type definitions (`typenative.d.ts`)**: added `findIndex`, `every`, `forEach`, `reduce`, `pop`, `shift`, `unshift`, `reverse`, `sort`, `flat`, `concat`, `at` to `Array`; `padStart`, `padEnd`, `match`, `matchAll`, `search`, `at` to `String`; added `JSON`, `Object`, `Process`, extended `Math` and `Console`
1634
-
1635
- ## [0.0.19] - 2026-03-07
1636
-
1637
- ### Added
1638
-
1639
- - Module/import support: `import { x } from './file'` transpiled to Go package imports for local TypeScript files
1640
- - Node.js built-in module imports: `import { join } from 'node:path'` and similar mapped to corresponding Go standard library packages
1641
- - npm package imports: `import { x } from 'pkg'` mapped to Go module imports via `typenative-npm.d.ts` type definitions
1642
- - Go package imports: `import { x } from 'go:package'` to import a Go library package
1643
- - Named exports: `export function` and `export const` declarations now transpiled correctly
1644
-
1645
- ## [0.0.18] - 2026-03-03
1646
-
1647
- ### Added
1648
-
1649
- - `Map<K, V>` support: transpiled to Go `map[K]V`; `.set()`, `.get()`, `.has()`, `.delete()`, `.clear()`, `.size` fully supported
1650
- - `Set<T>` support: transpiled to Go `map[T]struct{}`; `.add()`, `.has()`, `.delete()`, `.clear()`, `.size` fully supported
1651
- - Try/Catch/Finally support: `try/catch/finally` transpiled to Go IIFE with `defer`/`recover` pattern
1652
- - `throw new Error("msg")` transpiled to `panic("msg")`; bare `throw expr` transpiled to `panic(expr)`
1653
- - `Error` type added to `typenative.d.ts` for IDE type checking in test files
1654
- - Closures over mutable state: functions can now capture and mutate variables from outer scopes
1655
- - Function type annotations: `() => number`, `(x: number) => string`, etc. transpiled to Go `func(...)` types
1656
- - 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
1657
- - Expression-body arrow functions now correctly wrap the result as `{ return expr; }` in Go
1658
-
1659
- ## [0.0.17] - 2026-02-16
1660
-
1661
- ### Added
1662
-
1663
- - Support for ternary expressions (`condition ? a : b`)
1664
- - Support for optional chaining (`obj?.prop`, `arr?.[i]`)
1665
- - Support for nullish coalescing (`??` operator)
1666
- - Support for type aliases (`type X = ...`)
1667
- - Support for type assertions (`expr as Type`)
1668
- - Support for optional properties (`prop?: Type` in interfaces/types)
1669
- - Support for default parameter values (e.g. `function(x = defaultValue)`)
1670
- - Support for enum declarations and member access (`enum X { ... }`, `X.Member`)
1671
- - Support for array methods: `map`, `filter`, `some`, `find`
1672
- - Support for chaining array methods (e.g. `arr.map(...).filter(...).join(...)`)
1673
-
1674
- ## [0.0.16] - 2025-02-15
1675
-
1676
- ### Added
1677
-
1678
- - RegExp support: regex literals (`/pattern/flags`), `new RegExp()`, `test()`, and `exec()` mapped to Go's `regexp` package
1679
- - Universal `toString()` support for numbers, booleans, arrays, and objects
1680
-
1681
- ## [0.0.15] - 2025-02-15
1682
-
1683
- ### Added
1684
-
1685
- - Classes with constructors, inheritance (`extends`, `super()`), and methods transpiled to Go structs
1686
- - Interfaces with method signatures and `extends` transpiled to Go interfaces
1687
- - Generics support for functions and classes via Go type parameters
1688
- - Async/Await transpiled to Go channels and goroutines
1689
- - Promises (`new Promise`) transpiled to channel + goroutine pattern
1690
- - `setTimeout` mapped to Go's `time.AfterFunc`
1691
- - Nullable types (`T | null`, `T | undefined`) transpiled to Go pointer types
1692
- - Object literals transpiled to Go struct literals
1693
- - `assert()` function transpiled to `panic` on failure
1694
- - `parseInt` and `parseFloat` mapped to Go's `strconv` package
1695
- - String methods: `split`, `trim`, `trimStart`, `trimEnd`, `toUpperCase`, `toLowerCase`, `indexOf`, `includes`, `startsWith`, `endsWith`, `replace`, `replaceAll`, `repeat`, `charAt`, `substring`, `slice`, `concat`, `toString`
1696
- - Array methods: `join`, `slice`, `toString` (in addition to existing `push`)
1697
- - Math methods: `ceil`, `round`, `abs`, `sqrt`, `pow`, `min`, `max` (in addition to existing `random`, `floor`)
1698
- - Non-null assertion operator (`!`) support
1699
- - Type-aware method dispatch to prevent class methods from being intercepted as built-in string/array methods
1700
- - Safe name collision avoidance for Go reserved identifiers
1701
- - Automatic Go import management for `fmt`, `math`, `math/rand`, `strings`, `strconv`, `time`
1702
-
1703
- ## [0.0.14] - 2025-05-25
1704
-
1705
- ### Added
1706
-
1707
- - Project creation with new `--new` command
1708
- - Support for functions and arrow functions
1709
- - Support for switch statements
1710
- - If statements, while loops, and for...of loops for arrays
1711
-
1712
- ### Changed
1713
-
1714
- - Replaced shelljs dependency with execa for improved process execution
1715
-
1716
- ### Fixed
1717
-
1718
- - Project creation issues
1719
-
1720
- ## [0.0.12] - 2025-05-23
1721
-
1722
- ### Changed
1723
-
1724
- - Switched transpilation target to Go language
1725
-
1726
- ## [0.0.9] - 2024-03-01
1727
-
1728
- ### Added
1729
-
1730
- - Basic types support (number, boolean, string, null, any)
1731
- - Support for variable declarations
1732
- - Support for binary expressions
1733
- - Arithmetic, comparison, logical, and increment/decrement operators
1734
-
1735
- ## [0.0.1] - 2024-02-24
1736
-
1737
- ### Added
1738
-
1739
- - Initial project setup
1740
- - Basic project structure
1741
-
1742
- ## [0.0.0] - 2022-12-20
1743
-
1744
- ### Added
1745
-
1746
- - Initial commit