typenative 0.4.1 → 0.5.0

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 (151) hide show
  1. package/CHANGELOG.md +171 -0
  2. package/README.md +62 -22
  3. package/ROUND2-HANDOFF.md +200 -0
  4. package/bin/cli.js +1 -0
  5. package/bin/index.js +13 -2
  6. package/bin/main.js +1 -0
  7. package/bin/node/assert.js +2 -2
  8. package/bin/node/async_hooks.js +1 -1
  9. package/bin/node/buffer.js +16 -5
  10. package/bin/node/child_process.js +7 -7
  11. package/bin/node/cluster.js +3 -3
  12. package/bin/node/crypto_keys.js +21 -21
  13. package/bin/node/dgram.js +1 -1
  14. package/bin/node/diagnostics_channel.js +3 -3
  15. package/bin/node/dns.js +2 -2
  16. package/bin/node/events.js +3 -3
  17. package/bin/node/fetch.js +2 -2
  18. package/bin/node/fs.js +3 -3
  19. package/bin/node/fs_watch.js +5 -5
  20. package/bin/node/http.js +3 -3
  21. package/bin/node/http2.js +3 -3
  22. package/bin/node/net.js +8 -8
  23. package/bin/node/path.js +17 -3
  24. package/bin/node/process.js +34 -11
  25. package/bin/node/readline.js +1 -1
  26. package/bin/node/registry.js +4 -1
  27. package/bin/node/sqlite.js +6 -6
  28. package/bin/node/stream.js +81 -15
  29. package/bin/node/stream_web.js +10 -10
  30. package/bin/node/system_extra.js +3 -3
  31. package/bin/node/test.js +674 -366
  32. package/bin/node/test_coverage.js +187 -0
  33. package/bin/node/test_report.js +1392 -0
  34. package/bin/node/test_run.js +575 -0
  35. package/bin/node/timers.js +4 -4
  36. package/bin/node/tls.js +5 -5
  37. package/bin/node/util.js +31 -7
  38. package/bin/node/util_extra.js +7 -7
  39. package/bin/node/webview.js +654 -0
  40. package/bin/node/worker_threads.js +1 -1
  41. package/bin/node/zlib.js +3 -3
  42. package/bin/parse-node.js +4 -0
  43. package/bin/transpiler.js +10390 -1178
  44. package/bin/version.js +1 -1
  45. package/conformance.md +468 -340
  46. package/examples/README.md +47 -10
  47. package/examples/desktop-notes/README.md +108 -0
  48. package/examples/desktop-notes/bench.mjs +125 -0
  49. package/examples/desktop-notes/main.ts +131 -0
  50. package/examples/desktop-notes/package-lock.json +726 -0
  51. package/examples/desktop-notes/package.json +9 -0
  52. package/examples/desktop-notes/ui.ts +176 -0
  53. package/examples/dupe-finder/README.md +76 -0
  54. package/examples/dupe-finder/bench.mjs +120 -0
  55. package/examples/dupe-finder/main.ts +87 -0
  56. package/examples/mandelbrot-png/README.md +65 -0
  57. package/examples/mandelbrot-png/bench.mjs +95 -0
  58. package/examples/mandelbrot-png/main.ts +98 -0
  59. package/examples/mandelbrot-png/preview.png +0 -0
  60. package/examples/marked-cli/README.md +159 -0
  61. package/examples/marked-cli/bench.mjs +178 -0
  62. package/examples/marked-cli/main.ts +292 -0
  63. package/examples/marked-cli/parity.mjs +185 -0
  64. package/examples/marked-cli/vendor/marked/LICENSE +44 -0
  65. package/examples/marked-cli/vendor/marked/VENDOR.md +26 -0
  66. package/examples/todo-cli/README.md +69 -0
  67. package/examples/todo-cli/bench.mjs +89 -0
  68. package/examples/todo-cli/main.ts +92 -0
  69. package/examples/yaml-cli/README.md +136 -0
  70. package/examples/yaml-cli/bench.mjs +265 -0
  71. package/examples/yaml-cli/main.ts +29 -0
  72. package/examples/yaml-cli/parity.mjs +156 -0
  73. package/examples/yaml-cli/vendor/yaml/LICENSE +13 -0
  74. package/examples/yaml-cli/vendor/yaml/VENDOR.md +25 -0
  75. package/govendor/github.com/jchv/go-webview2/LICENSE +22 -0
  76. package/govendor/github.com/jchv/go-webview2/README.md +21 -0
  77. package/govendor/github.com/jchv/go-webview2/common.go +84 -0
  78. package/govendor/github.com/jchv/go-webview2/go.mod +3 -0
  79. package/govendor/github.com/jchv/go-webview2/internal/w32/w32.go +194 -0
  80. package/govendor/github.com/jchv/go-webview2/internal/w32/w32_386.go +14 -0
  81. package/govendor/github.com/jchv/go-webview2/internal/w32/w32_64bit.go +15 -0
  82. package/govendor/github.com/jchv/go-webview2/pkg/edge/COREWEBVIEW2_COLOR.go +8 -0
  83. package/govendor/github.com/jchv/go-webview2/pkg/edge/COREWEBVIEW2_HOST_RESOURCE_ACCESS_KIND.go +9 -0
  84. package/govendor/github.com/jchv/go-webview2/pkg/edge/COREWEBVIEW2_KEY_EVENT_KIND.go +10 -0
  85. package/govendor/github.com/jchv/go-webview2/pkg/edge/COREWEBVIEW2_MOVE_FOCUS_REASON.go +9 -0
  86. package/govendor/github.com/jchv/go-webview2/pkg/edge/COREWEBVIEW2_PHYSICAL_KEY_STATUS.go +10 -0
  87. package/govendor/github.com/jchv/go-webview2/pkg/edge/COREWEBVIEW2_WEB_RESOURCE_CONTEXT.go +23 -0
  88. package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2AcceleratorKeyPressedEventArgs.go +78 -0
  89. package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2AcceleratorKeyPressedEventHandler.go +52 -0
  90. package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2Controller.go +132 -0
  91. package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2Controller2.go +74 -0
  92. package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2CreateCoreWebView2ControllerCompletedHandler.go +48 -0
  93. package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2NavigationCompletedEventArgs.go +17 -0
  94. package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2NavigationCompletedEventHandler.go +48 -0
  95. package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2Settings.go +270 -0
  96. package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2WebResourceRequest.go +43 -0
  97. package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2WebResourceRequestedEventArgs.go +51 -0
  98. package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2WebResourceRequestedEventHandler.go +48 -0
  99. package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2WebResourceResponse.go +21 -0
  100. package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2_2.go +21 -0
  101. package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2_3.go +60 -0
  102. package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebViewSettings.go +396 -0
  103. package/govendor/github.com/jchv/go-webview2/pkg/edge/chromium.go +361 -0
  104. package/govendor/github.com/jchv/go-webview2/pkg/edge/chromium_386.go +24 -0
  105. package/govendor/github.com/jchv/go-webview2/pkg/edge/chromium_amd64.go +22 -0
  106. package/govendor/github.com/jchv/go-webview2/pkg/edge/chromium_arm64.go +26 -0
  107. package/govendor/github.com/jchv/go-webview2/pkg/edge/comproc.go +13 -0
  108. package/govendor/github.com/jchv/go-webview2/pkg/edge/comproc_go17.go +51 -0
  109. package/govendor/github.com/jchv/go-webview2/pkg/edge/comproc_go18.go +16 -0
  110. package/govendor/github.com/jchv/go-webview2/pkg/edge/corewebview2.go +411 -0
  111. package/govendor/github.com/jchv/go-webview2/pkg/edge/guid.go +223 -0
  112. package/govendor/github.com/jchv/go-webview2/webview.go +482 -0
  113. package/govendor/github.com/jchv/go-webview2/webviewloader/README.md +3 -0
  114. package/govendor/github.com/jchv/go-webview2/webviewloader/module.go +153 -0
  115. package/govendor/github.com/jchv/go-webview2/webviewloader/module_386.go +6 -0
  116. package/govendor/github.com/jchv/go-webview2/webviewloader/module_amd64.go +6 -0
  117. package/govendor/github.com/jchv/go-webview2/webviewloader/module_arm64.go +6 -0
  118. package/govendor/github.com/jchv/go-webview2/webviewloader/sdk/arm64/WebView2Loader.dll +0 -0
  119. package/govendor/github.com/jchv/go-webview2/webviewloader/sdk/x64/WebView2Loader.dll +0 -0
  120. package/govendor/github.com/jchv/go-webview2/webviewloader/sdk/x86/WebView2Loader.dll +0 -0
  121. package/govendor/github.com/jchv/go-winloader/LICENSE.md +7 -0
  122. package/govendor/github.com/jchv/go-winloader/README.md +124 -0
  123. package/govendor/github.com/jchv/go-winloader/common.go +11 -0
  124. package/govendor/github.com/jchv/go-winloader/go.mod +3 -0
  125. package/govendor/github.com/jchv/go-winloader/internal/loader/loader.go +25 -0
  126. package/govendor/github.com/jchv/go-winloader/internal/loader/machine.go +53 -0
  127. package/govendor/github.com/jchv/go-winloader/internal/memloader/cache.go +42 -0
  128. package/govendor/github.com/jchv/go-winloader/internal/memloader/loader.go +253 -0
  129. package/govendor/github.com/jchv/go-winloader/internal/pe/export.go +76 -0
  130. package/govendor/github.com/jchv/go-winloader/internal/pe/format.go +522 -0
  131. package/govendor/github.com/jchv/go-winloader/internal/pe/import.go +106 -0
  132. package/govendor/github.com/jchv/go-winloader/internal/pe/module.go +91 -0
  133. package/govendor/github.com/jchv/go-winloader/internal/pe/reloc.go +177 -0
  134. package/govendor/github.com/jchv/go-winloader/internal/pe/util.go +40 -0
  135. package/govendor/github.com/jchv/go-winloader/internal/vmem/common.go +55 -0
  136. package/govendor/github.com/jchv/go-winloader/internal/vmem/memory_other.go +71 -0
  137. package/govendor/github.com/jchv/go-winloader/internal/vmem/memory_windows.go +179 -0
  138. package/govendor/github.com/jchv/go-winloader/internal/winloader/hacks_other.go +17 -0
  139. package/govendor/github.com/jchv/go-winloader/internal/winloader/hacks_windows.go +73 -0
  140. package/govendor/github.com/jchv/go-winloader/internal/winloader/loader_windows.go +64 -0
  141. package/govendor/github.com/jchv/go-winloader/internal/winloader/machine_windows.go +32 -0
  142. package/govendor/github.com/jchv/go-winloader/internal/winloader/nativearch_386.go +9 -0
  143. package/govendor/github.com/jchv/go-winloader/internal/winloader/nativearch_amd64.go +9 -0
  144. package/govendor/github.com/jchv/go-winloader/internal/winloader/nativearch_arm64.go +9 -0
  145. package/govendor/github.com/jchv/go-winloader/loader_other.go +24 -0
  146. package/govendor/github.com/jchv/go-winloader/loader_windows.go +33 -0
  147. package/govendor/manifest.txt +3 -1
  148. package/package.json +1 -1
  149. package/tsparser/main.go +4 -0
  150. package/types/typenative-npm.d.ts +190 -2
  151. package/types/typenative.d.ts +98 -31
package/conformance.md CHANGED
@@ -4,7 +4,8 @@ Every TypeScript language feature and standard-library API TypeNative aims to
4
4
  support, split by area. Each ✅ row links to the [conformance/](conformance/)
5
5
  probe that proves it transpiles correctly (`npm run conformance`, filter with an
6
6
  optional substring: `node scripts/conformance.mjs <filter>`; `--native` runs the
7
- self-hosted binary).
7
+ self-hosted binary). The same run also type-checks and builds every program in
8
+ [examples/](#examples).
8
9
 
9
10
  | Status | Meaning |
10
11
  | :----: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -45,6 +46,8 @@ declared there fails the type check before it reaches the transpiler. The
45
46
  | Array destructuring | ✅ | [syntax-destructuring.ts](conformance/syntax-destructuring.ts) | Parenthesized initializers; elision and element/property reads |
46
47
  | Object destructuring | ✅ | [syntax-destructuring.ts](conformance/syntax-destructuring.ts) | Parenthesized initializers; elision and element/property reads; the initializer is evaluated once ([lib-node-worker-threads.ts](conformance/lib-node-worker-threads.ts)) |
47
48
  | Destructuring with defaults | ✅ | [syntax-destructuring-defaults.ts](conformance/syntax-destructuring-defaults.ts) | Missing elements/properties take defaults (nil- and bounds-checked) |
49
+ | Array destructuring with a rest element (`const [a, ...rest] = arr`) | ✅ | [syntax-destructuring-rest.ts](conformance/syntax-destructuring-rest.ts) | `rest` is a copy of the remaining elements, empty past the end |
50
+ | Array destructuring past the end without a default (`const [a] = []` gives `undefined`) | ❌ | — | The binding gets the element type's zero value (`''`, `0`) instead; give it a default |
48
51
  | Destructured parameters | ✅ | [syntax-destructuring-params.ts](conformance/syntax-destructuring-params.ts) | `function f({ a, b }: T)`, `([x, y]: number[])` |
49
52
  | Destructured callback parameters (`([k, v]) => …`, `({ a }) => …`), `[...map]`, `map.entries()`, `{ ...record, k: v }` | ✅ | [syntax-callback-destructuring.ts](conformance/syntax-callback-destructuring.ts) | Without annotations, in `map` / `filter` / `some` & co. over tuples, Map pairs and `Object.entries`; elements of mixed tuples are dynamic |
50
53
  | Object shorthand | ✅ | [lib-go-container-heap.ts](conformance/lib-go-container-heap.ts) | `{ name, priority }` takes the fields from same-named variables |
@@ -56,148 +59,175 @@ declared there fails the type check before it reaches the transpiler. The
56
59
  | Reading a missing key of a `Record` / `Map` of primitives (`rec[k] === undefined`) | ❌ | — | Gives the value type's zero value (`""`, `0`), so the comparison is `false`; test with `k in rec` / `map.has(k)` |
57
60
  | Tuples | ✅ | [syntax-tuples.ts](conformance/syntax-tuples.ts) | `[string, number]` fixed-length arrays |
58
61
  | Top-level / module-scope variables | ✅ | [syntax-top-level-scope.ts](conformance/syntax-top-level-scope.ts) | Functions see main-file top-level variables |
62
+ | Names that are Go keywords, builtins or types (`string`, `len`, `range`) as variables, parameters and members | ✅ | [syntax-go-reserved-names.ts](conformance/syntax-go-reserved-names.ts) | Variables and parameters are renamed; members keep their name (keywords get a trailing `_`) |
59
63
  | Numeric separators | ✅ | [syntax-numeric-separators.ts](conformance/syntax-numeric-separators.ts) | `1_000_000` |
60
64
  | Hex / octal / binary literals | ✅ | [syntax-numeric-literals.ts](conformance/syntax-numeric-literals.ts) | `0xFF`, `0o17`, `0b1010`, `1e3` |
61
65
  | `var` declarations (hoisting) | ✅ | [syntax-var.ts](conformance/syntax-var.ts) | Function- and module-level `var` |
62
66
  | `using` / `await using` declarations | ✅ | [syntax-using.ts](conformance/syntax-using.ts) | Disposed in reverse order when the block ends (`defer`); `[Symbol.dispose]` methods |
63
67
  | Writing past the end of an array (`arr[arr.length + 2] = x`) | ✅ | [semantics-array-growth.ts](conformance/semantics-array-growth.ts) | The array grows; holes read as the zero value (`0`, `""`), not `undefined` |
64
68
  | Sparse-array holes | 🚫 | — | Slices have no holes: a hole would read as the zero value, not `undefined` |
69
+ | `let x;` / `let x = undefined` typed from later assignments | ✅ | [syntax-evolving-let.ts](conformance/syntax-evolving-let.ts) | The variable takes the type of the values assigned to it (in a `try`, a loop, a later statement) |
70
+ | `$` in identifiers (`$EOF`, `obs$`, `$implicit`) | ✅ | [syntax-dollar-identifiers.ts](conformance/syntax-dollar-identifiers.ts) | Go names use `ǂ` for `$`; JSON keys keep `$` |
71
+ | `let x;` assigned on every path before it is read | ✅ | [syntax-let-and-narrowing.ts](conformance/syntax-let-and-narrowing.ts) | Holds its value type, not `any`; `.at()` past either end is `undefined`; unary `+` on a string is `Number()` |
65
72
 
66
73
  ## Operators
67
74
 
68
- | Feature | Status | Probe | Notes |
69
- | --------------------------------------------------------------- | :----: | -------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
70
- | Arithmetic operators | ✅ | [syntax-arithmetic.ts](conformance/syntax-arithmetic.ts) | `+`, `-`, etc.; `%`/`%=` via `math.Mod` |
71
- | Exponent operator | ✅ | [syntax-exponent.ts](conformance/syntax-exponent.ts) | `2 ** 10` |
72
- | Bitwise operators | ✅ | [syntax-bitwise.ts](conformance/syntax-bitwise.ts) | `&`, `\|`, `^`, `<<`, `>>` |
73
- | Unsigned shift | ✅ | [syntax-unsigned-shift.ts](conformance/syntax-unsigned-shift.ts) | `>>>` |
74
- | Comparison operators | ✅ | [syntax-variables.ts](conformance/syntax-variables.ts) | `==`, `!=`, `===`, `!==`, etc. |
75
- | Logical operators | ✅ | [syntax-variables.ts](conformance/syntax-variables.ts) | `&&`, `\|\|` |
76
- | Increment / decrement | ✅ | [syntax-increment-expression.ts](conformance/syntax-increment-expression.ts) | `++`, `--`, incl. as expressions |
77
- | Non-null assertion (`!`) | ✅ | [syntax-top-level-scope.ts](conformance/syntax-top-level-scope.ts) | Stripped during transpilation |
78
- | Ternary expressions | ✅ | [syntax-ternary.ts](conformance/syntax-ternary.ts) | `condition ? a : b` |
79
- | Nullish coalescing | ✅ | [syntax-nullish.ts](conformance/syntax-nullish.ts) | `??` operator, incl. chains |
80
- | Optional chaining | ✅ | [syntax-optional-chaining.ts](conformance/syntax-optional-chaining.ts) | `obj?.prop`, `arr?.[i]`, chains across calls |
81
- | Nullish / logical assignment | ✅ | [syntax-logical-assignment.ts](conformance/syntax-logical-assignment.ts) | `??=`, `\|\|=`, `&&=` |
82
- | `in` operator | ✅ | [syntax-in-operator.ts](conformance/syntax-in-operator.ts) | `"key" in obj` on records |
83
- | `typeof` | ✅ | [syntax-typeof.ts](conformance/syntax-typeof.ts) | `typeof x === "string"`; `"function"` for function values |
84
- | `instanceof` | ✅ | [syntax-instanceof.ts](conformance/syntax-instanceof.ts) | User classes, `Error` classes and Node globals (`URL`, `Uint8Array`, …) |
85
- | JS truthiness | ✅ | [syntax-optional-params.ts](conformance/syntax-optional-params.ts) | `if (str)`, `!count`, `a \|\| fallback` on any type |
86
- | Loose equality (`==`) | ✅ | [semantics-loose-equality.ts](conformance/semantics-loose-equality.ts), [semantics-any-variables.ts](conformance/semantics-any-variables.ts) | `bool`/`number`/`string` mixtures coerce like JS (`TnNumber`/`TnParseFloat`), also between `any` values (`TnLooseEqual`) |
87
- | Optional call (`fn?.()`) | ✅ | [syntax-optional-call.ts](conformance/syntax-optional-call.ts) | Nil check on the function value; result is nullable |
88
- | Comma operator | ✅ | [syntax-comma-operator.ts](conformance/syntax-comma-operator.ts) | In `for` headers (`i = 0, j = 10` / `i++, j--`) |
89
- | `void` operator | ✅ | [syntax-void-operator.ts](conformance/syntax-void-operator.ts) | Evaluates, then `nil` |
90
- | `new.target` | ✅ | [syntax-new-target.ts](conformance/syntax-new-target.ts) | Constructors pass the target class name through `super()` chains |
91
- | `instanceof Map` / `Set` / `Date` / `Array`, subclass instances | ✅ | [syntax-instanceof-builtins.ts](conformance/syntax-instanceof-builtins.ts) | Maps and Sets made by `new Map()` / `new Set()` are tagged (records are not Maps); arrays exclude Buffers; `instanceof Parent` holds for subclass instances |
92
- | `#x in obj` (private brand checks) | ✅ | [syntax-instanceof-builtins.ts](conformance/syntax-instanceof-builtins.ts) | An instance of the class declaring `#x`, or of a subclass |
75
+ | Feature | Status | Probe | Notes |
76
+ | ----------------------------------------------------------------------------------------- | :----: | -------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
77
+ | Arithmetic operators | ✅ | [syntax-arithmetic.ts](conformance/syntax-arithmetic.ts) | `+`, `-`, etc.; `%`/`%=` via `math.Mod` |
78
+ | Exponent operator | ✅ | [syntax-exponent.ts](conformance/syntax-exponent.ts) | `2 ** 10` |
79
+ | Bitwise operators | ✅ | [syntax-bitwise.ts](conformance/syntax-bitwise.ts) | `&`, `\|`, `^`, `<<`, `>>` |
80
+ | Unsigned shift | ✅ | [syntax-unsigned-shift.ts](conformance/syntax-unsigned-shift.ts) | `>>>` |
81
+ | Comparison operators | ✅ | [syntax-variables.ts](conformance/syntax-variables.ts) | `==`, `!=`, `===`, `!==`, etc. |
82
+ | Logical operators | ✅ | [syntax-variables.ts](conformance/syntax-variables.ts) | `&&`, `\|\|` |
83
+ | Increment / decrement | ✅ | [syntax-increment-expression.ts](conformance/syntax-increment-expression.ts) | `++`, `--`, incl. as expressions |
84
+ | Non-null assertion (`!`) | ✅ | [syntax-top-level-scope.ts](conformance/syntax-top-level-scope.ts) | Stripped during transpilation |
85
+ | Ternary expressions | ✅ | [syntax-ternary.ts](conformance/syntax-ternary.ts) | `condition ? a : b` |
86
+ | Nullish coalescing | ✅ | [syntax-nullish.ts](conformance/syntax-nullish.ts) | `??` operator, incl. chains |
87
+ | Optional chaining | ✅ | [syntax-optional-chaining.ts](conformance/syntax-optional-chaining.ts) | `obj?.prop`, `arr?.[i]`, chains across calls |
88
+ | Nullish / logical assignment | ✅ | [syntax-logical-assignment.ts](conformance/syntax-logical-assignment.ts) | `??=`, `\|\|=`, `&&=` |
89
+ | `in` operator | ✅ | [syntax-in-operator.ts](conformance/syntax-in-operator.ts) | `"key" in obj` on records |
90
+ | `typeof` | ✅ | [syntax-typeof.ts](conformance/syntax-typeof.ts) | `typeof x === "string"`; `"function"` for function values |
91
+ | `instanceof` | ✅ | [syntax-instanceof.ts](conformance/syntax-instanceof.ts) | User classes, `Error` classes and Node globals (`URL`, `Uint8Array`, …) |
92
+ | JS truthiness | ✅ | [syntax-optional-params.ts](conformance/syntax-optional-params.ts) | `if (str)`, `!count`, `a \|\| fallback` on any type |
93
+ | Loose equality (`==`) | ✅ | [semantics-loose-equality.ts](conformance/semantics-loose-equality.ts), [semantics-any-variables.ts](conformance/semantics-any-variables.ts) | `bool`/`number`/`string` mixtures coerce like JS (`TnNumber`/`TnParseFloat`), also between `any` values (`TnLooseEqual`) |
94
+ | Optional call (`fn?.()`) | ✅ | [syntax-optional-call.ts](conformance/syntax-optional-call.ts) | Nil check on the function value; result is nullable |
95
+ | Comma operator | ✅ | [syntax-comma-operator.ts](conformance/syntax-comma-operator.ts) | In `for` headers (`i = 0, j = 10` / `i++, j--`) |
96
+ | `void` operator | ✅ | [syntax-void-operator.ts](conformance/syntax-void-operator.ts) | Evaluates, then `nil` |
97
+ | `new.target` | ✅ | [syntax-new-target.ts](conformance/syntax-new-target.ts) | Constructors pass the target class name through `super()` chains |
98
+ | `instanceof Map` / `Set` / `Date` / `Array`, subclass instances | ✅ | [syntax-instanceof-builtins.ts](conformance/syntax-instanceof-builtins.ts) | Maps and Sets made by `new Map()` / `new Set()` are tagged (records are not Maps); arrays exclude Buffers; `instanceof Parent` holds for subclass instances |
99
+ | `#x in obj` (private brand checks) | ✅ | [syntax-instanceof-builtins.ts](conformance/syntax-instanceof-builtins.ts) | An instance of the class declaring `#x`, or of a subclass |
100
+ | Optional calls on `any` values (`o?.m()`, `a?.b.c?.get(k)`) | ✅ | [syntax-optional-call-any.ts](conformance/syntax-optional-call-any.ts) | Nothing is called when the receiver is nullish; the result can initialize a typed variable |
101
+ | `x?.m()` on an `any` value when `m` has a known primitive result (`s?.toUpperCase()`) | ❌ | — | A nullish `x` gives the type's zero value (`''`, `0`) instead of `undefined`, so `?? fallback` does not apply |
102
+ | Assignment as an expression (`while ((m = re.exec(s)))`, `a = b = c`, `x = (o[k] ??= v)`) | ✅ | [syntax-assignment-expressions.ts](conformance/syntax-assignment-expressions.ts) | Assigns, then reads the target back; `??=` on a map element tests for a missing key |
93
103
 
94
104
  ## Control flow
95
105
 
96
- | Feature | Status | Probe | Notes |
97
- | ------------------------------------------------------------------ | :----: | -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
98
- | If / else statements | ✅ | [syntax-if-switch.ts](conformance/syntax-if-switch.ts) | Incl. unbraced bodies and else-if chains |
99
- | Switch statements | ✅ | [syntax-switch.ts](conformance/syntax-switch.ts) | Case and default statements |
100
- | Switch fallthrough | ✅ | [syntax-switch-fallthrough.ts](conformance/syntax-switch-fallthrough.ts) | Explicit fallthrough between cases |
101
- | `for` loops | ✅ | [syntax-loops.ts](conformance/syntax-loops.ts) | Standard `for` loops, incl. unbraced bodies |
102
- | `continue` | ✅ | [syntax-loops.ts](conformance/syntax-loops.ts) | `continue` in all loop kinds |
103
- | `break` | ✅ | [syntax-if-switch.ts](conformance/syntax-if-switch.ts), [syntax-do-while.ts](conformance/syntax-do-while.ts) | In switch cases and loops |
104
- | `for...of` loops | ✅ | [syntax-loops.ts](conformance/syntax-loops.ts), [syntax-for-of-string.ts](conformance/syntax-for-of-string.ts) | Arrays, Maps, Sets, strings, tuples; `Object.entries()` unwrapping |
105
- | `for...in` loops | ✅ | [syntax-for-in.ts](conformance/syntax-for-in.ts) | Key range over records/maps |
106
- | `for await...of` | ✅ | [syntax-for-await.ts](conformance/syntax-for-await.ts) | Ranges over the async generator's channel |
107
- | `while` loops | ✅ | [syntax-loops.ts](conformance/syntax-loops.ts) | Transpiled to Go's `for` loops; assignment in condition |
108
- | `do...while` loops | ✅ | [syntax-do-while.ts](conformance/syntax-do-while.ts) | Implemented with conditional break |
109
- | Labeled loops | ✅ | [syntax-labeled-loops.ts](conformance/syntax-labeled-loops.ts) | `LabeledStatement` → Go labels; labeled `continue`/`break` |
110
- | `try` / `catch` / `finally` | ✅ | [syntax-try-catch-finally.ts](conformance/syntax-try-catch-finally.ts) | `throw` → `panic`; catch/finally via `defer`/`recover` |
111
- | Optional catch binding (`catch {}`) | ✅ | [syntax-try-catch-finally.ts](conformance/syntax-try-catch-finally.ts) | |
112
- | Custom error classes | ✅ | [syntax-custom-errors.ts](conformance/syntax-custom-errors.ts) | `extends Error` → embedded `TnError`; constructors take the message |
113
- | `Error.message` | ✅ | [syntax-error-message.ts](conformance/syntax-error-message.ts) | `throw new Error` panics with a `*TnError`; `.message` on caught values |
114
- | `Error` `cause` (`new Error(message, { cause })`, `err.cause`) | ✅ | [lib-node-fetch-bad-port.ts](conformance/lib-node-fetch-bad-port.ts) | Built-in error classes too |
115
- | Narrowing | ✅ | [syntax-typeof.ts](conformance/syntax-typeof.ts) | `T \| undefined` narrowed after `if (x)`, `x !== undefined`, early returns |
116
- | Exhaustive `switch` without `default`; statements after a `switch` | ✅ | [syntax-switch-exhaustive.ts](conformance/syntax-switch-exhaustive.ts) | A function that can end without a `return` returns its result type's zero value (JS: `undefined`) |
117
- | Labeled blocks and statements (`label: { … break label; }`) | ✅ | [syntax-labeled-blocks.ts](conformance/syntax-labeled-blocks.ts) | `break label` jumps past the statement (`goto`) |
118
- | Throwing non-`Error` values (`throw 'x'`, `throw { code: 1 }`) | ✅ | — | Caught as `interface{}`; properties read dynamically |
119
- | `debugger` | ✅ | — | Erased |
120
- | `with` | 🚫 | — | Not allowed in strict mode (modules are strict) |
106
+ | Feature | Status | Probe | Notes |
107
+ | -------------------------------------------------------------------------------------------------------------------------- | :----: | -------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
108
+ | If / else statements | ✅ | [syntax-if-switch.ts](conformance/syntax-if-switch.ts) | Incl. unbraced bodies and else-if chains |
109
+ | Switch statements | ✅ | [syntax-switch.ts](conformance/syntax-switch.ts) | Case and default statements |
110
+ | Switch fallthrough | ✅ | [syntax-switch-fallthrough.ts](conformance/syntax-switch-fallthrough.ts) | Explicit fallthrough between cases |
111
+ | `for` loops | ✅ | [syntax-loops.ts](conformance/syntax-loops.ts) | Standard `for` loops, incl. unbraced bodies |
112
+ | `continue` | ✅ | [syntax-loops.ts](conformance/syntax-loops.ts) | `continue` in all loop kinds |
113
+ | `break` | ✅ | [syntax-if-switch.ts](conformance/syntax-if-switch.ts), [syntax-do-while.ts](conformance/syntax-do-while.ts) | In switch cases and loops |
114
+ | `for...of` loops | ✅ | [syntax-loops.ts](conformance/syntax-loops.ts), [syntax-for-of-string.ts](conformance/syntax-for-of-string.ts) | Arrays, Maps, Sets, strings, tuples; `Object.entries()` unwrapping |
115
+ | `for...in` loops | ✅ | [syntax-for-in.ts](conformance/syntax-for-in.ts) | Key range over records/maps |
116
+ | `for await...of` | ✅ | [syntax-for-await.ts](conformance/syntax-for-await.ts) | Ranges over the async generator's channel |
117
+ | `while` loops | ✅ | [syntax-loops.ts](conformance/syntax-loops.ts) | Transpiled to Go's `for` loops; assignment in condition |
118
+ | `do...while` loops | ✅ | [syntax-do-while.ts](conformance/syntax-do-while.ts) | Implemented with conditional break |
119
+ | Labeled loops | ✅ | [syntax-labeled-loops.ts](conformance/syntax-labeled-loops.ts) | `LabeledStatement` → Go labels; labeled `continue`/`break` |
120
+ | `try` / `catch` / `finally` | ✅ | [syntax-try-catch-finally.ts](conformance/syntax-try-catch-finally.ts) | `throw` → `panic`; catch/finally via `defer`/`recover` |
121
+ | Optional catch binding (`catch {}`) | ✅ | [syntax-try-catch-finally.ts](conformance/syntax-try-catch-finally.ts) | |
122
+ | Custom error classes | ✅ | [syntax-custom-errors.ts](conformance/syntax-custom-errors.ts) | `extends Error` → embedded `TnError`; constructors take the message |
123
+ | `Error.message` | ✅ | [syntax-error-message.ts](conformance/syntax-error-message.ts) | `throw new Error` panics with a `*TnError`; `.message` on caught values |
124
+ | `Error` `cause` (`new Error(message, { cause })`, `err.cause`) | ✅ | [lib-node-fetch-bad-port.ts](conformance/lib-node-fetch-bad-port.ts) | Built-in error classes too |
125
+ | Narrowing | ✅ | [syntax-typeof.ts](conformance/syntax-typeof.ts) | `T \| undefined` narrowed after `if (x)`, `x !== undefined`, early returns |
126
+ | Exhaustive `switch` without `default`; statements after a `switch` | ✅ | [syntax-switch-exhaustive.ts](conformance/syntax-switch-exhaustive.ts) | A function that can end without a `return` returns its result type's zero value (JS: `undefined`) |
127
+ | Labeled blocks and statements (`label: { … break label; }`) | ✅ | [syntax-labeled-blocks.ts](conformance/syntax-labeled-blocks.ts) | `break label` jumps past the statement (`goto`) |
128
+ | Throwing non-`Error` values (`throw 'x'`, `throw { code: 1 }`) | ✅ | — | Caught as `interface{}`; properties read dynamically |
129
+ | `debugger` | ✅ | — | Erased |
130
+ | `with` | 🚫 | — | Not allowed in strict mode (modules are strict) |
131
+ | Assignments and compound assignments as values, comma expressions, `for (let x; …)` headers, several updates per iteration | ✅ | [syntax-loop-lowerings.ts](conformance/syntax-loop-lowerings.ts) | `(ch = s[i += 1])` in a condition, `a = b = 7`, `(k++, k * 10)`; Go-only statements are lowered to closures |
132
+ | `continue` in `do…while`; `default` falling through to later cases; labeled `break` out of a `switch` | ✅ | [syntax-loop-lowerings.ts](conformance/syntax-loop-lowerings.ts) | `continue` re-tests the condition |
133
+ | `for…of` whose body never reads its variable (`for (const x of xs) n++`) | ✅ | [lib-string-split-trim.ts](conformance/lib-string-split-trim.ts) | |
121
134
 
122
135
  ## Functions
123
136
 
124
- | Feature | Status | Probe | Notes |
125
- | --------------------------------------------------------------------- | :----: | ---------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
126
- | Function declarations | ✅ | [syntax-functions.ts](conformance/syntax-functions.ts) | Transpiled to Go functions |
127
- | Arrow functions | ✅ | [syntax-arrow-functions.ts](conformance/syntax-arrow-functions.ts) | Transpiled to anonymous functions |
128
- | IIFEs | ✅ | [syntax-iife.ts](conformance/syntax-iife.ts) | `(() => { ... })()` and `(function name() { ... })()` |
129
- | Closures over mutable state | ✅ | [syntax-closures.ts](conformance/syntax-closures.ts) | Functions capturing and mutating outer variables; per-iteration `let` |
130
- | Function types | ✅ | [syntax-closures.ts](conformance/syntax-closures.ts) | `() => number`, `(x: number) => string` as type annotations |
131
- | Default parameter values | ✅ | [syntax-default-params.ts](conformance/syntax-default-params.ts) | `function(x = defaultValue)`, incl. constructors, methods, arrows |
132
- | Rest parameters | ✅ | [syntax-rest-params.ts](conformance/syntax-rest-params.ts) | `function(...args: T[])` → Go variadic |
133
- | Spread in calls | ✅ | [syntax-spread-call.ts](conformance/syntax-spread-call.ts) | `f(...args)` incl. tuples |
134
- | Optional parameters | ✅ | [syntax-optional-params.ts](conformance/syntax-optional-params.ts) | `function f(x?: string)` |
135
- | Destructured parameters | ✅ | [syntax-destructuring-params.ts](conformance/syntax-destructuring-params.ts) | `function f({ a, b }: T)`, `([x, y]: number[])` |
136
- | Contextual object-literal arguments | ✅ | [syntax-contextual-arguments.ts](conformance/syntax-contextual-arguments.ts) | Struct type inferred from parameter / return type |
137
- | Recursion | ✅ | [syntax-recursion.ts](conformance/syntax-recursion.ts) | Direct self-recursion |
138
- | Recursive arrow functions | ✅ | [syntax-recursive-arrow.ts](conformance/syntax-recursive-arrow.ts) | `const f = () => … f() …` → declared, then assigned |
139
- | Generators (`function*` / `yield` / `yield*`) | ✅ | [syntax-generators.ts](conformance/syntax-generators.ts) | `function*` runs in a goroutine sending yields over a channel; `for...of` ranges it |
140
- | Async generators (`async function*`) | ✅ | [syntax-async-generators.ts](conformance/syntax-async-generators.ts) | Goroutine + channel, consumed with `for await` |
141
- | Custom iterators (`Symbol.iterator`) | ✅ | [syntax-custom-iterators.ts](conformance/syntax-custom-iterators.ts) | `*[Symbol.iterator]()` → a `Symbol_iterator()` channel method |
142
- | `as const` assertions | ✅ | [syntax-as-const.ts](conformance/syntax-as-const.ts) | Erased during transpilation |
143
- | Function overloads | ✅ | [syntax-function-overloads.ts](conformance/syntax-function-overloads.ts) | Signatures are erased; the implementation is emitted |
144
- | `this` parameter (`function f(this: T)`) | ✅ | [syntax-this-parameter.ts](conformance/syntax-this-parameter.ts) | Erased |
145
- | `arguments` object | ✅ | [syntax-arguments.ts](conformance/syntax-arguments.ts) | Functions reading it take extra arguments variadically (`[]interface{}`) |
146
- | Top-level `await` | ✅ | — | In modules (files with an `import` / `export`) |
147
- | Generator `next()` | ✅ | [lib-iterator-helpers.ts](conformance/lib-iterator-helpers.ts) | `{ value, done }` |
148
- | Generator `next(value)` (sending a value in) / `return()` / `throw()` | ❌ | — | Generators are goroutines feeding a channel: values only flow out |
149
- | `fn.call` / `fn.apply` / `fn.bind` | ✅ | [syntax-function-values.ts](conformance/syntax-function-values.ts) | Function declarations and function values; `apply` spreads the array over the parameters; `thisArg` is ignored (methods taken from an object are already bound in Go) |
150
- | `fn.name` / `fn.length` | ✅ | [syntax-function-values.ts](conformance/syntax-function-values.ts) | Known at compile time for declared functions, classes and function variables |
151
- | `eval` / `new Function(…)` | 🚫 | — | Compile and run JavaScript at runtime: needs a JavaScript engine |
137
+ | Feature | Status | Probe | Notes |
138
+ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :----: | -------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
139
+ | Function declarations | ✅ | [syntax-functions.ts](conformance/syntax-functions.ts) | Transpiled to Go functions |
140
+ | Arrow functions | ✅ | [syntax-arrow-functions.ts](conformance/syntax-arrow-functions.ts) | Transpiled to anonymous functions |
141
+ | IIFEs | ✅ | [syntax-iife.ts](conformance/syntax-iife.ts) | `(() => { ... })()` and `(function name() { ... })()` |
142
+ | Closures over mutable state | ✅ | [syntax-closures.ts](conformance/syntax-closures.ts) | Functions capturing and mutating outer variables; per-iteration `let` |
143
+ | Function types | ✅ | [syntax-closures.ts](conformance/syntax-closures.ts) | `() => number`, `(x: number) => string` as type annotations |
144
+ | Default parameter values | ✅ | [syntax-default-params.ts](conformance/syntax-default-params.ts) | `function(x = defaultValue)`, incl. constructors, methods, arrows |
145
+ | Rest parameters | ✅ | [syntax-rest-params.ts](conformance/syntax-rest-params.ts) | `function(...args: T[])` → Go variadic |
146
+ | Spread in calls | ✅ | [syntax-spread-call.ts](conformance/syntax-spread-call.ts) | `f(...args)` incl. tuples |
147
+ | Optional parameters | ✅ | [syntax-optional-params.ts](conformance/syntax-optional-params.ts) | `function f(x?: string)` |
148
+ | Destructured parameters | ✅ | [syntax-destructuring-params.ts](conformance/syntax-destructuring-params.ts) | `function f({ a, b }: T)`, `([x, y]: number[])` |
149
+ | Contextual object-literal arguments | ✅ | [syntax-contextual-arguments.ts](conformance/syntax-contextual-arguments.ts) | Struct type inferred from parameter / return type |
150
+ | Recursion | ✅ | [syntax-recursion.ts](conformance/syntax-recursion.ts) | Direct self-recursion |
151
+ | Recursive arrow functions | ✅ | [syntax-recursive-arrow.ts](conformance/syntax-recursive-arrow.ts) | `const f = () => … f() …` → declared, then assigned |
152
+ | Generators (`function*` / `yield` / `yield*`) | ✅ | [syntax-generators.ts](conformance/syntax-generators.ts) | `function*` runs in a goroutine sending yields over a channel; `for...of` ranges it |
153
+ | Async generators (`async function*`) | ✅ | [syntax-async-generators.ts](conformance/syntax-async-generators.ts) | Goroutine + channel, consumed with `for await` |
154
+ | Custom iterators (`Symbol.iterator`) | ✅ | [syntax-custom-iterators.ts](conformance/syntax-custom-iterators.ts) | `*[Symbol.iterator]()` → a `Symbol_iterator()` channel method |
155
+ | `as const` assertions | ✅ | [syntax-as-const.ts](conformance/syntax-as-const.ts) | Erased during transpilation |
156
+ | Function overloads | ✅ | [syntax-function-overloads.ts](conformance/syntax-function-overloads.ts) | Signatures are erased; the implementation is emitted |
157
+ | `this` parameter (`function f(this: T)`) | ✅ | [syntax-this-parameter.ts](conformance/syntax-this-parameter.ts) | Erased |
158
+ | `arguments` object | ✅ | [syntax-arguments.ts](conformance/syntax-arguments.ts) | Functions reading it take extra arguments variadically (`[]interface{}`) |
159
+ | Top-level `await` | ✅ | — | In modules (files with an `import` / `export`) |
160
+ | Generator `next()` | ✅ | [lib-iterator-helpers.ts](conformance/lib-iterator-helpers.ts) | `{ value, done }` |
161
+ | Generator `next(value)` (sending a value in) / `return()` / `throw()` | ❌ | — | Generators are goroutines feeding a channel: values only flow out |
162
+ | `fn.call` / `fn.apply` / `fn.bind` | ✅ | [syntax-function-values.ts](conformance/syntax-function-values.ts) | Function declarations and function values; `apply` spreads the array over the parameters; `thisArg` is ignored (methods taken from an object are already bound in Go) |
163
+ | `fn.name` / `fn.length` | ✅ | [syntax-function-values.ts](conformance/syntax-function-values.ts) | Known at compile time for declared functions, classes and function variables |
164
+ | `eval` / `new Function(…)` | 🚫 | — | Compile and run JavaScript at runtime: needs a JavaScript engine |
165
+ | Properties on functions (`fn.prop = v`), call-signature types with properties | ✅ | [syntax-function-properties.ts](conformance/syntax-function-properties.ts) | Each property is a package variable `fn__prop`; reassigning it works |
166
+ | `arguments` with optional parameters left out | ✅ | [syntax-arguments-object.ts](conformance/syntax-arguments-object.ts) | Omitted trailing optionals are not counted; `arguments[i]` is the value (not a pointer) |
167
+ | An optional array parameter passed on to a defaulted parameter (a call or `super(…)`) | ✅ | [syntax-optional-array-params.ts](conformance/syntax-optional-array-params.ts) | Left out, the callee gets its default; `xs ?? []` on an absent array gives the fallback |
168
+ | Function declarations inside functions and blocks | ✅ | [syntax-nested-functions.ts](conformance/syntax-nested-functions.ts) | Hoisted (callable before the declaration, mutually recursive), `async` and generator ones included |
169
+ | Function values: a static method in a variable, static and instance methods of one name, a variadic function expression where fixed parameters are expected, a `.catch` handler, an async IIFE, method identity | ✅ | [syntax-function-values-more.ts](conformance/syntax-function-values-more.ts) | `a.m === A.prototype.m` compares the methods |
170
+ | `f.apply(thisArg, args)` / `f.call` on a function held as `any` or under another name (`const f: any = fn`) | ✅ | [syntax-nullable-primitive-fields.ts](conformance/syntax-nullable-primitive-fields.ts) | `thisArg` is dropped |
171
+ | Functions with array parameters stored where a function type is expected (`Record<string, (xs: any[]) => R>`): declared functions, arrows, function expressions | ✅ | [syntax-function-values-more.ts](conformance/syntax-function-values-more.ts) | A function type's arrays are plain slices: a declared function is adapted |
172
+ | An array passed through a function-typed value (a callback slot) is shared with the callee | ❌ | — | The callee gets a copy: its `push` doesn't reach the caller's array (a direct call shares it) |
173
+ | A string method on an `any` value whose name an object literal's function also has (`spec.startsWith('.')`) | ✅ | [syntax-function-values-more.ts](conformance/syntax-function-values-more.ts) | A string runs the string method, any other value its own function |
152
174
 
153
175
  ## Classes & interfaces
154
176
 
155
- | Feature | Status | Probe | Notes |
156
- | ---------------------------------------------------------------------------------- | :----: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
157
- | Classes | ✅ | [syntax-class.ts](conformance/syntax-class.ts) | Transpiled to Go structs with constructor and receiver methods |
158
- | Constructor parameter properties | ✅ | [syntax-class-parameter-properties.ts](conformance/syntax-class-parameter-properties.ts) | `constructor(private x: number)` |
159
- | Class inheritance | ✅ | [syntax-class-inheritance.ts](conformance/syntax-class-inheritance.ts) | `super.method()` → `self.Parent.method()`; inherited methods copied for `this` dispatch |
160
- | `implements` clauses | ✅ | [syntax-class-implements.ts](conformance/syntax-class-implements.ts) | `class C implements I` |
161
- | Interface `extends` | ✅ | [syntax-interface-extends.ts](conformance/syntax-interface-extends.ts) | Inherited properties flattened into the derived struct |
162
- | Static members | ✅ | [syntax-class-static.ts](conformance/syntax-class-static.ts) | Static members → package-level `Class_member` vars/functions |
163
- | Getters / setters (classes) | ✅ | [syntax-class-getters.ts](conformance/syntax-class-getters.ts) | `c.v` reads/writes rewrite to `Get_v()`/`Set_v()` accessor calls |
164
- | Getters (object literals) | ✅ | [syntax-object-getters.ts](conformance/syntax-object-getters.ts) | Getter closures stored as function fields; reads invoke them |
165
- | Object-literal methods | ✅ | [syntax-object-methods.ts](conformance/syntax-object-methods.ts) | Method closures stored as function fields capturing the instance (`this` → the object) |
166
- | Private `#` fields | ✅ | [syntax-class-private-fields.ts](conformance/syntax-class-private-fields.ts) | `#secret` → a `__secret` struct field, left out of `JSON.stringify` and `console.log` |
167
- | Access modifiers (`private` / `protected` / `public` on members) | ✅ | [syntax-access-modifiers.ts](conformance/syntax-access-modifiers.ts) | `private` / `protected` / `public` are erased |
168
- | Abstract classes | ✅ | [syntax-class-abstract.ts](conformance/syntax-class-abstract.ts) | Abstract members skipped; concrete methods copied onto subclasses |
169
- | Static initialization blocks (`static {}`) | ✅ | [syntax-static-blocks.ts](conformance/syntax-static-blocks.ts) | Go `func init()` |
170
- | Class expressions (`const C = class {}`) | ✅ | [syntax-class-expressions.ts](conformance/syntax-class-expressions.ts) | `const C = class {…}` becomes a class named after the variable |
171
- | Interfaces | ✅ | [syntax-class-implements.ts](conformance/syntax-class-implements.ts) | Transpiled to Go interfaces |
172
- | Optional properties | ✅ | [syntax-optional-chaining.ts](conformance/syntax-optional-chaining.ts) | `prop?: Type` in interfaces/types |
173
- | Type-aware method dispatch | ✅ | [semantics-method-dispatch.ts](conformance/semantics-method-dispatch.ts) | Class `.push()` / `.length` not confused with array builtins |
174
- | Index signatures (`[key: string]: T`) | ✅ | [syntax-index-signatures.ts](conformance/syntax-index-signatures.ts) | `{ [k: K]: V }` is `Record<K, V>` (an ordered Go map) |
175
- | Methods without a return-type annotation | ✅ | [syntax-method-return-inference.ts](conformance/syntax-method-return-inference.ts) | Inferred from the returns, as for functions (also returns nested in `if` / loops / `switch` / `try`); an inherited `return this` returns the subclass |
176
- | Field initializers reading parameter properties or parent fields | ✅ | [syntax-class-field-order.ts](conformance/syntax-class-field-order.ts) | `super()`, then parameter properties, then field initializers, then the constructor body (TS's ES2020 order) |
177
- | Arrow-function fields (`h = () => this.x`), fields reading earlier fields | ✅ | — | Run in the constructor; `this` is the instance |
178
- | Private methods (`#m()`) | ✅ | [syntax-method-return-inference.ts](conformance/syntax-method-return-inference.ts) | |
179
- | A private and a public member with the same name (`#x` and `x`) | ✅ | [syntax-private-public-names.ts](conformance/syntax-private-public-names.ts) | `#x` is the Go field `__x` |
180
- | Private accessors (`get #x()`) / static private fields (`static #x`) | ✅ | [syntax-class-accessor-inheritance.ts](conformance/syntax-class-accessor-inheritance.ts), [syntax-class-static-inheritance.ts](conformance/syntax-class-static-inheritance.ts) | |
181
- | `accessor` fields | ✅ | — | Plain fields (decorating them is not supported) |
182
- | Static inheritance (`Child.staticOfParent()`) | ✅ | [syntax-class-static-inheritance.ts](conformance/syntax-class-static-inheritance.ts) | Resolved to the declaring class's `Parent_member` at compile time |
183
- | Inherited getters / setters, `super.x` on accessors | ✅ | [syntax-class-accessor-inheritance.ts](conformance/syntax-class-accessor-inheritance.ts) | Accessors are copied onto subclasses like methods |
184
- | Object-literal setters (`set x(v) {}`) | ✅ | [syntax-object-setters.ts](conformance/syntax-object-setters.ts) | A `Set_x` closure field: `o.x = v` calls it |
185
- | Mixins (class factories, `return class extends Base {}`, `class extends f()`) | ❌ | — | `Unsupported syntax: ClassExpression` outside `const C = class {}` |
186
- | Polymorphic `this` return types (fluent chains) | ✅ | [syntax-polymorphic-this.ts](conformance/syntax-polymorphic-this.ts) | `this` is the class; methods inherited by a subclass return the subclass |
187
- | Dynamic keys on class instances and typed objects (`inst[key]`) | ✅ | [syntax-instance-keys.ts](conformance/syntax-instance-keys.ts) | A `switch` over the declared fields and getters (reads and writes); through `any`, reflection |
188
- | Declaration merging (interface + interface, enum + enum, class + interface) | ✅ | [syntax-declaration-merging.ts](conformance/syntax-declaration-merging.ts) | Merged within one scope; an interface adds its properties to a same-named class as fields; namespace + function merging works too |
189
- | Prototype mutation (`C.prototype.m = …`, `Object.setPrototypeOf`, `util.inherits`) | 🚫 | — | Classes are static Go structs with fixed method sets |
177
+ | Feature | Status | Probe | Notes |
178
+ | ---------------------------------------------------------------------------------------------------------------------- | :----: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
179
+ | Classes | ✅ | [syntax-class.ts](conformance/syntax-class.ts) | Transpiled to Go structs with constructor and receiver methods |
180
+ | Constructor parameter properties | ✅ | [syntax-class-parameter-properties.ts](conformance/syntax-class-parameter-properties.ts) | `constructor(private x: number)` |
181
+ | Class inheritance | ✅ | [syntax-class-inheritance.ts](conformance/syntax-class-inheritance.ts) | `super.method()` → `self.Parent.method()`; inherited methods copied for `this` dispatch |
182
+ | `implements` clauses | ✅ | [syntax-class-implements.ts](conformance/syntax-class-implements.ts) | `class C implements I` |
183
+ | Interface `extends` | ✅ | [syntax-interface-extends.ts](conformance/syntax-interface-extends.ts) | Inherited properties flattened into the derived struct |
184
+ | Static members | ✅ | [syntax-class-static.ts](conformance/syntax-class-static.ts) | Static members → package-level `Class_member` vars/functions |
185
+ | Getters / setters (classes) | ✅ | [syntax-class-getters.ts](conformance/syntax-class-getters.ts) | `c.v` reads/writes rewrite to `Get_v()`/`Set_v()` accessor calls |
186
+ | Getters (object literals) | ✅ | [syntax-object-getters.ts](conformance/syntax-object-getters.ts) | Getter closures stored as function fields; reads invoke them |
187
+ | Object-literal methods | ✅ | [syntax-object-methods.ts](conformance/syntax-object-methods.ts) | Method closures stored as function fields capturing the instance (`this` → the object) |
188
+ | Private `#` fields | ✅ | [syntax-class-private-fields.ts](conformance/syntax-class-private-fields.ts) | `#secret` → a `__secret` struct field, left out of `JSON.stringify` and `console.log` |
189
+ | Access modifiers (`private` / `protected` / `public` on members) | ✅ | [syntax-access-modifiers.ts](conformance/syntax-access-modifiers.ts) | `private` / `protected` / `public` are erased |
190
+ | Abstract classes | ✅ | [syntax-class-abstract.ts](conformance/syntax-class-abstract.ts) | Abstract members skipped; concrete methods copied onto subclasses |
191
+ | Static initialization blocks (`static {}`) | ✅ | [syntax-static-blocks.ts](conformance/syntax-static-blocks.ts) | Go `func init()` |
192
+ | Class expressions (`const C = class {}`) | ✅ | [syntax-class-expressions.ts](conformance/syntax-class-expressions.ts) | `const C = class {…}` becomes a class named after the variable |
193
+ | Interfaces | ✅ | [syntax-class-implements.ts](conformance/syntax-class-implements.ts) | Transpiled to Go interfaces |
194
+ | Optional properties | ✅ | [syntax-optional-chaining.ts](conformance/syntax-optional-chaining.ts) | `prop?: Type` in interfaces/types |
195
+ | Type-aware method dispatch | ✅ | [semantics-method-dispatch.ts](conformance/semantics-method-dispatch.ts) | Class `.push()` / `.length` not confused with array builtins |
196
+ | Index signatures (`[key: string]: T`) | ✅ | [syntax-index-signatures.ts](conformance/syntax-index-signatures.ts) | `{ [k: K]: V }` is `Record<K, V>` (an ordered Go map) |
197
+ | Methods without a return-type annotation | ✅ | [syntax-method-return-inference.ts](conformance/syntax-method-return-inference.ts) | Inferred from the returns, as for functions (also returns nested in `if` / loops / `switch` / `try`); an inherited `return this` returns the subclass |
198
+ | Field initializers reading parameter properties or parent fields | ✅ | [syntax-class-field-order.ts](conformance/syntax-class-field-order.ts) | `super()`, then parameter properties, then field initializers, then the constructor body (TS's ES2020 order) |
199
+ | Arrow-function fields (`h = () => this.x`), fields reading earlier fields | ✅ | — | Run in the constructor; `this` is the instance |
200
+ | Private methods (`#m()`) | ✅ | [syntax-method-return-inference.ts](conformance/syntax-method-return-inference.ts) | |
201
+ | A private and a public member with the same name (`#x` and `x`) | ✅ | [syntax-private-public-names.ts](conformance/syntax-private-public-names.ts) | `#x` is the Go field `__x` |
202
+ | Private accessors (`get #x()`) / static private fields (`static #x`) | ✅ | [syntax-class-accessor-inheritance.ts](conformance/syntax-class-accessor-inheritance.ts), [syntax-class-static-inheritance.ts](conformance/syntax-class-static-inheritance.ts) | |
203
+ | `accessor` fields | ✅ | — | Plain fields (decorating them is not supported) |
204
+ | Static inheritance (`Child.staticOfParent()`) | ✅ | [syntax-class-static-inheritance.ts](conformance/syntax-class-static-inheritance.ts) | Resolved to the declaring class's `Parent_member` at compile time |
205
+ | Inherited getters / setters, `super.x` on accessors | ✅ | [syntax-class-accessor-inheritance.ts](conformance/syntax-class-accessor-inheritance.ts) | Accessors are copied onto subclasses like methods |
206
+ | Object-literal setters (`set x(v) {}`) | ✅ | [syntax-object-setters.ts](conformance/syntax-object-setters.ts) | A `Set_x` closure field: `o.x = v` calls it |
207
+ | Mixins (class factories, `return class extends Base {}`, `class extends f()`) | ❌ | — | `Unsupported syntax: ClassExpression` outside `const C = class {}` |
208
+ | Polymorphic `this` return types (fluent chains) | ✅ | [syntax-polymorphic-this.ts](conformance/syntax-polymorphic-this.ts) | `this` is the class; methods inherited by a subclass return the subclass |
209
+ | Dynamic keys on class instances and typed objects (`inst[key]`) | ✅ | [syntax-instance-keys.ts](conformance/syntax-instance-keys.ts) | A `switch` over the declared fields and getters (reads and writes); through `any`, reflection |
210
+ | Declaration merging (interface + interface, enum + enum, class + interface) | ✅ | [syntax-declaration-merging.ts](conformance/syntax-declaration-merging.ts) | Merged within one scope; an interface adds its properties to a same-named class as fields; namespace + function merging works too |
211
+ | Prototype mutation (`C.prototype.m = …`, `Object.setPrototypeOf`, `util.inherits`) | 🚫 | — | Classes are static Go structs with fixed method sets |
212
+ | Overrides dispatched on the runtime class (through a base-class type, `any` values, a base method calling an override) | ✅ | [syntax-class-polymorphism.ts](conformance/syntax-class-polymorphism.ts) | Polymorphic classes are held as `interface{}`; calls go through a per-method dispatch |
213
+ | `class C extends Array` | ✅ | [syntax-array-subclass.ts](conformance/syntax-array-subclass.ts) | The elements live in an embedded `TnArray`: indexing, `length`, `push`, iteration, spread, `Array.isArray` |
214
+ | Classes as values (chosen at run time, passed as `new (…) => T`, stored in records), `x.constructor` | ✅ | [syntax-class-values.ts](conformance/syntax-class-values.ts) | `new ctor(…)` works on class values and constructor functions alike |
215
+ | Interfaces mixing data fields and methods, implemented by object literals | ✅ | [syntax-interface-method-fields.ts](conformance/syntax-interface-method-fields.ts) | Method shorthand and arrow properties are contextually typed; optional function fields may be absent |
216
+ | `class E extends Error` setting `this.name` | ✅ | [lib-error-subclass-inspect.ts](conformance/lib-error-subclass-inspect.ts) | The subclass gets a `name` field; `util.inspect` prints `E: message` then its own properties |
217
+ | `Object.setPrototypeOf(this, new.target.prototype)` in an `Error` subclass | ✅ | [syntax-error-subclass-idiom.ts](conformance/syntax-error-subclass-idiom.ts) | The ES5-era idiom is dropped (classes are already their own type); other `setPrototypeOf` calls are errors |
190
218
 
191
219
  ## Generics
192
220
 
193
- | Feature | Status | Probe | Notes |
194
- | ------------------------------------------------------------- | :----: | ------------------------------------------------------------------------------ | -------------------------------------------------------------------------- |
195
- | Generic functions | ✅ | [syntax-generic-functions.ts](conformance/syntax-generic-functions.ts) | Type parameters → Go generics; call sites infer from arguments |
196
- | Generic classes | ✅ | [syntax-generic-classes.ts](conformance/syntax-generic-classes.ts) | Type parameters via Go generics |
197
- | Generic constraints (`<T extends U>`) | ✅ | [syntax-generic-constraints.ts](conformance/syntax-generic-constraints.ts) | Object-type bounds become `any`; properties of `T` values read dynamically |
198
- | Default type parameters (`<T = D>`) | ✅ | [syntax-generic-defaults.ts](conformance/syntax-generic-defaults.ts) | Defaults are erased; Go infers from arguments |
199
- | Generic interfaces / type aliases | ✅ | [syntax-generic-interfaces.ts](conformance/syntax-generic-interfaces.ts) | Go generic structs; literals instantiate them (`Box[float64]{…}`) |
200
- | `const` type parameters / variance annotations (`in` / `out`) | ✅ | [syntax-const-type-parameters.ts](conformance/syntax-const-type-parameters.ts) | Erased; object literals of method interfaces use an adapter struct |
221
+ | Feature | Status | Probe | Notes |
222
+ | ------------------------------------------------------------------------------------------ | :----: | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
223
+ | Generic functions | ✅ | [syntax-generic-functions.ts](conformance/syntax-generic-functions.ts) | Type parameters → Go generics; call sites infer from arguments |
224
+ | Generic classes | ✅ | [syntax-generic-classes.ts](conformance/syntax-generic-classes.ts) | Type parameters via Go generics |
225
+ | Generic constraints (`<T extends U>`) | ✅ | [syntax-generic-constraints.ts](conformance/syntax-generic-constraints.ts) | Object-type bounds become `any`; properties of `T` values read dynamically |
226
+ | Default type parameters (`<T = D>`) | ✅ | [syntax-generic-defaults.ts](conformance/syntax-generic-defaults.ts) | Defaults are erased; Go infers from arguments |
227
+ | Generic interfaces / type aliases | ✅ | [syntax-generic-interfaces.ts](conformance/syntax-generic-interfaces.ts) | Go generic structs; literals instantiate them (`Box[float64]{…}`) |
228
+ | `const` type parameters / variance annotations (`in` / `out`) | ✅ | [syntax-const-type-parameters.ts](conformance/syntax-const-type-parameters.ts) | Erased; object literals of method interfaces use an adapter struct |
229
+ | Instantiation expressions (`const f = g<number>`), explicit type arguments in call results | ✅ | [syntax-instantiation-expressions.ts](conformance/syntax-instantiation-expressions.ts) | `g<number>` is the Go instantiation `g[float64]` |
230
+ | Generic type aliases (`type WithId<T> = T & { id: number }`) | ✅ | [syntax-intersection-generic.ts](conformance/syntax-intersection-generic.ts) | The alias is instantiated with its type arguments |
201
231
 
202
232
  ## Enums
203
233
 
@@ -211,97 +241,118 @@ declared there fails the type check before it reaches the transpiler. The
211
241
 
212
242
  ## Type-system features
213
243
 
214
- | Feature | Status | Probe | Notes |
215
- | ------------------------------------------------------------------------------------ | :----: | -------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
216
- | Type aliases | ✅ | [syntax-type-aliases.ts](conformance/syntax-type-aliases.ts) | `type P = { x: number }` → Go struct; alias-of-alias |
217
- | Union types | ✅ | [syntax-union-types.ts](conformance/syntax-union-types.ts) | Narrowed via `typeof` checks |
218
- | Type guards (`is`) | ✅ | [syntax-type-guards.ts](conformance/syntax-type-guards.ts) | `p is T` → Go `bool`; `in` checks struct fields at runtime |
219
- | `as` assertions | ✅ | [syntax-type-aliases.ts](conformance/syntax-type-aliases.ts) | `x as T`, incl. angle-bracket syntax (`<T>x`); `any` values convert to `T` |
220
- | Self-host contextual typing | ✅ | [syntax-selfhost-context.ts](conformance/syntax-selfhost-context.ts) | Object/array literals typed from context, `Record` literals, `in`, `any` params |
221
- | Decorators (`@`) | ✅ | [syntax-decorators.ts](conformance/syntax-decorators.ts) | Standard method & class decorators, applied in source order; `this` is the receiver |
222
- | Field / accessor / parameter decorators, `context.addInitializer`, `Symbol.metadata` | ❌ | — | Only method and class decorators: field and accessor decorators fail the type check (`ClassFieldDecoratorContext` / `ClassAccessorDecoratorContext` are not declared) |
223
- | Namespaces / `module` blocks | ✅ | [syntax-namespaces.ts](conformance/syntax-namespaces.ts) | Flattened to prefixed declarations (`N.f` → `N_f`), nested and in types |
224
- | `override` modifier | ✅ | [syntax-override.ts](conformance/syntax-override.ts) | Erased |
225
- | `readonly` modifier (properties, `readonly T[]`) | ✅ | [syntax-readonly.ts](conformance/syntax-readonly.ts) | Erased (`readonly T[]` → `[]T`) |
226
- | `satisfies` operator | ✅ | [syntax-satisfies.ts](conformance/syntax-satisfies.ts) | Checked by tsc, erased; the type guides literals |
227
- | `keyof` / mapped types | ✅ | [syntax-keyof-mapped-types.ts](conformance/syntax-keyof-mapped-types.ts) | `keyof` → `string`; mapped types → structs (literal keys) or maps |
228
- | Conditional types | ✅ | [syntax-conditional-types.ts](conformance/syntax-conditional-types.ts) | Resolved to their branch's Go type |
229
- | `infer` types | ✅ | [syntax-infer-types.ts](conformance/syntax-infer-types.ts) | Resolved to their branch's Go type |
230
- | `import type` / `export type` | ✅ | [syntax-import-type.ts](conformance/syntax-import-type.ts) | Type-only imports are erased |
231
- | Intersection types (`A & B`) | ✅ | [syntax-intersection-types.ts](conformance/syntax-intersection-types.ts) | Object types merge into one struct |
232
- | Literal types (`'a' \| 'b'`) | ✅ | [syntax-literal-types.ts](conformance/syntax-literal-types.ts) | Erased; string/number/boolean literals map to their base Go types |
233
- | Tuple optional / rest / labeled elements | ✅ | [syntax-tuple-elements.ts](conformance/syntax-tuple-elements.ts) | Tuples are slices |
234
- | Indexed access types (`T['k']`) | ✅ | [syntax-indexed-access-types.ts](conformance/syntax-indexed-access-types.ts) | `T['k']` resolves to the member type |
235
- | Type-level `typeof` (`typeof obj`) | ✅ | [syntax-type-typeof.ts](conformance/syntax-type-typeof.ts) | The variable's Go type |
236
- | Template literal types | ✅ | [syntax-template-literal-types.ts](conformance/syntax-template-literal-types.ts) | Template literal types → `string` |
237
- | Utility types (`Partial`, `Pick`, `Omit`, …) | ✅ | [syntax-utility-types.ts](conformance/syntax-utility-types.ts) | `Partial` / `Required` / `Readonly` / `Pick` / `Omit` / `NonNullable` → the base type |
238
- | Assertion functions (`asserts x is T`) | ✅ | [syntax-assertion-functions.ts](conformance/syntax-assertion-functions.ts) | No return value |
239
- | Callable / construct signatures (`type F = { (): void }`) | ✅ | [syntax-callable-signatures.ts](conformance/syntax-callable-signatures.ts) | Function types; a class passed as a value is its constructor |
240
- | JSX / `.tsx` syntax | ✅ | [syntax-jsx.tsx](conformance/syntax-jsx.tsx) | Renders to HTML strings (text escaped); components are calls with props |
241
- | Ambient declarations (`declare`, `.d.ts`, `x!: T`) | ✅ | [syntax-ambient-declarations.ts](conformance/syntax-ambient-declarations.ts) | `declare` only types code; `declare const` is an unset variable |
242
- | `export =` / `import x = require()` | ✅ | [syntax-export-equals.ts](conformance/syntax-export-equals.ts) | `import x = require()` is a namespace import |
243
- | Recursive types (`type Tree = { children: Tree[] }`) | ✅ | — | Self-referencing structs |
244
+ | Feature | Status | Probe | Notes |
245
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :----: | -------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
246
+ | Type aliases | ✅ | [syntax-type-aliases.ts](conformance/syntax-type-aliases.ts) | `type P = { x: number }` → Go struct; alias-of-alias |
247
+ | Union types | ✅ | [syntax-union-types.ts](conformance/syntax-union-types.ts) | Narrowed via `typeof` checks |
248
+ | Type guards (`is`) | ✅ | [syntax-type-guards.ts](conformance/syntax-type-guards.ts) | `p is T` → Go `bool`; `in` checks struct fields at runtime |
249
+ | `as` assertions | ✅ | [syntax-type-aliases.ts](conformance/syntax-type-aliases.ts) | `x as T`, incl. angle-bracket syntax (`<T>x`); `any` values convert to `T` |
250
+ | Self-host contextual typing | ✅ | [syntax-selfhost-context.ts](conformance/syntax-selfhost-context.ts) | Object/array literals typed from context, `Record` literals, `in`, `any` params |
251
+ | Decorators (`@`) | ✅ | [syntax-decorators.ts](conformance/syntax-decorators.ts) | Standard method & class decorators, applied in source order; `this` is the receiver |
252
+ | Field / accessor / parameter decorators, `context.addInitializer`, `Symbol.metadata` | ❌ | — | Only method and class decorators: field and accessor decorators fail the type check (`ClassFieldDecoratorContext` / `ClassAccessorDecoratorContext` are not declared) |
253
+ | Namespaces / `module` blocks | ✅ | [syntax-namespaces.ts](conformance/syntax-namespaces.ts) | Flattened to prefixed declarations (`N.f` → `N_f`), nested and in types |
254
+ | `override` modifier | ✅ | [syntax-override.ts](conformance/syntax-override.ts) | Erased |
255
+ | `readonly` modifier (properties, `readonly T[]`) | ✅ | [syntax-readonly.ts](conformance/syntax-readonly.ts) | Erased (`readonly T[]` → `[]T`) |
256
+ | `satisfies` operator | ✅ | [syntax-satisfies.ts](conformance/syntax-satisfies.ts) | Checked by tsc, erased; the type guides literals |
257
+ | `keyof` / mapped types | ✅ | [syntax-keyof-mapped-types.ts](conformance/syntax-keyof-mapped-types.ts) | `keyof` → `string`; mapped types → structs (literal keys) or maps |
258
+ | Conditional types | ✅ | [syntax-conditional-types.ts](conformance/syntax-conditional-types.ts) | Resolved to their branch's Go type |
259
+ | `infer` types | ✅ | [syntax-infer-types.ts](conformance/syntax-infer-types.ts) | Resolved to their branch's Go type |
260
+ | `import type` / `export type` | ✅ | [syntax-import-type.ts](conformance/syntax-import-type.ts) | Type-only imports are erased |
261
+ | Intersection types (`A & B`) | ✅ | [syntax-intersection-types.ts](conformance/syntax-intersection-types.ts) | Object types merge into one struct |
262
+ | Literal types (`'a' \| 'b'`) | ✅ | [syntax-literal-types.ts](conformance/syntax-literal-types.ts) | Erased; string/number/boolean literals map to their base Go types |
263
+ | Tuple optional / rest / labeled elements | ✅ | [syntax-tuple-elements.ts](conformance/syntax-tuple-elements.ts) | Tuples are slices |
264
+ | Indexed access types (`T['k']`) | ✅ | [syntax-indexed-access-types.ts](conformance/syntax-indexed-access-types.ts) | `T['k']` resolves to the member type |
265
+ | Type-level `typeof` (`typeof obj`) | ✅ | [syntax-type-typeof.ts](conformance/syntax-type-typeof.ts) | The variable's Go type |
266
+ | Template literal types | ✅ | [syntax-template-literal-types.ts](conformance/syntax-template-literal-types.ts) | Template literal types → `string` |
267
+ | Utility types (`Partial`, `Pick`, `Omit`, …) | ✅ | [syntax-utility-types.ts](conformance/syntax-utility-types.ts) | `Partial` / `Required` / `Readonly` / `Pick` / `Omit` / `NonNullable` → the base type |
268
+ | Assertion functions (`asserts x is T`) | ✅ | [syntax-assertion-functions.ts](conformance/syntax-assertion-functions.ts) | No return value |
269
+ | Callable / construct signatures (`type F = { (): void }`) | ✅ | [syntax-callable-signatures.ts](conformance/syntax-callable-signatures.ts) | Function types; a class passed as a value is its constructor |
270
+ | JSX / `.tsx` syntax | ✅ | [syntax-jsx.tsx](conformance/syntax-jsx.tsx) | Renders to HTML strings (text escaped); components are calls with props |
271
+ | Ambient declarations (`declare`, `.d.ts`, `x!: T`) | ✅ | [syntax-ambient-declarations.ts](conformance/syntax-ambient-declarations.ts) | `declare` only types code; `declare const` is an unset variable |
272
+ | `export =` / `import x = require()` | ✅ | [syntax-export-equals.ts](conformance/syntax-export-equals.ts) | `import x = require()` is a namespace import |
273
+ | Recursive types (`type Tree = { children: Tree[] }`) | ✅ | — | Self-referencing structs |
274
+ | `typeof` / `instanceof` narrowing of `unknown` values (`string`, `number`, `boolean`, `Date`, arrays, functions, objects) | ✅ | [syntax-typeof-narrowing.ts](conformance/syntax-typeof-narrowing.ts) | Inside the branch the value has the narrowed Go type and its methods |
275
+ | Forced casts (`x as unknown as T[]`) where the value is not a `T[]` | ✅ | [syntax-forced-cast.ts](conformance/syntax-forced-cast.ts) | The value stays what it is; a method returning one returns any value |
276
+ | `typeof f` of a declared function as a type | ✅ | [syntax-typeof-function-type.ts](conformance/syntax-typeof-function-type.ts) | Its Go func type: values of it (record fields, destructured parameters) are called directly |
277
+ | User-defined type guards (`(t): t is string`, declared or a local arrow) narrowing an optional argument | ✅ | [syntax-type-guard-narrowing.ts](conformance/syntax-type-guard-narrowing.ts) | Where the call is true, the argument is its non-nullable type |
278
+ | Generic interfaces used without type arguments; interfaces extending `Omit<>` / `Pick<>` / `Partial<>`; open object types (`{ [k: string]: any; … }`); call signatures declared in a function; array types with properties (`T[] & { links: L }`) | ✅ | [syntax-object-type-forms.ts](conformance/syntax-object-type-forms.ts) | Unused type parameters are erased; an array type with properties is an `Array` subclass |
279
+ | A `string \| null` (number, boolean) field holding the value, `null` or `undefined` | ✅ | [syntax-nullable-primitive-fields.ts](conformance/syntax-nullable-primitive-fields.ts) | An any field: `x \|\| null`, `x ?? null` and a conditional's `null` branch store `null`, which `JSON.stringify` writes; an absent value is left out |
244
280
 
245
281
  ## Modules & imports
246
282
 
247
- | Feature | Status | Probe | Notes |
248
- | ------------------------------------------------------------------ | :----: | ------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
249
- | Named imports | ✅ | [syntax-import-go.ts](conformance/syntax-import-go.ts) | `import { x } from './file'` |
250
- | Import renaming (`import { x as y }`) | ✅ | [syntax-import-renaming.ts](conformance/syntax-import-renaming.ts) | Local file imports |
251
- | Named exports (`export const` / `export function`) | ✅ | [syntax-import-local.ts](conformance/syntax-import-local.ts) | Helper [import-local-helper.ts](conformance/import-local-helper.ts) exports `multiply` |
252
- | Default imports | ✅ | [syntax-import-go.ts](conformance/syntax-import-go.ts) | `import x from 'pkg'` — namespace stripped in output |
253
- | Namespace imports | ✅ | [syntax-import-go.ts](conformance/syntax-import-go.ts) | `import * as x from 'pkg'` |
254
- | Local file imports | ✅ | [syntax-import-local.ts](conformance/syntax-import-local.ts) | Relative paths transpiled to a separate Go file (helper: [import-local-helper.ts](conformance/import-local-helper.ts)) |
255
- | Default export | ✅ | [syntax-default-export.ts](conformance/syntax-default-export.ts) | `export default function` |
256
- | Node.js built-in imports | ✅ | [lib-node-path.ts](conformance/lib-node-path.ts) | `node:x` or bare (`'fs'`), named / default / namespace imports, subpaths (`fs/promises`) (see [Node builtins](#node-builtins-node)) |
257
- | Go package imports | ✅ | [syntax-import-go.ts](conformance/syntax-import-go.ts) | `import { x } from 'go:pkg'` |
258
- | npm package imports | ✅ | [syntax-import-npm.ts](conformance/syntax-import-npm.ts) | `import { x } from 'pkg'` mapped to Go module imports |
259
- | Re-exports (`export { x } from`, `export *`) | ✅ | [syntax-re-exports.ts](conformance/syntax-re-exports.ts) | Re-exported files are included (one Go package) |
260
- | Dynamic `import()` | ✅ | [syntax-dynamic-import.ts](conformance/syntax-dynamic-import.ts) | `const m = await import('./x')` is a namespace import |
261
- | Side-effect imports (`import './mod'`) | ✅ | [syntax-side-effect-import.ts](conformance/syntax-side-effect-import.ts) | Module top-level statements run in Go's `init()` |
262
- | `import.meta.url` | ✅ | [syntax-import-meta.ts](conformance/syntax-import-meta.ts) | The `file://` URL of the running program (`os.Executable` → `pathToFileURL`) |
263
- | JSON modules (`import data from './x.json' with { type: 'json' }`) | ✅ | [lib-json-modules.ts](conformance/lib-json-modules.ts) | Read at compile time and compiled as an object literal, so fields keep their types (helper [json-module-helper.json](conformance/json-module-helper.json)); needs `resolveJsonModule` and a `module` setting that allows import attributes in a project tsconfig |
283
+ | Feature | Status | Probe | Notes |
284
+ | ---------------------------------------------------------------------------------- | :----: | -------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
285
+ | Named imports | ✅ | [syntax-import-go.ts](conformance/syntax-import-go.ts) | `import { x } from './file'` |
286
+ | Import renaming (`import { x as y }`) | ✅ | [syntax-import-renaming.ts](conformance/syntax-import-renaming.ts) | Local file imports |
287
+ | Named exports (`export const` / `export function`) | ✅ | [syntax-import-local.ts](conformance/syntax-import-local.ts) | Helper [import-local-helper.ts](conformance/import-local-helper.ts) exports `multiply` |
288
+ | Default imports | ✅ | [syntax-import-go.ts](conformance/syntax-import-go.ts) | `import x from 'pkg'` — namespace stripped in output |
289
+ | Namespace imports | ✅ | [syntax-import-go.ts](conformance/syntax-import-go.ts) | `import * as x from 'pkg'` |
290
+ | Local file imports | ✅ | [syntax-import-local.ts](conformance/syntax-import-local.ts) | Relative paths transpiled to a separate Go file (helper: [import-local-helper.ts](conformance/import-local-helper.ts)) |
291
+ | Default export | ✅ | [syntax-default-export.ts](conformance/syntax-default-export.ts) | `export default function` |
292
+ | Node.js built-in imports | ✅ | [lib-node-path.ts](conformance/lib-node-path.ts) | `node:x` or bare (`'fs'`), named / default / namespace imports, subpaths (`fs/promises`) (see [Node builtins](#node-builtins-node)) |
293
+ | Go package imports | ✅ | [syntax-import-go.ts](conformance/syntax-import-go.ts) | `import { x } from 'go:pkg'` |
294
+ | npm package imports | ✅ | [syntax-import-npm.ts](conformance/syntax-import-npm.ts) | `import { x } from 'pkg'` mapped to Go module imports |
295
+ | Re-exports (`export { x } from`, `export *`) | ✅ | [syntax-re-exports.ts](conformance/syntax-re-exports.ts) | Re-exported files are included (one Go package) |
296
+ | Dynamic `import()` | ✅ | [syntax-dynamic-import.ts](conformance/syntax-dynamic-import.ts) | `const m = await import('./x')` is a namespace import |
297
+ | Side-effect imports (`import './mod'`) | ✅ | [syntax-side-effect-import.ts](conformance/syntax-side-effect-import.ts) | Module top-level statements run in Go's `init()` |
298
+ | `import.meta.url` | ✅ | [syntax-import-meta.ts](conformance/syntax-import-meta.ts) | The `file://` URL of the running program (`os.Executable` → `pathToFileURL`) |
299
+ | JSON modules (`import data from './x.json' with { type: 'json' }`) | ✅ | [lib-json-modules.ts](conformance/lib-json-modules.ts) | Read at compile time and compiled as an object literal, so fields keep their types (helper [json-module-helper.json](conformance/json-module-helper.json)); needs `resolveJsonModule` and a `module` setting that allows import attributes in a project tsconfig |
300
+ | Per-module top-level scopes (same-named functions, consts, classes in two modules) | ✅ | [syntax-module-scope.ts](conformance/syntax-module-scope.ts) | Module-private names are made unique per module |
301
+ | `Ns.T` of a namespace declared in another module | ✅ | [syntax-namespace-types-import.ts](conformance/syntax-namespace-types-import.ts) | `import type { Ns }` included |
264
302
 
265
303
  ## Async & timing
266
304
 
267
- | Feature | Status | Probe | Notes |
268
- | ---------------------------------------------------------------------------------------------- | :----: | -------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
269
- | `async` / `await` | ✅ | [syntax-async-await.ts](conformance/syntax-async-await.ts) | The body runs synchronously until its first `await`; `await` runs pending event-loop tasks while it waits; the loop drains before exit |
270
- | Async arrow callbacks (`emitter.on('x', async () => { await … })`, `test('t', async () => …)`) | ✅ | [lib-node-test.ts](conformance/lib-node-test.ts) | Run to completion when called (their awaits keep the event loop running), so the caller sees them finish before it continues |
271
- | `Promise` constructor / `.then` | ✅ | [syntax-promise-then.ts](conformance/syntax-promise-then.ts) | The executor runs synchronously; promises are buffered channels; `.then` callbacks run on the event loop |
272
- | `Promise.all` | ✅ | [syntax-promise-all.ts](conformance/syntax-promise-all.ts) | `TnPromiseAll` drains every promise channel into a slice |
273
- | `Promise.resolve` | ✅ | [lib-promise-resolve.ts](conformance/lib-promise-resolve.ts) | Buffered channel holding the value |
274
- | `Promise.reject` / `.catch` / `.finally` | ✅ | [lib-promise-catch.ts](conformance/lib-promise-catch.ts) | Rejected promises are closed channels with a reason; `await` rethrows |
275
- | `Promise.race` / `allSettled` / `any` | ✅ | [lib-promise-combinators.ts](conformance/lib-promise-combinators.ts) | Goroutine per promise; first settled / all settled / first fulfilled |
276
- | `clearTimeout` | ✅ | [lib-timers.ts](conformance/lib-timers.ts) | `TnClearTimeout` stops the timer |
277
- | `setInterval` / `clearInterval` | ✅ | [lib-set-interval.ts](conformance/lib-set-interval.ts) | `time.Ticker` posting to the event loop; the process lives until cleared |
278
- | `queueMicrotask` | ✅ | [lib-queue-microtask.ts](conformance/lib-queue-microtask.ts) | Runs after the current synchronous code (end of main or of an event-loop task) |
279
- | `setTimeout` | ✅ | [lib-set-timeout.ts](conformance/lib-set-timeout.ts) | `time.AfterFunc` posting the callback to the event loop, which keeps the process alive |
280
- | `resolve` / `reject` passed as values | ✅ | [lib-node-async-hooks.ts](conformance/lib-node-async-hooks.ts) | `new Promise((resolve) => setTimeout(resolve, ms))` |
281
- | Async class methods (instance, static, inherited, unannotated); `return otherPromise()` | ✅ | [syntax-async-methods.ts](conformance/syntax-async-methods.ts) | Lowered like async functions; a returned promise is awaited |
282
- | `Promise.withResolvers` / `Promise.try` | ✅ | [lib-promise-extras.ts](conformance/lib-promise-extras.ts) | |
283
- | Async arrows kept as values (`const f = async () => …`) | ✅ | [lib-promise-extras.ts](conformance/lib-promise-extras.ts) | Return a promise like async functions (concise bodies too); async arrows passed straight to a call run inline (see above) |
305
+ | Feature | Status | Probe | Notes |
306
+ | -------------------------------------------------------------------------------------------------------------------- | :----: | -------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
307
+ | `async` / `await` | ✅ | [syntax-async-await.ts](conformance/syntax-async-await.ts) | The body runs synchronously until its first `await`; `await` runs pending event-loop tasks while it waits; the loop drains before exit |
308
+ | Async arrow callbacks (`emitter.on('x', async () => { await … })`, `test('t', async () => …)`) | ✅ | [lib-node-test.ts](conformance/lib-node-test.ts) | Run to completion when called (their awaits keep the event loop running), so the caller sees them finish before it continues |
309
+ | `Promise` constructor / `.then` | ✅ | [syntax-promise-then.ts](conformance/syntax-promise-then.ts) | The executor runs synchronously; promises are buffered channels; `.then` callbacks run on the event loop |
310
+ | `Promise.all` | ✅ | [syntax-promise-all.ts](conformance/syntax-promise-all.ts) | `TnPromiseAll` drains every promise channel into a slice |
311
+ | `Promise.resolve` | ✅ | [lib-promise-resolve.ts](conformance/lib-promise-resolve.ts) | Buffered channel holding the value |
312
+ | `Promise.reject` / `.catch` / `.finally` | ✅ | [lib-promise-catch.ts](conformance/lib-promise-catch.ts) | Rejected promises are closed channels with a reason; `await` rethrows |
313
+ | `Promise.race` / `allSettled` / `any` | ✅ | [lib-promise-combinators.ts](conformance/lib-promise-combinators.ts) | Goroutine per promise; first settled / all settled / first fulfilled |
314
+ | `clearTimeout` | ✅ | [lib-timers.ts](conformance/lib-timers.ts) | `TnClearTimeout` stops the timer |
315
+ | `setInterval` / `clearInterval` | ✅ | [lib-set-interval.ts](conformance/lib-set-interval.ts) | `time.Ticker` posting to the event loop; the process lives until cleared |
316
+ | `queueMicrotask` | ✅ | [lib-queue-microtask.ts](conformance/lib-queue-microtask.ts) | Runs after the current synchronous code (end of main or of an event-loop task) |
317
+ | `setTimeout` | ✅ | [lib-set-timeout.ts](conformance/lib-set-timeout.ts) | `time.AfterFunc` posting the callback to the event loop, which keeps the process alive |
318
+ | `resolve` / `reject` passed as values | ✅ | [lib-node-async-hooks.ts](conformance/lib-node-async-hooks.ts) | `new Promise((resolve) => setTimeout(resolve, ms))` |
319
+ | Async class methods (instance, static, inherited, unannotated); `return otherPromise()` | ✅ | [syntax-async-methods.ts](conformance/syntax-async-methods.ts) | Lowered like async functions; a returned promise is awaited |
320
+ | `Promise.withResolvers` / `Promise.try` | ✅ | [lib-promise-extras.ts](conformance/lib-promise-extras.ts) | |
321
+ | Async arrows kept as values (`const f = async () => …`) | ✅ | [lib-promise-extras.ts](conformance/lib-promise-extras.ts) | Return a promise like async functions (concise bodies too); async arrows passed straight to a call run inline (see above) |
322
+ | `.then` on a `Promise.resolve(v)` held in a variable | ❌ | — | Go build error (`chan T` has no `then`); `await` it, or build it with `new Promise` |
323
+ | Microtask order: `await` inside an async function nobody awaits; `.then` callbacks before a later `setTimeout(…, 0)` | ❌ | — | The function resumes synchronously and `.then` callbacks may run after the timer; await the call to get JS's order |
284
324
 
285
325
  ## Semantics (JS behaviour preserved)
286
326
 
287
- | Feature | Status | Probe | Notes |
288
- | --------------------------------------------------------------------------------- | :----: | ---------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
289
- | Array reference semantics | ✅ | [semantics-array-reference.ts](conformance/semantics-array-reference.ts) | Array variables hold `*[]T` so aliases share the slice header |
290
- | `any[]` arrays mutated through a parameter (`function f(a: any[]) { a.push(x) }`) | ❌ | — | `any[]` arrays are plain `[]interface{}`, not shared references: a `push` inside the callee is lost to the caller (typed arrays share) |
291
- | Object reference semantics | ✅ | [semantics-object-reference.ts](conformance/semantics-object-reference.ts) | Aliased objects share state; [semantics-parameter-mutation.ts](conformance/semantics-parameter-mutation.ts) |
292
- | Object identity | ✅ | [semantics-object-identity.ts](conformance/semantics-object-identity.ts) | Equal literals are different references |
293
- | Object key order | ✅ | [semantics-object-key-order.ts](conformance/semantics-object-key-order.ts) | Insertion order preserved |
294
- | Map insertion order | ✅ | [semantics-map-order.ts](conformance/semantics-map-order.ts) | Iteration follows insertion order |
295
- | Set insertion order | ✅ | [semantics-set-order.ts](conformance/semantics-set-order.ts) | Spread follows insertion order |
296
- | Default sort is lexicographic | ✅ | [semantics-default-sort.ts](conformance/semantics-default-sort.ts) | `[10, 9, 1].sort()` → `1,10,9` |
297
- | Float math | ✅ | [semantics-float-math.ts](conformance/semantics-float-math.ts) | `7 / 2 === 3.5`, `0.1 + 0.2 !== 0.3` |
298
- | Integer precision | ✅ | [semantics-integer-precision.ts](conformance/semantics-integer-precision.ts) | `2 ** 53 + 1 === 2 ** 53` |
299
- | `NaN` semantics | ✅ | [semantics-nan.ts](conformance/semantics-nan.ts) | `NaN !== NaN`, `Number.isNaN(0 / 0)` |
300
- | String-number concatenation order | ✅ | [semantics-string-number-concat.ts](conformance/semantics-string-number-concat.ts) | `'a' + 1 + 2` vs `1 + 2 + 'a'` |
301
- | Array truthiness | ✅ | [semantics-array-truthy.ts](conformance/semantics-array-truthy.ts) | Empty array is truthy |
302
- | An object's own `length` field (`{ length: 3 }.length`) | ✅ | [semantics-length-field.ts](conformance/semantics-length-field.ts) | A field read, not an array length |
303
- | Loop closures capture per-iteration `let` | ✅ | [semantics-loop-closures.ts](conformance/semantics-loop-closures.ts) | |
304
- | Functions stored in Records | ✅ | [semantics-record-functions.ts](conformance/semantics-record-functions.ts) | `rec.fn()` → `rec.Get("fn")()`, also for names like `get` / `sort` |
327
+ | Feature | Status | Probe | Notes |
328
+ | --------------------------------------------------------------------------------------------------------- | :----: | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
329
+ | Array reference semantics | ✅ | [semantics-array-reference.ts](conformance/semantics-array-reference.ts) | Array variables hold `*[]T` so aliases share the slice header |
330
+ | `any[]` arrays mutated through a parameter (`function f(a: any[]) { a.push(x) }`) | ❌ | — | `any[]` arrays are plain `[]interface{}`, not shared references: a `push` inside the callee is lost to the caller (typed arrays share) |
331
+ | Arrays held in a `Map` / `Record` / array, mutated in place (`m.get(k)!.push(x)`) | ❌ | — | Containers hold `[]T` by value: a `push` on the element doesn't compile, and a `push` through a local read of it (`const a = m.get(k)!`) is lost. Read, modify, then `set` it back |
332
+ | Object reference semantics | ✅ | [semantics-object-reference.ts](conformance/semantics-object-reference.ts) | Aliased objects share state; [semantics-parameter-mutation.ts](conformance/semantics-parameter-mutation.ts) |
333
+ | Object identity | ✅ | [semantics-object-identity.ts](conformance/semantics-object-identity.ts) | Equal literals are different references |
334
+ | Object key order | ✅ | [semantics-object-key-order.ts](conformance/semantics-object-key-order.ts) | Insertion order preserved |
335
+ | Map insertion order | ✅ | [semantics-map-order.ts](conformance/semantics-map-order.ts) | Iteration follows insertion order |
336
+ | Set insertion order | ✅ | [semantics-set-order.ts](conformance/semantics-set-order.ts) | Spread follows insertion order |
337
+ | Default sort is lexicographic | ✅ | [semantics-default-sort.ts](conformance/semantics-default-sort.ts) | `[10, 9, 1].sort()` → `1,10,9` |
338
+ | Float math | ✅ | [semantics-float-math.ts](conformance/semantics-float-math.ts) | `7 / 2 === 3.5`, `0.1 + 0.2 !== 0.3` |
339
+ | Number to string (`String(n)`, templates, `JSON.stringify`) | ✅ | [semantics-number-to-string.ts](conformance/semantics-number-to-string.ts) | Plain notation from `1e-6` up to `1e21`, exponent form (`1e-7`, `1e+21`) outside it |
340
+ | Integer precision | ✅ | [semantics-integer-precision.ts](conformance/semantics-integer-precision.ts) | `2 ** 53 + 1 === 2 ** 53` |
341
+ | `NaN` semantics | ✅ | [semantics-nan.ts](conformance/semantics-nan.ts) | `NaN !== NaN`, `Number.isNaN(0 / 0)` |
342
+ | String-number concatenation order | ✅ | [semantics-string-number-concat.ts](conformance/semantics-string-number-concat.ts) | `'a' + 1 + 2` vs `1 + 2 + 'a'` |
343
+ | Array truthiness | ✅ | [semantics-array-truthy.ts](conformance/semantics-array-truthy.ts) | Empty array is truthy |
344
+ | An object's own `length` field (`{ length: 3 }.length`) | ✅ | [semantics-length-field.ts](conformance/semantics-length-field.ts) | A field read, not an array length |
345
+ | Loop closures capture per-iteration `let` | ✅ | [semantics-loop-closures.ts](conformance/semantics-loop-closures.ts) | |
346
+ | Functions stored in Records | ✅ | [semantics-record-functions.ts](conformance/semantics-record-functions.ts) | `rec.fn()` → `rec.Get("fn")()`, also for names like `get` / `sort` |
347
+ | An array field passed to a function or returned from one is the same array | ✅ | [semantics-shared-arrays.ts](conformance/semantics-shared-arrays.ts) | Callees get a `*[]T` reference to the field; `return n.sep ?? n.items` returns the field itself |
348
+ | A local alias of an array field (`const a = o.items; a.push(x)`) | ❌ | — | The variable holds its own slice: pushes and splices through it do not reach the field |
349
+ | An array read from an `any` object into a variable, then pushed to | ❌ | — | `o.list.push(x)` reaches the object; `const l = o.list; l.push(x)` does not |
350
+ | `null` in program data (`JSON.parse`, arrays and objects of `any`) is not `undefined` | ✅ | [semantics-json-null.ts](conformance/semantics-json-null.ts) | It prints, serializes and stringifies as `null`; `=== undefined` is false. A `null` stored in a typed slot is still Go `nil` |
351
+ | Arrays are shared: an object field, a variable and a parameter holding one array see each other's changes | ✅ | [semantics-array-aliasing.ts](conformance/semantics-array-aliasing.ts) | An object type's array field is a reference (`*[]T`); a method returning its array argument returns that array |
352
+ | Mutating array methods through `any` (`tok.tokens.unshift(…)`) reach the array's other holders | ✅ | [semantics-array-write-back.ts](conformance/semantics-array-write-back.ts) | Also `x?.[i]`, `x ?? []` and `x \|\| []` on an absent array, and a `Source[]` passed as `(Source \| Other)[]` (a converted copy) |
353
+ | Object literals whose methods return the object (fluent builders), chained to any length | ✅ | [semantics-self-referencing-object.ts](conformance/semantics-self-referencing-object.ts) | Type inference is memoized per query, so long chains compile in linear time |
354
+ | Key order of an `any`-typed object literal (`const o: any = { b: 1, a: 2 }`) | ❌ | — | It becomes a Go map, whose keys come out sorted (`a, b`); a typed (or inferred) literal keeps its order |
355
+ | `arr?.length` on an absent array | ❌ | — | Reads `0` instead of `undefined`; test `arr` itself |
305
356
 
306
357
  ## Sample apps
307
358
 
@@ -312,6 +363,23 @@ End-to-end programs that combine many features the way real code does (they run
312
363
  | `wc`-style CLI | [app-cli-wordcount.ts](conformance/app-cli-wordcount.ts) | `util.parseArgs`, `fs`, `path`, `os.EOL`, a class with a `Map` field, tuples sorted with a `\|\|` comparator, `reduce` into an object, `crypto` |
313
364
  | JSON API on HTTP + SQLite | [app-http-sqlite.ts](conformance/app-http-sqlite.ts) | `http.createServer` routing, `URL`, `node:sqlite` prepared statements, `fetch` (POST / GET / DELETE), JSON bodies, status codes |
314
365
  | Stream pipeline | [app-stream-pipeline.ts](conformance/app-stream-pipeline.ts) | A generator through `Readable.from`, a CSV-aggregating `Transform`, `Float64Array` series, `stream/promises` `pipeline` to files, gzip and Brotli streams, SHA-256 |
366
+ | Native window | [app-webview-window.ts](conformance/app-webview-window.ts) | A real `@webviewjs/webview` window whose page calls the program's own `http` server, then closes (runs with `TN_WEBVIEW_SMOKE=1`) |
367
+
368
+ ## Examples
369
+
370
+ The programs in [examples/](examples/) show where a native binary beats Node.js, each with a benchmark. They
371
+ take arguments or keep running, so the suite type-checks and builds them as `example-<name>` without running
372
+ them (`node scripts/conformance.mjs example`).
373
+
374
+ | Example | Source | Covers |
375
+ | ------------------------------------------ | -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
376
+ | [hello-world](examples/hello-world/) | [main.ts](examples/hello-world/main.ts) | `process.argv`, template literals: process startup |
377
+ | [fibonacci](examples/fibonacci/) | [main.ts](examples/fibonacci/main.ts) | Recursion, `perf_hooks`: CPU-bound compute |
378
+ | [json-server](examples/json-server/) | [main.ts](examples/json-server/main.ts) | `node:http` GET / POST JSON routes, `URL`: HTTP throughput |
379
+ | [todo-cli](examples/todo-cli/) | [main.ts](examples/todo-cli/main.ts) | `process.argv` destructuring with default and rest, `fs` atomic writes (`renameSync`), `os.homedir()`, `process.env`: per-command latency |
380
+ | [dupe-finder](examples/dupe-finder/) | [main.ts](examples/dupe-finder/main.ts) | Recursive `readdirSync` with `withFileTypes`, `statSync`, SHA-256 `createHash`, `Map` grouping, JSON report to disk: disk scan + hashing |
381
+ | [mandelbrot-png](examples/mandelbrot-png/) | [main.ts](examples/mandelbrot-png/main.ts) | Float loop, tuple returns, `Uint8Array` / `DataView`, a PNG encoder on `zlib.deflateSync` + `zlib.crc32`: image rendering with no deps |
382
+ | [desktop-notes](examples/desktop-notes/) | [main.ts](examples/desktop-notes/main.ts), [ui.ts](examples/desktop-notes/ui.ts) | `node:http` REST routes, `fs` note files, UI compiled in from a `.ts` module, `@webviewjs/webview` window (own process under Node.js): launch time + memory |
315
383
 
316
384
  ## Standard library
317
385
 
@@ -359,44 +427,53 @@ Every standard-library API TypeNative ports, split by module. Per
359
427
 
360
428
  ### `Object`
361
429
 
362
- | API | Status | Probe | Notes |
363
- | ---------------------------------------------------------------------------------------------------------------- | :----: | -------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
364
- | `Object.keys` / `values` / `entries` | ✅ | [lib-object-helpers.ts](conformance/lib-object-helpers.ts) | Map key/value iteration helpers; typed results for maps and records |
365
- | `Object.keys` / `values` / `entries`, `for...in` on typed objects (interfaces, object literals, class instances) | ✅ | [lib-object-keys-typed.ts](conformance/lib-object-keys-typed.ts) | Own data fields in declaration order, a parent class's first; no `#private` fields or accessors (they are on the prototype); unset optional properties are absent |
366
- | `Object.assign` | ✅ | [lib-object-assign.ts](conformance/lib-object-assign.ts) | Sources (structs, maps, dynamic objects) copied into an ordered map |
367
- | `Object.freeze` / `seal` / `preventExtensions` / `isFrozen` / `isSealed` / `isExtensible` | ✅ | [lib-object-freeze.ts](conformance/lib-object-freeze.ts) | Integrity level tracked by identity; writes rejected by `Readonly<T>` types (`preventExtensions` / `isSealed` / `isExtensible` not probed) |
368
- | `Object.fromEntries` | ✅ | [lib-object-from-entries.ts](conformance/lib-object-from-entries.ts) | `TnFromEntries` → dynamic object |
369
- | `Object.hasOwn` / `defineProperty` / `getOwnPropertyNames` | ✅ | [lib-object-own.ts](conformance/lib-object-own.ts) | Maps, dynamic objects and typed objects (literal keys); `{ value }` descriptors |
370
- | `Object.hasOwn` / `defineProperty` with a non-literal key on a typed object | ✅ | [lib-object-own-computed.ts](conformance/lib-object-own-computed.ts) | A `switch` over the declared fields (an unset optional field is not own) |
371
- | `Object.is` | ✅ | [lib-builtins-statics.ts](conformance/lib-builtins-statics.ts) | SameValue; two empty object literals may share an address in Go, so `Object.is({}, {})` can be `true` |
372
- | `Object.groupBy` / `Map.groupBy` | ✅ | [lib-group-by.ts](conformance/lib-group-by.ts) | Groups in first-seen key order |
373
- | `Object.create` / `getPrototypeOf` / `getOwnPropertyDescriptor(s)` / `defineProperties` | ❌ | — | Not declared |
430
+ | API | Status | Probe | Notes |
431
+ | ------------------------------------------------------------------------------------------------------------------------------- | :----: | -------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
432
+ | `Object.keys` / `values` / `entries` | ✅ | [lib-object-helpers.ts](conformance/lib-object-helpers.ts) | Map key/value iteration helpers; typed results for maps and records |
433
+ | `Object.keys` / `values` / `entries`, `for...in` on typed objects (interfaces, object literals, class instances) | ✅ | [lib-object-keys-typed.ts](conformance/lib-object-keys-typed.ts) | Own data fields in declaration order, a parent class's first; no `#private` fields or accessors (they are on the prototype); unset optional properties are absent |
434
+ | `Object.assign` | ✅ | [lib-object-assign.ts](conformance/lib-object-assign.ts) | Sources (structs, maps, dynamic objects) copied into an ordered map |
435
+ | `Object.freeze` / `seal` / `preventExtensions` / `isFrozen` / `isSealed` / `isExtensible` | ✅ | [lib-object-freeze.ts](conformance/lib-object-freeze.ts) | Integrity level tracked by identity; writes rejected by `Readonly<T>` types (`preventExtensions` / `isSealed` / `isExtensible` not probed) |
436
+ | `Object.fromEntries` | ✅ | [lib-object-from-entries.ts](conformance/lib-object-from-entries.ts) | `TnFromEntries` → dynamic object |
437
+ | `Object.hasOwn` / `defineProperty` / `getOwnPropertyNames` | ✅ | [lib-object-own.ts](conformance/lib-object-own.ts) | Maps, dynamic objects and typed objects (literal keys); `{ value }` descriptors |
438
+ | `Object.hasOwn` / `defineProperty` with a non-literal key on a typed object | ✅ | [lib-object-own-computed.ts](conformance/lib-object-own-computed.ts) | A `switch` over the declared fields (an unset optional field is not own) |
439
+ | `Object.is` | ✅ | [lib-builtins-statics.ts](conformance/lib-builtins-statics.ts) | SameValue; two empty object literals may share an address in Go, so `Object.is({}, {})` can be `true` |
440
+ | `Object.groupBy` / `Map.groupBy` | ✅ | [lib-group-by.ts](conformance/lib-group-by.ts) | Groups in first-seen key order |
441
+ | `Object.create(null)` | ✅ | [lib-object-create-null.ts](conformance/lib-object-create-null.ts) | An empty dynamic object (the prototype-less dictionary idiom) |
442
+ | `Object.create(C.prototype)` / `getPrototypeOf` / `getOwnPropertyDescriptors` / `defineProperties` | ✅ | [lib-object-create-proto.ts](conformance/lib-object-create-proto.ts) | Class values stand in for prototypes: an instance without its constructor run (unset fields are zero values); `getPrototypeOf` gives the class |
443
+ | `Object.assign` keeps types: a typed target updated in place, `Object.assign({}, typed, { overrides })` a copy of the same type | ✅ | [syntax-object-assign-typed.ts](conformance/syntax-object-assign-typed.ts) | Function fields and methods are copied; an explicit `undefined` override clears the field |
444
+ | Integer-like keys of plain objects listed first, ascending | ✅ | [lib-object-key-order.ts](conformance/lib-object-key-order.ts) | `Object.keys`, `JSON.stringify` and `for…in`; Maps keep plain insertion order |
445
+ | `Object.defineProperty(this, k, { value, writable })` in a constructor | ✅ | [lib-object-define-property.ts](conformance/lib-object-define-property.ts) | Sets the field (or the record entry) |
446
+ | A `Record` built from an object's spread; an object stored where a `Record` is expected and read back | ✅ | [lib-record-spread-objects.ts](conformance/lib-record-spread-objects.ts) | A parameter may shadow a Node import of the same name |
374
447
 
375
448
  ### `String`
376
449
 
377
- | API | Status | Probe | Notes |
378
- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | :----: | ---------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
379
- | Template literals | ✅ | [syntax-template-literals.ts](conformance/syntax-template-literals.ts) | Backtick strings with `${expr}` interpolation |
380
- | Tagged templates | ✅ | [syntax-tagged-templates.ts](conformance/syntax-tagged-templates.ts) | Desugared to `tag([...strings], ...values)` |
381
- | `toUpperCase` / `toLowerCase` | ✅ | [lib-string-basics.ts](conformance/lib-string-basics.ts) | Via `strings` package |
382
- | `trim` / `trimStart` / `trimEnd` | ✅ | [lib-string-basics.ts](conformance/lib-string-basics.ts) | Via `strings` package |
383
- | `split` / `join` | ✅ | [lib-string-split-join.ts](conformance/lib-string-split-join.ts) | Via `strings` package |
384
- | `includes` / `startsWith` / `endsWith` / `indexOf` (with `fromIndex`) | ✅ | [lib-string-search.ts](conformance/lib-string-search.ts) | Via `strings` package |
385
- | `replace` / `replaceAll` (string pattern) | ✅ | [lib-string-replace.ts](conformance/lib-string-replace.ts) | Via `strings` package |
386
- | `replace` / `replaceAll` (RegExp, `$1`/`$&`, fn replacer) | ✅ | [syntax-top-level-scope.ts](conformance/syntax-top-level-scope.ts) | `/g` vs first match, `$1`/`$&` patterns, function replacers |
387
- | `charAt` / `substring` / `slice` | ✅ | [lib-string-slice.ts](conformance/lib-string-slice.ts) | Direct Go string indexing/slicing |
388
- | `charCodeAt` / `String.fromCharCode` | ✅ | [lib-string-char-codes.ts](conformance/lib-string-char-codes.ts) | `charCodeAt` reads the byte; `String.fromCharCode` → `string(rune(n))` |
389
- | `concat` / `repeat` | ✅ | [lib-string-pad-repeat.ts](conformance/lib-string-pad-repeat.ts) | Concatenation and `strings.Repeat` |
390
- | `padStart` / `padEnd` | ✅ | [lib-string-pad-repeat.ts](conformance/lib-string-pad-repeat.ts) | Via `strings.Repeat` |
391
- | `localeCompare` | ✅ | [lib-string-compare.ts](conformance/lib-string-compare.ts) | `strings.Compare` → -1/0/1: code-unit order, not locale-aware |
392
- | `match` / `matchAll` / `search` | ✅ | [syntax-top-level-scope.ts](conformance/syntax-top-level-scope.ts) | Via `regexp` package (`String.match` with groups) |
393
- | `at` (negative indices) | ✅ | [lib-array-at.ts](conformance/lib-array-at.ts) | Supports negative indices |
394
- | Unicode length / iteration | ✅ | [lib-string-unicode.ts](conformance/lib-string-unicode.ts) | `.length` counts runes; `[...str]` spreads runes |
395
- | `String.raw` | ✅ | [lib-string-raw.ts](conformance/lib-string-raw.ts) | Raw template text with values interpolated |
396
- | `normalize` | ✅ | [lib-string-normalize.ts](conformance/lib-string-normalize.ts) | `golang.org/x/text/unicode/norm`, copied from GOROOT's vendor tree (offline) |
397
- | `split(sep, limit)` / `lastIndexOf(s, fromIndex)` | ✅ | [lib-builtins-statics.ts](conformance/lib-builtins-statics.ts) | |
398
- | `localeCompare(s, locales, options)` | ❌ | — | Locales / options are not declared; the comparison is by code unit |
399
- | `codePointAt` / `String.fromCodePoint` / `substr` / `trimLeft` / `trimRight` / `isWellFormed` / `toWellFormed` / `toLocaleUpperCase` / `toLocaleLowerCase` | ✅ | [lib-builtins-statics.ts](conformance/lib-builtins-statics.ts) | `codePointAt` past the end is `NaN` (JS: `undefined`); the locale variants ignore the locale |
450
+ | API | Status | Probe | Notes |
451
+ | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | :----: | ---------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
452
+ | Template literals | ✅ | [syntax-template-literals.ts](conformance/syntax-template-literals.ts) | Backtick strings with `${expr}` interpolation |
453
+ | Tagged templates | ✅ | [syntax-tagged-templates.ts](conformance/syntax-tagged-templates.ts) | Desugared to `tag([...strings], ...values)` |
454
+ | `toUpperCase` / `toLowerCase` | ✅ | [lib-string-basics.ts](conformance/lib-string-basics.ts) | Via `strings` package |
455
+ | `trim` / `trimStart` / `trimEnd` | ✅ | [lib-string-basics.ts](conformance/lib-string-basics.ts) | Via `strings` package |
456
+ | `split` / `join` | ✅ | [lib-string-split-join.ts](conformance/lib-string-split-join.ts) | Via `strings` package |
457
+ | `includes` / `startsWith` / `endsWith` / `indexOf` (with `fromIndex`) | ✅ | [lib-string-search.ts](conformance/lib-string-search.ts) | Via `strings` package |
458
+ | `replace` / `replaceAll` (string pattern) | ✅ | [lib-string-replace.ts](conformance/lib-string-replace.ts) | Via `strings` package |
459
+ | `replace` / `replaceAll` (RegExp, `$1`/`$&`, fn replacer) | ✅ | [syntax-top-level-scope.ts](conformance/syntax-top-level-scope.ts) | `/g` vs first match, `$1`/`$&` patterns, function replacers |
460
+ | `charAt` / `substring` / `slice` | ✅ | [lib-string-slice.ts](conformance/lib-string-slice.ts) | Direct Go string indexing/slicing |
461
+ | `charCodeAt` / `String.fromCharCode` | ✅ | [lib-string-char-codes.ts](conformance/lib-string-char-codes.ts) | `charCodeAt` reads the byte; `String.fromCharCode` → `string(rune(n))` |
462
+ | `concat` / `repeat` | ✅ | [lib-string-pad-repeat.ts](conformance/lib-string-pad-repeat.ts) | Concatenation and `strings.Repeat` |
463
+ | `padStart` / `padEnd` | ✅ | [lib-string-pad-repeat.ts](conformance/lib-string-pad-repeat.ts) | Via `strings.Repeat` |
464
+ | `localeCompare` | ✅ | [lib-string-compare.ts](conformance/lib-string-compare.ts) | `strings.Compare` → -1/0/1: code-unit order, not locale-aware |
465
+ | `match` / `matchAll` / `search` | ✅ | [syntax-top-level-scope.ts](conformance/syntax-top-level-scope.ts) | Via `regexp` package (`String.match` with groups) |
466
+ | `at` (negative indices) | ✅ | [lib-array-at.ts](conformance/lib-array-at.ts) | Supports negative indices |
467
+ | Unicode length / iteration | ✅ | [lib-string-unicode.ts](conformance/lib-string-unicode.ts) | `.length` counts runes; `[...str]` spreads runes |
468
+ | `String.raw` | ✅ | [lib-string-raw.ts](conformance/lib-string-raw.ts) | Raw template text with values interpolated |
469
+ | `normalize` | ✅ | [lib-string-normalize.ts](conformance/lib-string-normalize.ts) | `golang.org/x/text/unicode/norm`, copied from GOROOT's vendor tree (offline) |
470
+ | `split(sep, limit)` / `lastIndexOf(s, fromIndex)` | ✅ | [lib-builtins-statics.ts](conformance/lib-builtins-statics.ts) | |
471
+ | `localeCompare(s, locales, options)` | ❌ | — | Locales / options are not declared; the comparison is by code unit |
472
+ | `codePointAt` / `String.fromCodePoint` / `substr` / `trimLeft` / `trimRight` / `isWellFormed` / `toWellFormed` / `toLocaleUpperCase` / `toLocaleLowerCase` | ✅ | [lib-builtins-statics.ts](conformance/lib-builtins-statics.ts) | `codePointAt` past the end is `NaN` (JS: `undefined`); the locale variants ignore the locale |
473
+ | Positions in non-ASCII text (length, indexing, `indexOf`, `slice`, regex `index` / `lastIndex`) | ✅ | [lib-string-code-points.ts](conformance/lib-string-code-points.ts) | Every API counts the same units: one per character in the BMP (code points beyond it count once, not as two UTF-16 units) |
474
+ | `replace` with a `string \| RegExp` pattern, a function value as the replacer, `undefined` groups, an offset parameter | ✅ | [lib-string-replace-forms.ts](conformance/lib-string-replace-forms.ts) | |
475
+ | `toUpperCase` / `toLowerCase` as JS maps case | ✅ | [lib-string-case-mapping.ts](conformance/lib-string-case-mapping.ts) | `ß` → `SS`, `fi` → `FI`, `İ` → `i̇`, `ẞ` → `ß`, final `ς` |
476
+ | `split(sep, limit)` (string and RegExp separators); `trim` / `trimStart` / `trimEnd`; strings built with `+=` in a loop | ✅ | [lib-string-split-trim.ts](conformance/lib-string-split-trim.ts) | Trims JS whitespace (U+0085 and U+200B are not); loop accumulators are `strings.Builder`s, so building a long string is linear |
400
477
 
401
478
  ### `Array`
402
479
 
@@ -432,32 +509,35 @@ Every standard-library API TypeNative ports, split by module. Per
432
509
  | Iterator helpers on generators (`map` / `filter` / `flatMap` / `take` / `drop` / `toArray` / `forEach` / `some` / `every` / `find` / `reduce`), `Iterator.from(array)` | ✅ | [lib-iterator-helpers.ts](conformance/lib-iterator-helpers.ts) | Lazy (works on infinite generators): one goroutine per stage |
433
510
  | `Array.fromAsync` | ❌ | — | Not declared |
434
511
  | `[...map.keys()]` / `[...map.values()]` | ✅ | [lib-group-by.ts](conformance/lib-group-by.ts) | |
512
+ | `anyArray.concat([…])` with an array of another element type (`xs.concat(['x'])` on `any[]`) | ❌ | — | Go build error; spread instead (`[...xs, 'x']`) |
435
513
 
436
514
  ### `Map` / `Set`
437
515
 
438
- | API | Status | Probe | Notes |
439
- | -------------------------------------------------------- | :----: | ------------------------------------------------------------------ | ----------------------------------------------------------------------------- |
440
- | `Map` (`set` / `get` / `has` / `delete` / `size`) | ✅ | [lib-map.ts](conformance/lib-map.ts) | `Map<K, V>` → Go `map[K]V`; constructor with entries |
441
- | `Map` iteration (`for...of`, destructuring) | ✅ | [lib-map-iteration.ts](conformance/lib-map-iteration.ts) | Key/value iteration, `Object.entries()` unwrapping |
442
- | `Set` (`add` / `has` / `delete` / `size`) | ✅ | [lib-set.ts](conformance/lib-set.ts) | `Set<T>` → Go `map[T]struct{}`; constructor with values |
443
- | `Set` iteration / spread | ✅ | [syntax-top-level-scope.ts](conformance/syntax-top-level-scope.ts) | `for...of`, `[...set]` |
444
- | `Map.clear` / `Set.clear` | ✅ | [lib-map-clear.ts](conformance/lib-map-clear.ts) | `TnMap.Clear()` |
445
- | `WeakMap` / `WeakSet` | ✅ | [lib-weak-collections.ts](conformance/lib-weak-collections.ts) | Same as `Map` / `Set` (weakness is not observable) |
446
- | Set operations (`union` / `intersection` / `difference`) | ✅ | [lib-set-operations.ts](conformance/lib-set-operations.ts) | Plus `symmetricDifference` / `isSubsetOf` / `isSupersetOf` / `isDisjointFrom` |
516
+ | API | Status | Probe | Notes |
517
+ | ------------------------------------------------------------------------------------------------------------- | :----: | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
518
+ | `Map` (`set` / `get` / `has` / `delete` / `size`) | ✅ | [lib-map.ts](conformance/lib-map.ts) | `Map<K, V>` → Go `map[K]V`; constructor with entries |
519
+ | `Map` iteration (`for...of`, destructuring) | ✅ | [lib-map-iteration.ts](conformance/lib-map-iteration.ts) | Key/value iteration, `Object.entries()` unwrapping |
520
+ | `Set` (`add` / `has` / `delete` / `size`) | ✅ | [lib-set.ts](conformance/lib-set.ts) | `Set<T>` → Go `map[T]struct{}`; constructor with values |
521
+ | `Set` iteration / spread | ✅ | [syntax-top-level-scope.ts](conformance/syntax-top-level-scope.ts) | `for...of`, `[...set]` |
522
+ | `Map.clear` / `Set.clear` | ✅ | [lib-map-clear.ts](conformance/lib-map-clear.ts) | `TnMap.Clear()` |
523
+ | `WeakMap` / `WeakSet` | ✅ | [lib-weak-collections.ts](conformance/lib-weak-collections.ts) | Same as `Map` / `Set` (weakness is not observable) |
524
+ | Set operations (`union` / `intersection` / `difference`) | ✅ | [lib-set-operations.ts](conformance/lib-set-operations.ts) | Plus `symmetricDifference` / `isSubsetOf` / `isSupersetOf` / `isDisjointFrom` |
525
+ | `new Map(iterable)` / `new Set(iterable)` from Maps, iterators, generators, `Object.entries`, strings, `null` | ✅ | [lib-collection-constructors.ts](conformance/lib-collection-constructors.ts) | A Map copy keeps the source's key and value types; plain objects and arrays as keys / members are compared by identity |
447
526
 
448
527
  ### `Number`
449
528
 
450
- | API | Status | Probe | Notes |
451
- | -------------------------------------------------------------------------------------------------------- | :----: | -------------------------------------------------------------- | ----------------------------------------------------- |
452
- | `toString` (incl. radix) | ✅ | [lib-number-format.ts](conformance/lib-number-format.ts) | Universal `toString()` via `fmt.Sprintf` for any type |
453
- | `toFixed` | ✅ | [lib-number-format.ts](conformance/lib-number-format.ts) | `n.toFixed(2)` via `strconv.FormatFloat` |
454
- | `parseInt` / `parseFloat` / `Number()` | ✅ | [lib-number-parse.ts](conformance/lib-number-parse.ts) | Mapped to Go's `strconv` package |
455
- | `Number.isInteger` / `isNaN` / `MAX_SAFE_INTEGER` | ✅ | [lib-number-checks.ts](conformance/lib-number-checks.ts) | Number predicates and constants |
456
- | `Number.MIN_SAFE_INTEGER` / `MAX_VALUE` | ✅ | — | |
457
- | `Number.EPSILON` / `isFinite` / `toPrecision` | ✅ | [lib-number-misc.ts](conformance/lib-number-misc.ts) | `toPrecision` → `strconv.FormatFloat(x, 'g', n, 64)` |
458
- | `String()` / `Boolean()` conversions | ✅ | [lib-conversions.ts](conformance/lib-conversions.ts) | JS formatting / truthiness |
459
- | `toExponential` / `Number.isSafeInteger` / `parseInt` / `parseFloat` / `MIN_VALUE` / `NEGATIVE_INFINITY` | ✅ | [lib-builtins-statics.ts](conformance/lib-builtins-statics.ts) | |
460
- | Number `toLocaleString` | ❌ | — | Needs `Intl` |
529
+ | API | Status | Probe | Notes |
530
+ | -------------------------------------------------------------------------------------------------------- | :----: | -------------------------------------------------------------- | ------------------------------------------------------------------- |
531
+ | `toString` (incl. radix) | ✅ | [lib-number-format.ts](conformance/lib-number-format.ts) | Universal `toString()` via `fmt.Sprintf` for any type |
532
+ | `toFixed` | ✅ | [lib-number-format.ts](conformance/lib-number-format.ts) | `n.toFixed(2)` via `strconv.FormatFloat` |
533
+ | `parseInt` / `parseFloat` / `Number()` | ✅ | [lib-number-parse.ts](conformance/lib-number-parse.ts) | Mapped to Go's `strconv` package |
534
+ | `Number.isInteger` / `isNaN` / `MAX_SAFE_INTEGER` | ✅ | [lib-number-checks.ts](conformance/lib-number-checks.ts) | Number predicates and constants |
535
+ | `Number.MIN_SAFE_INTEGER` / `MAX_VALUE` | ✅ | — | |
536
+ | `Number.EPSILON` / `isFinite` / `toPrecision` | ✅ | [lib-number-misc.ts](conformance/lib-number-misc.ts) | `toPrecision` → `strconv.FormatFloat(x, 'g', n, 64)` |
537
+ | `String()` / `Boolean()` conversions | ✅ | [lib-conversions.ts](conformance/lib-conversions.ts) | JS formatting / truthiness |
538
+ | `toExponential` / `Number.isSafeInteger` / `parseInt` / `parseFloat` / `MIN_VALUE` / `NEGATIVE_INFINITY` | ✅ | [lib-builtins-statics.ts](conformance/lib-builtins-statics.ts) | |
539
+ | Number `toLocaleString` | ❌ | — | Needs `Intl` |
540
+ | `toFixed` rounding ties away from zero, ≥ 1e21, on `any` values and in callbacks | ✅ | [lib-number-to-fixed.ts](conformance/lib-number-to-fixed.ts) | `(1.25).toFixed(1)` is `"1.3"` (Go's formatter rounds ties to even) |
461
541
 
462
542
  ### `Date`
463
543
 
@@ -475,22 +555,26 @@ Every standard-library API TypeNative ports, split by module. Per
475
555
 
476
556
  ### `RegExp`
477
557
 
478
- | API | Status | Probe | Notes |
479
- | ----------------------------------------------------------------------------------------------------------------------------------- | :----: | -------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
480
- | Regex literals | ✅ | [lib-regex-test.ts](conformance/lib-regex-test.ts) | `/pattern/flags` transpiled to `regexp.MustCompile` |
481
- | `new RegExp()` | ✅ | [lib-regex-test.ts](conformance/lib-regex-test.ts) | Constructor with optional flags |
482
- | `test()` | ✅ | [lib-regex-test.ts](conformance/lib-regex-test.ts) | Mapped to `regexp.MatchString` |
483
- | `exec()` (groups) | ✅ | [lib-regex-groups.ts](conformance/lib-regex-groups.ts) | Mapped to `regexp.FindStringSubmatch` |
484
- | Flags (`i`, `m`) | ✅ | [lib-regex-flags.ts](conformance/lib-regex-flags.ts) | Case-insensitive, multiline |
485
- | Backreferences | ✅ | [lib-regex-backreference.ts](conformance/lib-regex-backreference.ts) | Backreference patterns run on a small backtracking engine |
486
- | Named groups | ✅ | [lib-regex-named-groups.ts](conformance/lib-regex-named-groups.ts) | `(?<name>` → `(?P<name>`; `exec` returns a match with `.groups` |
487
- | Global `exec` loop (`/g` + `lastIndex`) | ✅ | [lib-regex-global-exec.ts](conformance/lib-regex-global-exec.ts) | /g regexes carry `lastIndex` state in the `TnRegex` wrapper |
488
- | Lookbehind | ✅ | [lib-regex-lookbehind.ts](conformance/lib-regex-lookbehind.ts) | Lookaround patterns run on the backtracking engine |
489
- | Remaining flags (`s` / `u` / `y`) & `source` / `flags` | ✅ | [lib-regex-more-flags.ts](conformance/lib-regex-more-flags.ts) | Sticky matching, `\u{…}` escapes, `lastIndex` / `source` / `flags` / flag getters |
490
- | `split` with RegExp | ✅ | [lib-regex-split.ts](conformance/lib-regex-split.ts) | JS semantics: captures are included, `limit` counts items |
491
- | Match `.index` (`exec` / `match` / `matchAll`), `match` with `/g` | ✅ | [lib-regex-index-split.ts](conformance/lib-regex-index-split.ts) | Character index kept in a hidden slot of the match array; `search` counts characters |
492
- | Unicode property escapes (`\p{L}`) with `u` | ✅ | — | Go's `regexp` |
493
- | `\p{…}` in patterns that need the backtracking engine (backreferences, lookaround); `d` flag (`indices`); `v` flag; `RegExp.escape` | ❌ | — | The backtracking engine has no `\p`: `/(\p{L})\1/u` doesn't match `aa` (wrong result, no error) |
558
+ | API | Status | Probe | Notes |
559
+ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :----: | -------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
560
+ | Regex literals | ✅ | [lib-regex-test.ts](conformance/lib-regex-test.ts) | `/pattern/flags` transpiled to `regexp.MustCompile` |
561
+ | `new RegExp()` | ✅ | [lib-regex-test.ts](conformance/lib-regex-test.ts) | Constructor with optional flags |
562
+ | `test()` | ✅ | [lib-regex-test.ts](conformance/lib-regex-test.ts) | Mapped to `regexp.MatchString` |
563
+ | `exec()` (groups) | ✅ | [lib-regex-groups.ts](conformance/lib-regex-groups.ts) | Mapped to `regexp.FindStringSubmatch` |
564
+ | Flags (`i`, `m`) | ✅ | [lib-regex-flags.ts](conformance/lib-regex-flags.ts) | Case-insensitive, multiline |
565
+ | Backreferences | ✅ | [lib-regex-backreference.ts](conformance/lib-regex-backreference.ts) | Backreference patterns run on a small backtracking engine |
566
+ | Named groups | ✅ | [lib-regex-named-groups.ts](conformance/lib-regex-named-groups.ts) | `(?<name>` → `(?P<name>`; `exec` returns a match with `.groups` |
567
+ | Global `exec` loop (`/g` + `lastIndex`) | ✅ | [lib-regex-global-exec.ts](conformance/lib-regex-global-exec.ts) | /g regexes carry `lastIndex` state in the `TnRegex` wrapper |
568
+ | Lookbehind | ✅ | [lib-regex-lookbehind.ts](conformance/lib-regex-lookbehind.ts) | Lookaround patterns run on the backtracking engine |
569
+ | Remaining flags (`s` / `u` / `y`) & `source` / `flags` | ✅ | [lib-regex-more-flags.ts](conformance/lib-regex-more-flags.ts) | Sticky matching, `\u{…}` escapes, `lastIndex` / `source` / `flags` / flag getters |
570
+ | `split` with RegExp | ✅ | [lib-regex-split.ts](conformance/lib-regex-split.ts) | JS semantics: captures are included, `limit` counts items |
571
+ | Match `.index` (`exec` / `match` / `matchAll`), `match` with `/g` | ✅ | [lib-regex-index-split.ts](conformance/lib-regex-index-split.ts) | Character index kept in a hidden slot of the match array; `search` counts characters |
572
+ | Unicode property escapes (`\p{L}`) with `u` | ✅ | — | Go's `regexp` |
573
+ | `d` flag (`indices`); `v` flag; `RegExp.escape` | ❌ | — | |
574
+ | Unmatched groups are `undefined`; sticky (`y`) regexes; lookaround captures; `$&` / `` $` `` / `$'` / `$<name>` / `$$` replacements; replacer offsets | ✅ | [lib-regex-groups-replace.ts](conformance/lib-regex-groups-replace.ts) | `new RegExp(src, 'g')` keeps its flags. An unmatched group still reads as `''` in string comparisons other than `=== undefined` |
575
+ | JS escapes in every pattern, also those the backtracking engine runs (backreferences, lookaround): `\xHH`, `\uHHHH`, `\u{…}`, `\cJ`, `\p{…}` / `\P{…}`, `\k<name>`; `\s` as JS's Unicode whitespace | ✅ | [lib-regex-escapes.ts](conformance/lib-regex-escapes.ts) | Group numbers count opening parentheses, as in JS |
576
+ | RegExp values: in objects, passed around, built at run time (`new RegExp(src, 'g')`), called through `any`; an object cast to `RegExp` | ✅ | [lib-regex-values.ts](conformance/lib-regex-values.ts) | `Object.prototype.toString.call(re)` |
577
+ | Unmatched groups stay `undefined` through a `const`, a conditional and a `string` field (left out of JSON); `xs[i]` past the end into `any` | ✅ | [lib-regex-unmatched-groups.ts](conformance/lib-regex-unmatched-groups.ts) | Such a field is an any field |
494
578
 
495
579
  ### `Promise` / timers
496
580
 
@@ -500,40 +584,41 @@ See [Async & timing](#async--timing): `Promise` (constructor, `.then` / `.catch`
500
584
 
501
585
  ### Misc globals
502
586
 
503
- | API | Status | Probe | Notes |
504
- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | :----: | ------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------- |
505
- | `assert` | ✅ | [lib-console-log.ts](conformance/lib-console-log.ts) | Transpiled to `panic` on failure |
506
- | `process.argv` / `process.platform` | ✅ | [lib-process.ts](conformance/lib-process.ts) | Node's shapes (`[execPath, script, ...args]`, `win32`); the rest of `process` is in [node:process](#nodeprocess) |
507
- | `process.env` | ✅ | [syntax-top-level-scope.ts](conformance/syntax-top-level-scope.ts) | Environment variable access |
508
- | `process.exit` | ✅ | [lib-process-exit.ts](conformance/lib-process-exit.ts) | `os.Exit`, after `process.on('exit')` listeners |
509
- | `process.cwd()` | ✅ | [lib-process-cwd.ts](conformance/lib-process-cwd.ts) | `os.Getwd()` |
510
- | `Buffer` / `Uint8Array` / `TextEncoder` / `TextDecoder` / `atob` / `btoa` | ✅ | [lib-node-buffer-encodings.ts](conformance/lib-node-buffer-encodings.ts) | See [node:buffer](#nodebuffer) |
511
- | `URL` / `URLSearchParams` | ✅ | [lib-node-url-class.ts](conformance/lib-node-url-class.ts) | See [node:url](#nodeurl) |
512
- | `EventTarget` / `Event` / `AbortController` / `AbortSignal` | ✅ | [lib-node-abort.ts](conformance/lib-node-abort.ts) | See [node:events](#nodeevents) |
513
- | `performance` / `setImmediate` / `crypto` | ✅ | [lib-node-perf-hooks.ts](conformance/lib-node-perf-hooks.ts) | See [perf_hooks](#nodeperf_hooks), [timers](#nodetimers), [crypto](#nodecrypto) |
514
- | `TypeError` / `RangeError` / `SyntaxError` & co. | ✅ | [lib-node-assert.ts](conformance/lib-node-assert.ts) | `TnError`s carrying their `name`; `instanceof` checks the name |
515
- | `Infinity` | ✅ | [lib-globals.ts](conformance/lib-globals.ts) | `math.Inf(1)` |
516
- | Global `isNaN` / `isFinite` | ✅ | [lib-globals.ts](conformance/lib-globals.ts) | `math.IsNaN` / `math.IsInf` |
517
- | `encodeURIComponent` / `decodeURIComponent` | ✅ | [lib-uri.ts](conformance/lib-uri.ts) | `TnEncodeURIComponent` / `url.PathUnescape` |
518
- | `structuredClone` | ✅ | [lib-structured-clone.ts](conformance/lib-structured-clone.ts) | Reflection deep copy |
519
- | `fetch` / `Headers` / `Request` / `Response` | ✅ | [lib-node-fetch.ts](conformance/lib-node-fetch.ts) | See [fetch](#fetch) |
520
- | `ReadableStream` / `WritableStream` / `TransformStream` & co., `TextEncoderStream` / `TextDecoderStream`, `CompressionStream` / `DecompressionStream` | ✅ | [lib-node-stream-web.ts](conformance/lib-node-stream-web.ts) | See [stream/web](#nodestreamweb) |
521
- | `Blob` / `File` / `FormData` | ✅ | [lib-node-blob.ts](conformance/lib-node-blob.ts) | See [buffer](#nodebuffer) and [fetch](#fetch) |
522
- | `MessageChannel` / `MessagePort` / `BroadcastChannel` | ✅ | [lib-node-worker-threads.ts](conformance/lib-node-worker-threads.ts) | See [worker_threads](#nodeworker_threads) |
523
- | `__filename` / `__dirname` | ✅ | — | The running executable (a native binary has no script file) |
524
- | `globalThis` | ✅ | [lib-global-this.ts](conformance/lib-global-this.ts) | `globalThis.x` is the global `x`; `(globalThis as any)` is a dynamic object |
525
- | `err.stack` | ✅ | [lib-error-stack.ts](conformance/lib-error-stack.ts) | `Name: message` and an `at fn (file.ts:line)` line per TS frame (no columns), from `runtime.Callers` and the `//line` directives |
526
- | `AggregateError` (`errors`) | ✅ | [lib-error-stack.ts](conformance/lib-error-stack.ts) | |
527
- | `Error.captureStackTrace` / `Error.isError` / `DOMException` | ❌ | — | Not declared |
528
- | `Symbol.for` / `Symbol.keyFor` / `description` | ✅ | [lib-builtins-statics.ts](conformance/lib-builtins-statics.ts) | A global registry by key |
529
- | `[Symbol.asyncIterator]()` methods; `Symbol.toPrimitive` / `hasInstance` / `toStringTag` | ❌ | — | Only `Symbol()`, `Symbol.iterator` and `Symbol.dispose` are lowered |
530
- | `WeakRef` / `FinalizationRegistry` | ✅ | [lib-weak-refs.ts](conformance/lib-weak-refs.ts) | Go's `weak` package and `runtime.AddCleanup`; cleanup callbacks run on the event loop. Targets must be objects (pointers) |
531
- | `Reflect` (`ownKeys` / `has` / `get` / `set` / …) | ❌ | — | Feasible over the existing dynamic property access |
532
- | `Proxy` | 🚫 | — | Intercepting every property access on static Go structs; a `Proxy` limited to dynamic (`any`) objects would be feasible |
533
- | `Intl` (`NumberFormat`, `DateTimeFormat`, `Collator`, `PluralRules`, `ListFormat`, `RelativeTimeFormat`, `Segmenter`), `toLocaleString` | ❌ | — | Needs locale data (vendored `golang.org/x/text`, or hand-written `en-US` first) |
534
- | `Temporal` | ❌ | — | Feasible on Go's `time` and tzdata |
535
- | `WebSocket` / `navigator` / `CustomEvent` / `URLPattern` / `EventSource` / `reportError` | ❌ | — | Not declared |
536
- | `WebAssembly` | ❌ | — | Needs a Wasm runtime: vendoring wazero (pure Go, no cgo) would provide one (see [wasi](#nodewasi)) |
587
+ | API | Status | Probe | Notes |
588
+ | ----------------------------------------------------------------------------------------------------------------------------------------------------- | :----: | ---------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
589
+ | `assert` | ✅ | [lib-console-log.ts](conformance/lib-console-log.ts) | Transpiled to `panic` on failure |
590
+ | `process.argv` / `process.platform` | ✅ | [lib-process.ts](conformance/lib-process.ts) | Node's shapes (`[execPath, script, ...args]`, `win32`); the rest of `process` is in [node:process](#nodeprocess) |
591
+ | `process.env` | ✅ | [syntax-top-level-scope.ts](conformance/syntax-top-level-scope.ts) | Environment variable access |
592
+ | `process.exit` | ✅ | [lib-process-exit.ts](conformance/lib-process-exit.ts) | `os.Exit`, after `process.on('exit')` listeners |
593
+ | `process.cwd()` | ✅ | [lib-process-cwd.ts](conformance/lib-process-cwd.ts) | `os.Getwd()` |
594
+ | `Buffer` / `Uint8Array` / `TextEncoder` / `TextDecoder` / `atob` / `btoa` | ✅ | [lib-node-buffer-encodings.ts](conformance/lib-node-buffer-encodings.ts) | See [node:buffer](#nodebuffer) |
595
+ | `URL` / `URLSearchParams` | ✅ | [lib-node-url-class.ts](conformance/lib-node-url-class.ts) | See [node:url](#nodeurl) |
596
+ | `EventTarget` / `Event` / `AbortController` / `AbortSignal` | ✅ | [lib-node-abort.ts](conformance/lib-node-abort.ts) | See [node:events](#nodeevents) |
597
+ | `performance` / `setImmediate` / `crypto` | ✅ | [lib-node-perf-hooks.ts](conformance/lib-node-perf-hooks.ts) | See [perf_hooks](#nodeperf_hooks), [timers](#nodetimers), [crypto](#nodecrypto) |
598
+ | `TypeError` / `RangeError` / `SyntaxError` & co. | ✅ | [lib-node-assert.ts](conformance/lib-node-assert.ts) | `TnError`s carrying their `name`; `instanceof` checks the name |
599
+ | `Infinity` | ✅ | [lib-globals.ts](conformance/lib-globals.ts) | `math.Inf(1)` |
600
+ | Global `isNaN` / `isFinite` | ✅ | [lib-globals.ts](conformance/lib-globals.ts) | `math.IsNaN` / `math.IsInf` |
601
+ | `encodeURIComponent` / `decodeURIComponent` | ✅ | [lib-uri.ts](conformance/lib-uri.ts) | `TnEncodeURIComponent` / `url.PathUnescape` |
602
+ | `structuredClone` | ✅ | [lib-structured-clone.ts](conformance/lib-structured-clone.ts) | Reflection deep copy |
603
+ | `fetch` / `Headers` / `Request` / `Response` | ✅ | [lib-node-fetch.ts](conformance/lib-node-fetch.ts) | See [fetch](#fetch) |
604
+ | `ReadableStream` / `WritableStream` / `TransformStream` & co., `TextEncoderStream` / `TextDecoderStream`, `CompressionStream` / `DecompressionStream` | ✅ | [lib-node-stream-web.ts](conformance/lib-node-stream-web.ts) | See [stream/web](#nodestreamweb) |
605
+ | `Blob` / `File` / `FormData` | ✅ | [lib-node-blob.ts](conformance/lib-node-blob.ts) | See [buffer](#nodebuffer) and [fetch](#fetch) |
606
+ | `MessageChannel` / `MessagePort` / `BroadcastChannel` | ✅ | [lib-node-worker-threads.ts](conformance/lib-node-worker-threads.ts) | See [worker_threads](#nodeworker_threads) |
607
+ | `__filename` / `__dirname` | ✅ | — | The running executable (a native binary has no script file) |
608
+ | `globalThis` | ✅ | [lib-global-this.ts](conformance/lib-global-this.ts) | `globalThis.x` is the global `x`; `(globalThis as any)` is a dynamic object |
609
+ | `err.stack` | ✅ | [lib-error-stack.ts](conformance/lib-error-stack.ts) | `Name: message` and an `at fn (file.ts:line)` line per TS frame (no columns), from `runtime.Callers` and the `//line` directives |
610
+ | `AggregateError` (`errors`) | ✅ | [lib-error-stack.ts](conformance/lib-error-stack.ts) | |
611
+ | `Error.captureStackTrace` / `Error.isError` / `DOMException` | ❌ | — | Not declared |
612
+ | `Symbol.for` / `Symbol.keyFor` / `description` | ✅ | [lib-builtins-statics.ts](conformance/lib-builtins-statics.ts) | A global registry by key |
613
+ | `[Symbol.asyncIterator]()` methods; `Symbol.toPrimitive` / `hasInstance` / `toStringTag` | ❌ | — | Only `Symbol()`, `Symbol.iterator` and `Symbol.dispose` are lowered |
614
+ | `WeakRef` / `FinalizationRegistry` | ✅ | [lib-weak-refs.ts](conformance/lib-weak-refs.ts) | Go's `weak` package and `runtime.AddCleanup`; cleanup callbacks run on the event loop. Targets must be objects (pointers) |
615
+ | `Reflect` (`ownKeys` / `has` / `get` / `set` / …) | ❌ | — | Feasible over the existing dynamic property access |
616
+ | `Proxy` | 🚫 | — | Intercepting every property access on static Go structs; a `Proxy` limited to dynamic (`any`) objects would be feasible |
617
+ | `Intl` (`NumberFormat`, `DateTimeFormat`, `Collator`, `PluralRules`, `ListFormat`, `RelativeTimeFormat`, `Segmenter`), `toLocaleString` | ❌ | — | Needs locale data (vendored `golang.org/x/text`, or hand-written `en-US` first) |
618
+ | `Temporal` | ❌ | — | Feasible on Go's `time` and tzdata |
619
+ | `WebSocket` / `navigator` / `CustomEvent` / `URLPattern` / `EventSource` / `reportError` | ❌ | — | Not declared |
620
+ | `WebAssembly` | ❌ | — | Needs a Wasm runtime: vendoring wazero (pure Go, no cgo) would provide one (see [wasi](#nodewasi)) |
621
+ | `Function` as a value (`const Type = Function`), `x instanceof Function` | ✅ | [syntax-error-subclass-idiom.ts](conformance/syntax-error-subclass-idiom.ts) | An opaque sentinel; `instanceof Function` checks for a function value |
537
622
 
538
623
  ### Node builtins (`node:*`)
539
624
 
@@ -580,7 +665,7 @@ async function runs synchronously until its first `await`.
580
665
  | `node:string_decoder` | ✅ | [string_decoder](#nodestring_decoder) |
581
666
  | `node:sys` | ✅ | [constants / sys](#nodeconstants--nodesys) |
582
667
  | `node:test` | ✅ | [test](#nodetest) |
583
- | `node:test/reporters` | ❌ | [test/reporters](#nodetestreporters) |
668
+ | `node:test/reporters` | ✅ | [test/reporters](#nodetestreporters) |
584
669
  | `node:timers` / `node:timers/promises` | ✅ | [timers](#nodetimers) |
585
670
  | `node:tls` | ✅ | [tls](#nodetls) |
586
671
  | `node:trace_events` | 🚫 | [trace_events](#nodetrace_events) |
@@ -617,6 +702,7 @@ async function runs synchronously until its first `await`.
617
702
  | Typed arrays (`Int8Array`, `Uint8ClampedArray`, `Int16Array`, `Uint16Array`, `Int32Array`, `Uint32Array`, `Float32Array`, `Float64Array`): indexing, `length` / `byteLength` / `buffer`, `from` / `of`, `fill` / `set` / `subarray` / `slice` / `copyWithin`, `map` / `filter` / `reduce` / `forEach` & co., `sort` / `toSorted`, `join`, `for…of`, spread; `ArrayBuffer` (`slice`, `isView`); `DataView` (all getters / setters incl. BigInt64) | ✅ | [lib-typed-arrays.ts](conformance/lib-typed-arrays.ts) | One Go slice per element type; views on an `ArrayBuffer` share its memory. Writes convert like JS (wrapping, clamping). A view's `.buffer` is its own bytes (`byteOffset` 0). Out-of-range reads give `0`, not `undefined`. |
618
703
  | `BigInt64Array` / `BigUint64Array` | ❌ | — | `DataView` already has the BigInt64 accessors |
619
704
  | `Float16Array`, resizable `ArrayBuffer` (`resize`, `transfer`), `Uint8Array` `toBase64` / `fromBase64` / `toHex` / `fromHex` | ❌ | — | Not declared |
705
+ | `JSON.stringify(buffer)`, `buf.toJSON()` | ✅ | [lib-buffer-json.ts](conformance/lib-buffer-json.ts) | `{"type":"Buffer","data":[…]}`, keys in that order |
620
706
 
621
707
  #### `node:fs`
622
708
 
@@ -650,9 +736,11 @@ async function runs synchronously until its first `await`.
650
736
  | `process.env` reads, writes, `delete`, `in`, `Object.keys(process.env)`; `import { env } from 'node:process'` | ✅ | [lib-node-process-env.ts](conformance/lib-node-process-env.ts) | `os.Setenv` / `os.Unsetenv`; missing variables read as `""` |
651
737
  | `process.on('exit' \| 'SIGINT' \| 'SIGTERM' \| 'SIGHUP')` / `once` / `off` / `emit` | ✅ | [lib-node-process-events.ts](conformance/lib-node-process-events.ts) | `'exit'` runs after the event loop with the exit code; signals arrive on the loop |
652
738
  | `process.stdin` / `stdout` / `stderr` as streams | ✅ | [lib-node-child-process-async.ts](conformance/lib-node-child-process-async.ts) | `stdin` keeps the process alive only while flowing |
739
+ | `stdout.write(data, callback)` / `stderr.write(data, callback)` | ✅ | [lib-process-write-callback.ts](conformance/lib-process-write-callback.ts) | The callback runs after the current code once the data is written; output is flushed before exit |
653
740
  | `kill` / `emitWarning` / `getuid` / `getgid` | ✅ | — | Implemented, not probed |
654
741
  | `on('uncaughtException')` / `'uncaughtExceptionMonitor'` / `'unhandledRejection'` / `'beforeExit'` (per drain, can schedule more work); `cpuUsage` / `resourceUsage` / `availableMemory` / `loadEnvFile` | ✅ | [lib-node-process-uncaught.ts](conformance/lib-node-process-uncaught.ts), [lib-node-os-mem.ts](conformance/lib-node-os-mem.ts) | Throws in the top-level code, loop callbacks and detached async calls reach the handlers; CPU times from `/proc` (Linux) or Go's runtime metrics |
655
742
  | `stdout.columns` / `rows` / `getWindowSize()` (and `stderr`), `stdin.setRawMode` / `isRaw`, `umask` | ✅ | [lib-node-process-tty.ts](conformance/lib-node-process-tty.ts) | A per-OS helper: `TIOCGWINSZ` and termios ioctls (Linux, macOS, FreeBSD), the console API (Windows). `columns` / `rows` are `0`, not `undefined`, when not a terminal (`columns \|\| 80` still works); raw mode is libuv's and is undone at exit; `setRawMode` throws when stdin isn't a terminal. No raw mode on Linux PowerPC / MIPS, no `umask` on Windows (`0`, as in Node); no `'resize'` event |
743
+ | `emitWarning(warning, type)` | ✅ | [lib-process-emit-warning.ts](conformance/lib-process-emit-warning.ts) | `(node:PID) <type>: <message>` on stderr, and Node's `--trace-warnings` hint after the first one |
656
744
 
657
745
  #### `node:console`
658
746
 
@@ -663,16 +751,17 @@ async function runs synchronously until its first `await`.
663
751
 
664
752
  #### `node:util`
665
753
 
666
- | API | Status | Probe | Notes |
667
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :----: | ---------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
668
- | `format` / `formatWithOptions` (`%s %d %i %f %j %o %O %c %%`) | ✅ | [lib-node-util-format.ts](conformance/lib-node-util-format.ts) | Extra arguments appended; also used by `console.log` |
669
- | `inspect` (`depth`, `breakLength`, `compact`) | ✅ | [lib-node-util-inspect.ts](conformance/lib-node-util-inspect.ts) | Node's layout rules: single line up to 80 columns, number arrays grouped in columns, `Map(1) {…}`, `ClassName {…}`, `[Circular *1]` |
670
- | `isDeepStrictEqual` / `types.*` (`node:util/types`) / `deprecate` / `stripVTControlCharacters` / `styleText` | ✅ | [lib-node-util-misc.ts](conformance/lib-node-util-misc.ts) | `styleText` colours only TTYs unless `validateStream: false` |
671
- | `promisify` / `callbackify` | ✅ | [lib-node-util-promisify.ts](conformance/lib-node-util-promisify.ts) | Node functions map to their promise versions at compile time (`fs.readFile`, `setTimeout`, `exec`); other functions are wrapped |
672
- | `parseArgs` (short / long / grouped flags, `multiple`, `default`, `strict`, `allowPositionals`, `allowNegative`, `tokens`, Node's errors), `getSystemErrorName` / `getSystemErrorMessage` / `getSystemErrorMap`, `MIMEType` / `MIMEParams`, `parseEnv` (+ `process.loadEnvFile`), `aborted`, `debuglog` (`NODE_DEBUG`), `toUSVString` | ✅ | [lib-node-util-parse-args.ts](conformance/lib-node-util-parse-args.ts) | |
673
- | `inspect.custom` methods, `getCallSites` | ❌ | — | `[inspect.custom]()` can lower to a method like `[Symbol.dispose]()`; `getCallSites` can read `runtime.Callers`, which reports `.ts` lines through the `//line` directives |
674
- | `inherits` (legacy) | 🚫 | — | Rewrites prototypes; classes are static Go structs |
675
- | Node's errno numbers per OS (`err.errno`, `getSystemErrorMap`) | ✅ | [lib-node-errno.ts](conformance/lib-node-errno.ts) | libuv's table, generated into `src/node/errno_tables.ts`: the OS's errno on Unix (`ECONNREFUSED` is `-111` on Linux, `-61` on macOS) and libuv's fixed numbers on Windows (`ENOENT` is `-4058`). Messages are libuv's; the map matches Node's on Linux entry for entry |
754
+ | API | Status | Probe | Notes |
755
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :----: | ------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
756
+ | `format` / `formatWithOptions` (`%s %d %i %f %j %o %O %c %%`) | ✅ | [lib-node-util-format.ts](conformance/lib-node-util-format.ts) | Extra arguments appended; also used by `console.log` |
757
+ | `inspect` (`depth`, `breakLength`, `compact`) | ✅ | [lib-node-util-inspect.ts](conformance/lib-node-util-inspect.ts) | Node's layout rules: single line up to 80 columns, number arrays grouped in columns, `Map(1) {…}`, `ClassName {…}`, `[Circular *1]` |
758
+ | `isDeepStrictEqual` / `types.*` (`node:util/types`) / `deprecate` / `stripVTControlCharacters` / `styleText` | ✅ | [lib-node-util-misc.ts](conformance/lib-node-util-misc.ts) | `styleText` colours only TTYs unless `validateStream: false` |
759
+ | `promisify` / `callbackify` | ✅ | [lib-node-util-promisify.ts](conformance/lib-node-util-promisify.ts) | Node functions map to their promise versions at compile time (`fs.readFile`, `setTimeout`, `exec`); other functions are wrapped |
760
+ | `parseArgs` (short / long / grouped flags, `multiple`, `default`, `strict`, `allowPositionals`, `allowNegative`, `tokens`, Node's errors), `getSystemErrorName` / `getSystemErrorMessage` / `getSystemErrorMap`, `MIMEType` / `MIMEParams`, `parseEnv` (+ `process.loadEnvFile`), `aborted`, `debuglog` (`NODE_DEBUG`), `toUSVString` | ✅ | [lib-node-util-parse-args.ts](conformance/lib-node-util-parse-args.ts) | |
761
+ | `inspect.custom` methods, `getCallSites` | ❌ | — | `[inspect.custom]()` can lower to a method like `[Symbol.dispose]()`; `getCallSites` can read `runtime.Callers`, which reports `.ts` lines through the `//line` directives |
762
+ | `inherits` (legacy) | 🚫 | — | Rewrites prototypes; classes are static Go structs |
763
+ | Node's errno numbers per OS (`err.errno`, `getSystemErrorMap`) | ✅ | [lib-node-errno.ts](conformance/lib-node-errno.ts) | libuv's table, generated into `src/node/errno_tables.ts`: the OS's errno on Unix (`ECONNREFUSED` is `-111` on Linux, `-61` on macOS) and libuv's fixed numbers on Windows (`ENOENT` is `-4058`). Messages are libuv's; the map matches Node's on Linux entry for entry |
764
+ | `parseArgs` result typed from the `options` config | ✅ | [lib-util-parse-args-typed.ts](conformance/lib-util-parse-args-typed.ts) | `values.json` is a `boolean`, `values.indent` a `string` |
676
765
 
677
766
  #### `node:assert`
678
767
 
@@ -924,18 +1013,19 @@ async function runs synchronously until its first `await`.
924
1013
 
925
1014
  #### `node:test`
926
1015
 
927
- | API | Status | Probe | Notes |
928
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :----: | ------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
929
- | `test` / `it` / `describe` / `suite` (+ `.skip` / `.todo` / `.only`; `skip` / `todo` / `timeout` options); sync, async and `done`-callback tests | ✅ | [lib-node-test.ts](conformance/lib-node-test.ts) | Tests run one after another once the main module has finished, as in Node |
930
- | `before` / `after` / `beforeEach` / `afterEach` (file and suite level, `t.before` & co.) | ✅ | [lib-node-test.ts](conformance/lib-node-test.ts) | Node's order: outer `beforeEach` first, inner `afterEach` first |
931
- | `TestContext`: `t.test` subtests, `t.skip`, `t.todo`, `t.diagnostic`, `t.plan`, `t.name`, `t.fullName`, `t.signal`, `t.mock` | ✅ | [lib-node-test.ts](conformance/lib-node-test.ts) | |
932
- | Reporting: TAP (Node's default when stdout is not a terminal) / spec (on a terminal); `tests` / `suites` / `pass` / `fail` / `cancelled` / `skipped` / `todo` counters; exit code 1 on failure | ✅ | [lib-node-test-fail.ts](conformance/lib-node-test-fail.ts) | Same layout as Node, without `location` / `stack` yet (the `//line` directives make them recoverable through `runtime.Callers`); timeouts count as cancelled |
933
- | `mock.fn(original?, implementation?)`; `fn.mock.calls` / `callCount()` / `mockImplementation(Once)` / `resetCalls()` / `restore()` | ✅ | [lib-node-test.ts](conformance/lib-node-test.ts) | The mock has the original's Go function type |
934
- | `t.assert` (`node:assert`'s functions, counted by `t.plan`) and `mock.timers` (`enable({ apis, now })`, `tick`, `runAll`, `setTime`, `reset`; `setTimeout` / `setInterval` / `setImmediate` / `Date`) | ✅ | [lib-node-test-mock-timers.ts](conformance/lib-node-test-mock-timers.ts) | Mocked timers do not keep the process alive; `t.mock` timers reset after each test |
935
- | `mock.method` / `mock.getter` / `mock.setter` | ❌ | — | Object-literal methods are function fields and can be swapped; class methods need calls routed through a replaceable table |
936
- | `NODE_OPTIONS` flags: `--test-name-pattern` / `--test-skip-pattern` (repeatable, `/re/flags`), `--test-only`, `--test-reporter=tap\|spec\|dot\|junit`; Node's notice for `.only` without `--test-only` | ✅ | [lib-node-test-flags.ts](conformance/lib-node-test-flags.ts) | Read from `NODE_OPTIONS`, as Node reads them (arguments after a program never reach Node's runner either). Filtered-out tests are not reported; a matching suite runs all its tests. The TAP / spec / dot outputs match Node's; junit's failure bodies have no stack traces |
937
- | Snapshots, `run()`, `--test-reporter-destination` | ❌ | — | Snapshots need `--test-update-snapshots` files next to the program; `run()` needs extra entry points |
938
- | Coverage | ❌ | — | Would need Go's `-cover` instrumentation mapped back through the `//line` directives |
1016
+ | API | Status | Probe | Notes |
1017
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :----: | -------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1018
+ | `test` / `it` / `describe` / `suite` (+ `.skip` / `.todo` / `.only`; `skip` / `todo` / `timeout` options); sync, async and `done`-callback tests | ✅ | [lib-node-test.ts](conformance/lib-node-test.ts) | Tests run one after another once the main module has finished, as in Node |
1019
+ | `before` / `after` / `beforeEach` / `afterEach` (file and suite level, `t.before` & co.) | ✅ | [lib-node-test.ts](conformance/lib-node-test.ts) | Node's order: outer `beforeEach` first, inner `afterEach` first |
1020
+ | `TestContext`: `t.test` subtests, `t.skip`, `t.todo`, `t.diagnostic`, `t.plan`, `t.name`, `t.fullName`, `t.signal`, `t.mock` | ✅ | [lib-node-test.ts](conformance/lib-node-test.ts) | |
1021
+ | Reporting: TAP (Node's default when stdout is not a terminal) / spec (on a terminal); `tests` / `suites` / `pass` / `fail` / `cancelled` / `skipped` / `todo` counters; exit code 1 on failure | ✅ | [lib-node-test-fail.ts](conformance/lib-node-test-fail.ts) | Same layout as Node, including each failure's `location` (`file:line:col`); stack traces are the remaining gap (the `//line` directives make them recoverable through `runtime.Callers`); timeouts count as cancelled |
1022
+ | `mock.fn(original?, implementation?)`; `fn.mock.calls` / `callCount()` / `mockImplementation(Once)` / `resetCalls()` / `restore()` | ✅ | [lib-node-test.ts](conformance/lib-node-test.ts) | The mock has the original's Go function type |
1023
+ | `t.assert` (`node:assert`'s functions, counted by `t.plan`) and `mock.timers` (`enable({ apis, now })`, `tick`, `runAll`, `setTime`, `reset`; `setTimeout` / `setInterval` / `setImmediate` / `Date`) | ✅ | [lib-node-test-mock-timers.ts](conformance/lib-node-test-mock-timers.ts) | Mocked timers do not keep the process alive; `t.mock` timers reset after each test |
1024
+ | `mock.method` / `mock.getter` / `mock.setter` | ✅ | [lib-node-test-mock-members.ts](conformance/lib-node-test-mock-members.ts) | Object-literal methods and getters swap the closure field; class methods route through per-instance override slots (other instances keep theirs, inherited members included); namespace functions (`console.log`, `Math.random`, …) dispatch by name; `t.mock` restores after each test |
1025
+ | `NODE_OPTIONS` flags: `--test-name-pattern` / `--test-skip-pattern` (repeatable, `/re/flags`), `--test-only`, `--test-reporter=tap\|spec\|dot\|junit` with `--test-reporter-destination` (a file, `stdout` or `stderr`, one per reporter); Node's notice for `.only` without `--test-only` | ✅ | [lib-node-test-flags.ts](conformance/lib-node-test-flags.ts) | Read from `NODE_OPTIONS`, as Node reads them (arguments after a program never reach Node's runner either). Filtered-out tests are not reported; a matching suite runs all its tests. The TAP / spec / dot outputs match Node's; junit's failure bodies have no stack traces |
1026
+ | Snapshots: `t.assert.snapshot` / `t.assert.fileSnapshot`, `--test-update-snapshots`, `snapshot.setDefaultSnapshotSerializers` / `setResolveSnapshotPath` | ✅ | [lib-node-test-snapshots.ts](conformance/lib-node-test-snapshots.ts) | Node's `<test file>.snapshot` format (entries sorted by name, JSON values), redirectable with `setResolveSnapshotPath`; a missing file or entry names the update flag |
1027
+ | `run({ files })`: a TestsStream (`test:pass` & co. events, `compose(reporter)`, `pipe`) | ✅ | [lib-node-test-run.ts](conformance/lib-node-test-run.ts) | Files with literal paths compile in as entry points and run as child processes; top-level numbering continues across files, child output becomes `test:stdout` / `test:stderr`, coverage and summaries merge |
1028
+ | Coverage: `--experimental-test-coverage`, `--test-coverage-include` / `-exclude`, `-lines` / `-branches` / `-functions` thresholds | ✅ | [lib-node-test-coverage.ts](conformance/lib-node-test-coverage.ts) | Programs that import `node:test` count what runs over V8-style source ranges (functions, blocks, ternary arms, `&&` / `\|\|` / `??` operands, class field initializers); `node:coverage ignore` comments exclude ranges; lcov records and the tap / spec table match Node's output |
939
1029
 
940
1030
  #### `node:worker_threads`
941
1031
 
@@ -1031,10 +1121,10 @@ network; it adds about 10 MB to a binary. Rows are records: `row.name`, `row as
1031
1121
 
1032
1122
  #### `node:test/reporters`
1033
1123
 
1034
- | API | Status | Probe | Notes |
1035
- | ------------------------------------------- | :----: | ----- | -------------------------------------------------------------------------------------------------------------------------------- |
1036
- | `tap` / `spec` / `dot` / `junit` as exports | ❌ | — | The four reporters exist (`--test-reporter` in [test](#nodetest)); exporting them as stream transforms only matters with `run()` |
1037
- | `lcov` | ❌ | — | Needs coverage (see [test](#nodetest)) |
1124
+ | API | Status | Probe | Notes |
1125
+ | ------------------------------------------- | :----: | -------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
1126
+ | `tap` / `spec` / `dot` / `junit` as exports | ✅ | [lib-node-test-reporters.ts](conformance/lib-node-test-reporters.ts) | `tap` / `dot` / `junit` are generator functions over an event source (an array, an async generator, a stream such as `run()`'s); `spec` is a Transform stream for `compose()` — Node's output, byte for byte |
1127
+ | `lcov` | ✅ | [lib-node-test-reporters.ts](conformance/lib-node-test-reporters.ts) | A Transform stream (`new lcov()`, `compose(lcov)`); writes one record per `test:coverage` event (see coverage in [test](#nodetest)) |
1038
1128
 
1039
1129
  #### `node:domain`
1040
1130
 
@@ -1254,10 +1344,48 @@ Status: ✅ probed, 🚫 can't work in a TypeNative program (see [Known limitati
1254
1344
 
1255
1345
  ### npm packages
1256
1346
 
1257
- | Pattern | Status | Probe | Notes |
1258
- | ------------------------------------------------------------------------------------------------ | :----: | -------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1259
- | `import { x } from 'pkg'` | ✅ | [syntax-import-npm.ts](conformance/syntax-import-npm.ts) | Mapped to Go module imports (fixture dep in [conformance/package.json](conformance/package.json)) |
1260
- | Packages published as plain JavaScript / CommonJS (tried: `ms`, `escape-html`, `tiny-invariant`) | ❌ | — | Without TypeScript sources there are no types to compile from: untyped packages stop at the type check (TS7016), and typed ones whose code is CommonJS (`module.exports`, union-typed callbacks) don't lower. Packages that ship `.ts` sources work |
1347
+ | Pattern | Status | Probe | Notes |
1348
+ | ------------------------------------------------- | :----: | -------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1349
+ | `import { x } from 'pkg'` | ✅ | [syntax-import-npm.ts](conformance/syntax-import-npm.ts) | Mapped to Go module imports (fixture dep in [conformance/package.json](conformance/package.json)) |
1350
+ | Packages published as plain JavaScript / CommonJS | 🚫 | — | Without TypeScript sources there are no types to compile from: untyped packages stop at the type check (TS7016), and typed ones whose code is CommonJS (`module.exports`, union-typed callbacks) don't lower. Packages that ship `.ts` sources work |
1351
+
1352
+ ### Native app windows (`@webviewjs/webview`)
1353
+
1354
+ Programs open windows through the [`@webviewjs/webview`](https://www.npmjs.com/package/@webviewjs/webview)
1355
+ API, so the same source runs under Node.js (the real package) and compiled (a built-in
1356
+ implementation, no npm package needed). Build a windowed app with `--gui`. Anything not listed
1357
+ here is a type error when compiled.
1358
+
1359
+ | API | Status | Probe | Notes |
1360
+ | ----------------------------------------------------------------------------------------------------- | :----: | ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
1361
+ | `new Application()`, `run`, `exit`, `isReady`, `whenReady` | ✅ | [lib-webview-api.ts](conformance/lib-webview-api.ts) | `ApplicationOptions` aren't accepted |
1362
+ | `app.createWebContext({ dataDirectory })` | ✅ | [lib-webview-api.ts](conformance/lib-webview-api.ts) | Without one, compiled apps use the per-user cache folder |
1363
+ | `app.createBrowserWindow({ title, width, height, logical, resizable })` | ✅ | [lib-webview-api.ts](conformance/lib-webview-api.ts) | Sizes are physical pixels unless `logical`, as in the package |
1364
+ | `win.createWebview({ url, html, enableDevtools, webContext })` | ✅ | [lib-webview-api.ts](conformance/lib-webview-api.ts) | One webview per window, which opens once it has one. `enableDevtools` also enables the right-click menu |
1365
+ | `win.setTitle`, `win.close` | ✅ | [lib-webview-api.ts](conformance/lib-webview-api.ts) | |
1366
+ | `view.loadUrl`, `loadHtml`, `evaluateScript`, `reload` | ✅ | [lib-webview-api.ts](conformance/lib-webview-api.ts) | Once a browser app window is open these throw `ERR_WEBVIEW_UNSUPPORTED` |
1367
+ | Events `ready`, `window-close-requested`, `application-close-requested`, window `close` | ✅ | [app-webview-window.ts](conformance/app-webview-window.ts) | A close from the program skips `close` and `window-close-requested`, as in the package |
1368
+ | `event.preventDefault()` on `close` | 🚫 | — | The window is already gone when `close` arrives: save before it, for example on the page's `beforeunload` |
1369
+ | Menus, tray icons, notifications, IPC (`expose`, `onIpcMessage`), custom protocols, window controls | ❌ | — | Not implemented |
1370
+
1371
+ How a window is hosted:
1372
+
1373
+ | Platform | Window | Closing it is detected by | Verified |
1374
+ | ---------------------------------------- | -------------------------------------- | ------------------------------------- | ---------------------------------------------------------- |
1375
+ | Windows | Embedded WebView2, pure Go, no cgo | The window's message loop ending | Run end to end |
1376
+ | Windows without the WebView2 runtime | Edge or Chrome in app mode | A job object emptying | Run end to end (`TYPENATIVE_WEBVIEW=browser` forces this) |
1377
+ | macOS, Linux | Chrome, Edge or Chromium in app mode | The DevTools pipe reporting the page closed | Builds in CI; **never run on these systems**, only the pipe's messages were checked on Windows |
1378
+
1379
+ With no browser to open, opening the window throws `ERR_WEBVIEW_NO_BROWSER`. Run
1380
+ [app-webview-window.ts](conformance/app-webview-window.ts) with `TN_WEBVIEW_SMOKE=1` to open a real
1381
+ window: the suite skips it otherwise, since CI has no display.
1382
+
1383
+ Under Node.js on Windows the package has a pitfall that compiled programs don't: while the window
1384
+ is idle, its event pump can hold the JS thread until a window message arrives (seen on 0.6.0 and
1385
+ 1.0.0-rc.4, and `controlFlow` doesn't change it), which starves timers and an HTTP server in the
1386
+ same process. [desktop-notes](examples/desktop-notes/) gives the window its own process there. Its
1387
+ default profile folder is beside `node.exe`, which is read-only under Program Files, so pass a
1388
+ `dataDirectory`.
1261
1389
 
1262
1390
  ## Known limitations (🚫)
1263
1391