typenative 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/conformance.md CHANGED
@@ -19,8 +19,8 @@ self-hosted binary). Each ❌ row is a known gap with no passing probe yet.
19
19
  | Nullable types (`T \| null`, `T \| undefined`) | ✅ | [syntax-null-undefined.ts](conformance/syntax-null-undefined.ts) | Transpiled to Go pointer types |
20
20
  | `bigint` | ✅ | [syntax-bigint.ts](conformance/syntax-bigint.ts) | `2n` literals → `*big.Int`; `**` → `.Exp`, comparisons via `.Cmp` |
21
21
  | `symbol` | ✅ | [syntax-symbols.ts](conformance/syntax-symbols.ts) | `Symbol()` → unique `*TnSymbol` pointers, usable as record keys |
22
- | `object` type | ❌ | — | No probe yet |
23
- | `void` / `never` | ❌ | — | No probe yet |
22
+ | `object` type | ✅ | [syntax-object-type.ts](conformance/syntax-object-type.ts) | `object` → `interface{}` |
23
+ | `void` / `never` | ✅ | [syntax-void-never.ts](conformance/syntax-void-never.ts) | No return value in Go |
24
24
 
25
25
  ## Variables & destructuring
26
26
 
@@ -40,9 +40,9 @@ self-hosted binary). Each ❌ row is a known gap with no passing probe yet.
40
40
  | Tuples | ✅ | [syntax-tuples.ts](conformance/syntax-tuples.ts) | `[string, number]` fixed-length arrays |
41
41
  | Top-level / module-scope variables | ✅ | [syntax-top-level-scope.ts](conformance/syntax-top-level-scope.ts) | Functions see main-file top-level variables |
42
42
  | Numeric separators | ✅ | [syntax-numeric-separators.ts](conformance/syntax-numeric-separators.ts) | `1_000_000` |
43
- | Hex / octal / binary literals | ❌ | — | `0xFF`, `0o17`, `0b1010`; no probe yet |
44
- | `var` declarations (hoisting) | ❌ | — | No probe yet |
45
- | `using` / `await using` declarations | ❌ | — | Explicit resource management; no probe yet |
43
+ | Hex / octal / binary literals | ✅ | [syntax-numeric-literals.ts](conformance/syntax-numeric-literals.ts) | `0xFF`, `0o17`, `0b1010`, `1e3` |
44
+ | `var` declarations (hoisting) | ✅ | [syntax-var.ts](conformance/syntax-var.ts) | Function- and module-level `var` |
45
+ | `using` / `await using` declarations | ✅ | [syntax-using.ts](conformance/syntax-using.ts) | Disposed in reverse order when the block ends (`defer`); `[Symbol.dispose]` methods |
46
46
 
47
47
  ## Operators
48
48
 
@@ -65,10 +65,10 @@ self-hosted binary). Each ❌ row is a known gap with no passing probe yet.
65
65
  | `instanceof` | ✅ | [syntax-instanceof.ts](conformance/syntax-instanceof.ts) | Class instance checks |
66
66
  | JS truthiness | ✅ | [syntax-optional-params.ts](conformance/syntax-optional-params.ts) | `if (str)`, `!count`, `a \|\| fallback` on any type |
67
67
  | Loose equality (`==`) | ✅ | [semantics-loose-equality.ts](conformance/semantics-loose-equality.ts) | `bool`/`number`/`string` mixtures coerce like JS (`TnNumber`/`TnParseFloat`) |
68
- | Optional call (`fn?.()`) | ❌ | — | No probe yet |
69
- | Comma operator | ❌ | — | No probe yet |
70
- | `void` operator | ❌ | — | No probe yet |
71
- | `new.target` | ❌ | — | No probe yet |
68
+ | Optional call (`fn?.()`) | ✅ | [syntax-optional-call.ts](conformance/syntax-optional-call.ts) | Nil check on the function value; result is nullable |
69
+ | Comma operator | ✅ | [syntax-comma-operator.ts](conformance/syntax-comma-operator.ts) | In `for` headers (`i = 0, j = 10` / `i++, j--`) |
70
+ | `void` operator | ✅ | [syntax-void-operator.ts](conformance/syntax-void-operator.ts) | Evaluates, then `nil` |
71
+ | `new.target` | ✅ | [syntax-new-target.ts](conformance/syntax-new-target.ts) | Constructors pass the target class name through `super()` chains |
72
72
 
73
73
  ## Control flow
74
74
 
@@ -82,7 +82,7 @@ self-hosted binary). Each ❌ row is a known gap with no passing probe yet.
82
82
  | `break` | ✅ | [syntax-if-switch.ts](conformance/syntax-if-switch.ts), [syntax-do-while.ts](conformance/syntax-do-while.ts) | In switch cases and loops |
83
83
  | `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 |
84
84
  | `for...in` loops | ✅ | [syntax-for-in.ts](conformance/syntax-for-in.ts) | Key range over records/maps |
85
- | `for await...of` | ❌ | — | Requires async iteration (see [Async & timing](#async--timing)) |
85
+ | `for await...of` | ✅ | [syntax-for-await.ts](conformance/syntax-for-await.ts) | Ranges over the async generator's channel |
86
86
  | `while` loops | ✅ | [syntax-loops.ts](conformance/syntax-loops.ts) | Transpiled to Go's `for` loops; assignment in condition |
87
87
  | `do...while` loops | ✅ | [syntax-do-while.ts](conformance/syntax-do-while.ts) | Implemented with conditional break |
88
88
  | Labeled loops | ✅ | [syntax-labeled-loops.ts](conformance/syntax-labeled-loops.ts) | `LabeledStatement` → Go labels; labeled `continue`/`break` |
@@ -108,13 +108,14 @@ self-hosted binary). Each ❌ row is a known gap with no passing probe yet.
108
108
  | Destructured parameters | ✅ | [syntax-destructuring-params.ts](conformance/syntax-destructuring-params.ts) | `function f({ a, b }: T)`, `([x, y]: number[])` |
109
109
  | Contextual object-literal arguments | ✅ | [syntax-contextual-arguments.ts](conformance/syntax-contextual-arguments.ts) | Struct type inferred from parameter / return type |
110
110
  | Recursion | ✅ | [syntax-recursion.ts](conformance/syntax-recursion.ts) | Direct self-recursion |
111
+ | Recursive arrow functions | ✅ | [syntax-recursive-arrow.ts](conformance/syntax-recursive-arrow.ts) | `const f = () => … f() …` → declared, then assigned |
111
112
  | 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 |
112
- | Async generators (`async function*`) | ❌ | — | Depends on generators and async |
113
+ | Async generators (`async function*`) | ✅ | [syntax-async-generators.ts](conformance/syntax-async-generators.ts) | Goroutine + channel, consumed with `for await` |
113
114
  | Custom iterators (`Symbol.iterator`) | ✅ | [syntax-custom-iterators.ts](conformance/syntax-custom-iterators.ts) | `*[Symbol.iterator]()` → a `Symbol_iterator()` channel method |
114
115
  | `as const` assertions | ✅ | [syntax-as-const.ts](conformance/syntax-as-const.ts) | Erased during transpilation |
115
- | Function overloads | ❌ | — | No probe yet |
116
- | `this` parameter (`function f(this: T)`) | ❌ | — | No probe yet |
117
- | `arguments` object | ❌ | — | No probe yet |
116
+ | Function overloads | ✅ | [syntax-function-overloads.ts](conformance/syntax-function-overloads.ts) | Signatures are erased; the implementation is emitted |
117
+ | `this` parameter (`function f(this: T)`) | ✅ | [syntax-this-parameter.ts](conformance/syntax-this-parameter.ts) | Erased |
118
+ | `arguments` object | ✅ | [syntax-arguments.ts](conformance/syntax-arguments.ts) | Functions reading it take extra arguments variadically (`[]interface{}`) |
118
119
 
119
120
  ## Classes & interfaces
120
121
 
@@ -130,14 +131,14 @@ self-hosted binary). Each ❌ row is a known gap with no passing probe yet.
130
131
  | Getters (object literals) | ✅ | [syntax-object-getters.ts](conformance/syntax-object-getters.ts) | Getter closures stored as function fields; reads invoke them |
131
132
  | Object-literal methods | ✅ | [syntax-object-methods.ts](conformance/syntax-object-methods.ts) | Method closures stored as function fields capturing the instance (`this` → the object) |
132
133
  | Private `#` fields | ✅ | [syntax-class-private-fields.ts](conformance/syntax-class-private-fields.ts) | `#secret` → a plain (name-mangled) struct field |
133
- | Access modifiers (`private` / `protected` / `public` on members) | ❌ | — | Constructor parameter properties ✅; member modifiers unprobed |
134
+ | Access modifiers (`private` / `protected` / `public` on members) | ✅ | [syntax-access-modifiers.ts](conformance/syntax-access-modifiers.ts) | `private` / `protected` / `public` are erased |
134
135
  | Abstract classes | ✅ | [syntax-class-abstract.ts](conformance/syntax-class-abstract.ts) | Abstract members skipped; concrete methods copied onto subclasses |
135
- | Static initialization blocks (`static {}`) | ❌ | — | No probe yet |
136
- | Class expressions (`const C = class {}`) | ❌ | — | No probe yet |
136
+ | Static initialization blocks (`static {}`) | ✅ | [syntax-static-blocks.ts](conformance/syntax-static-blocks.ts) | Go `func init()` |
137
+ | Class expressions (`const C = class {}`) | ✅ | [syntax-class-expressions.ts](conformance/syntax-class-expressions.ts) | `const C = class {…}` becomes a class named after the variable |
137
138
  | Interfaces | ✅ | [syntax-class-implements.ts](conformance/syntax-class-implements.ts) | Transpiled to Go interfaces |
138
139
  | Optional properties | ✅ | [syntax-optional-chaining.ts](conformance/syntax-optional-chaining.ts) | `prop?: Type` in interfaces/types |
139
140
  | Type-aware method dispatch | ✅ | [semantics-method-dispatch.ts](conformance/semantics-method-dispatch.ts) | Class `.push()` / `.length` not confused with array builtins |
140
- | Index signatures (`[key: string]: T`) | ❌ | — | No probe yet (records/dicts → Go maps ✅) |
141
+ | 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) |
141
142
 
142
143
  ## Generics
143
144
 
@@ -145,10 +146,10 @@ self-hosted binary). Each ❌ row is a known gap with no passing probe yet.
145
146
  | ------------------------------------------------------------- | :----: | ---------------------------------------------------------------------- | ---------------------------------- |
146
147
  | Generic functions | ✅ | [syntax-generic-functions.ts](conformance/syntax-generic-functions.ts) | Type parameters → Go generics; call sites infer from arguments |
147
148
  | Generic classes | ✅ | [syntax-generic-classes.ts](conformance/syntax-generic-classes.ts) | Type parameters via Go generics |
148
- | Generic constraints (`<T extends U>`) | ❌ | — | No probe yet |
149
- | Default type parameters (`<T = D>`) | ❌ | — | No probe yet |
150
- | Generic interfaces / type aliases | ❌ | — | No probe yet |
151
- | `const` type parameters / variance annotations (`in` / `out`) | ❌ | — | No probe yet |
149
+ | 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 |
150
+ | Default type parameters (`<T = D>`) | ✅ | [syntax-generic-defaults.ts](conformance/syntax-generic-defaults.ts) | Defaults are erased; Go infers from arguments |
151
+ | Generic interfaces / type aliases | ✅ | [syntax-generic-interfaces.ts](conformance/syntax-generic-interfaces.ts) | Go generic structs; literals instantiate them (`Box[float64]{…}`) |
152
+ | `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 |
152
153
 
153
154
  ## Enums
154
155
 
@@ -156,8 +157,8 @@ self-hosted binary). Each ❌ row is a known gap with no passing probe yet.
156
157
  | ------------------------------------- | :----: | ------------------------------------------------------------ | -------------------------------------------- |
157
158
  | Numeric enums | ✅ | [syntax-enum-numeric.ts](conformance/syntax-enum-numeric.ts) | Numeric members are `float64` constants; string enums keep a named type |
158
159
  | String enums | ✅ | [syntax-enum-string.ts](conformance/syntax-enum-string.ts) | `enum` declarations and member access |
159
- | `const enum` | ❌ | — | No probe yet |
160
- | Computed / heterogeneous enum members | ❌ | — | `enum E { A = f(), B = 's' }`; no probe yet |
160
+ | `const enum` | ✅ | [syntax-const-enum.ts](conformance/syntax-const-enum.ts) | Compiled like a regular enum |
161
+ | Computed / heterogeneous enum members | ✅ | [syntax-enum-computed.ts](conformance/syntax-enum-computed.ts) | Computed members assigned in source order; mixed enums keep each member's type |
161
162
 
162
163
  ## Type-system features
163
164
 
@@ -168,32 +169,34 @@ self-hosted binary). Each ❌ row is a known gap with no passing probe yet.
168
169
  | Type guards (`is`) | ✅ | [syntax-type-guards.ts](conformance/syntax-type-guards.ts) | `p is T` → Go `bool`; `in` checks struct fields at runtime |
169
170
  | `as` assertions | ✅ | [syntax-type-aliases.ts](conformance/syntax-type-aliases.ts) | `x as T`, incl. angle-bracket syntax |
170
171
  | Self-host contextual typing | ✅ | [syntax-selfhost-context.ts](conformance/syntax-selfhost-context.ts) | Object/array literals typed from context, `Record` literals, `in`, `any` params |
171
- | Decorators (`@`) | ❌ | — | No probe yet |
172
- | Namespaces / `module` blocks | ❌ | — | No probe yet |
173
- | `override` modifier | ❌ | — | No probe yet |
174
- | `readonly` modifier (properties, `readonly T[]`) | ❌ | — | No probe yet |
175
- | `satisfies` operator | ❌ | — | No probe yet |
176
- | `keyof` / mapped / conditional / `infer` types | ❌ | — | No probe yet |
177
- | `import type` / `export type` | ❌ | — | No probe yet |
178
- | Intersection types (`A & B`) | ❌ | — | No probe yet |
179
- | Literal types (`'a' \| 'b'`) | ❌ | — | No probe yet |
180
- | Tuple optional / rest / labeled elements | ❌ | — | `[number, ...string[]]`, `[name: string]` |
181
- | Indexed access types (`T['k']`) | ❌ | — | No probe yet |
182
- | Type-level `typeof` (`typeof obj`) | ❌ | — | Runtime `typeof` ✅ (see Operators) |
183
- | Template literal types | ❌ | — | `` type S = `${A}-${B}` `` |
184
- | Utility types (`Partial`, `Pick`, `Omit`, …) | ❌ | — | `Record<K, V>` ✅ (see [Variables & destructuring](#variables--destructuring)) |
185
- | Assertion functions (`asserts x is T`) | ❌ | — | No probe yet |
186
- | Callable / construct signatures (`type F = { (): void }`) | ❌ | — | No probe yet |
187
- | JSX / `.tsx` syntax | ❌ | — | No probe yet |
188
- | Ambient declarations (`declare`, `.d.ts`, `x!: T`) | ❌ | — | No probe yet |
189
- | `export =` / `import x = require()` | ❌ | — | No probe yet |
172
+ | Decorators (`@`) | ✅ | [syntax-decorators.ts](conformance/syntax-decorators.ts) | Standard method & class decorators, applied in source order; `this` is the receiver |
173
+ | Namespaces / `module` blocks | ✅ | [syntax-namespaces.ts](conformance/syntax-namespaces.ts) | Flattened to prefixed declarations (`N.f` → `N_f`), nested and in types |
174
+ | `override` modifier | ✅ | [syntax-override.ts](conformance/syntax-override.ts) | Erased |
175
+ | `readonly` modifier (properties, `readonly T[]`) | ✅ | [syntax-readonly.ts](conformance/syntax-readonly.ts) | Erased (`readonly T[]` → `[]T`) |
176
+ | `satisfies` operator | ✅ | [syntax-satisfies.ts](conformance/syntax-satisfies.ts) | Checked by tsc, erased; the type guides literals |
177
+ | `keyof` / mapped types | ✅ | [syntax-keyof-mapped-types.ts](conformance/syntax-keyof-mapped-types.ts) | `keyof` → `string`; mapped types → structs (literal keys) or maps |
178
+ | Conditional types | ✅ | [syntax-conditional-types.ts](conformance/syntax-conditional-types.ts) | Resolved to their branch's Go type |
179
+ | `infer` types | ✅ | [syntax-infer-types.ts](conformance/syntax-infer-types.ts) | Resolved to their branch's Go type |
180
+ | `import type` / `export type` | ✅ | [syntax-import-type.ts](conformance/syntax-import-type.ts) | Type-only imports are erased |
181
+ | Intersection types (`A & B`) | ✅ | [syntax-intersection-types.ts](conformance/syntax-intersection-types.ts) | Object types merge into one struct |
182
+ | Literal types (`'a' \| 'b'`) | ✅ | [syntax-literal-types.ts](conformance/syntax-literal-types.ts) | Erased; string/number/boolean literals map to their base Go types |
183
+ | Tuple optional / rest / labeled elements | ✅ | [syntax-tuple-elements.ts](conformance/syntax-tuple-elements.ts) | Tuples are slices |
184
+ | Indexed access types (`T['k']`) | ✅ | [syntax-indexed-access-types.ts](conformance/syntax-indexed-access-types.ts) | `T['k']` resolves to the member type |
185
+ | Type-level `typeof` (`typeof obj`) | ✅ | [syntax-type-typeof.ts](conformance/syntax-type-typeof.ts) | The variable's Go type |
186
+ | Template literal types | ✅ | [syntax-template-literal-types.ts](conformance/syntax-template-literal-types.ts) | Template literal types → `string` |
187
+ | Utility types (`Partial`, `Pick`, `Omit`, …) | ✅ | [syntax-utility-types.ts](conformance/syntax-utility-types.ts) | `Partial` / `Required` / `Readonly` / `Pick` / `Omit` / `NonNullable` → the base type |
188
+ | Assertion functions (`asserts x is T`) | ✅ | [syntax-assertion-functions.ts](conformance/syntax-assertion-functions.ts) | No return value |
189
+ | 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 |
190
+ | JSX / `.tsx` syntax | ✅ | [syntax-jsx.tsx](conformance/syntax-jsx.tsx) | Renders to HTML strings (text escaped); components are calls with props |
191
+ | 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 |
192
+ | `export =` / `import x = require()` | ✅ | [syntax-export-equals.ts](conformance/syntax-export-equals.ts) | `import x = require()` is a namespace import |
190
193
 
191
194
  ## Modules & imports
192
195
 
193
196
  | Feature | Status | Probe | Notes |
194
197
  | -------------------------------------------------- | :----: | ---------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
195
198
  | Named imports | ✅ | [syntax-import-go.ts](conformance/syntax-import-go.ts) | `import { x } from './file'` |
196
- | Import renaming (`import { x as y }`) | ❌ | — | No probe yet |
199
+ | Import renaming (`import { x as y }`) | ✅ | [syntax-import-renaming.ts](conformance/syntax-import-renaming.ts) | Local file imports |
197
200
  | 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` |
198
201
  | Default imports | ✅ | [syntax-import-go.ts](conformance/syntax-import-go.ts) | `import x from 'pkg'` — namespace stripped in output |
199
202
  | Namespace imports | ✅ | [syntax-import-go.ts](conformance/syntax-import-go.ts) | `import * as x from 'pkg'` |
@@ -202,9 +205,9 @@ self-hosted binary). Each ❌ row is a known gap with no passing probe yet.
202
205
  | Node.js built-in imports | ✅ | [lib-node-path.ts](conformance/lib-node-path.ts) | `import { join } from 'node:path'` mapped to Go stdlib (see [Standard library](#standard-library)) |
203
206
  | Go package imports | ✅ | [syntax-import-go.ts](conformance/syntax-import-go.ts) | `import { x } from 'go:pkg'` |
204
207
  | npm package imports | ✅ | [syntax-import-npm.ts](conformance/syntax-import-npm.ts) | `import { x } from 'pkg'` mapped to Go module imports |
205
- | Re-exports (`export { x } from`, `export *`) | ❌ | — | No probe yet |
206
- | Dynamic `import()` | ❌ | — | No probe yet |
207
- | Side-effect imports (`import './mod'`) | ❌ | — | No probe yet |
208
+ | Re-exports (`export { x } from`, `export *`) | ✅ | [syntax-re-exports.ts](conformance/syntax-re-exports.ts) | Re-exported files are included (one Go package) |
209
+ | Dynamic `import()` | ✅ | [syntax-dynamic-import.ts](conformance/syntax-dynamic-import.ts) | `const m = await import('./x')` is a namespace import |
210
+ | 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()` |
208
211
  | `import.meta.url` | ✅ | [syntax-import-meta.ts](conformance/syntax-import-meta.ts) | The `file://` URL of the running program (`os.Executable` → `pathToFileURL`) |
209
212
 
210
213
  ## Async & timing
@@ -214,10 +217,12 @@ self-hosted binary). Each ❌ row is a known gap with no passing probe yet.
214
217
  | `async` / `await` | ✅ | [syntax-async-await.ts](conformance/syntax-async-await.ts) | Async functions send returns over a channel; `await` receives; pending work drains before exit |
215
218
  | `Promise` constructor / `.then` | ✅ | [syntax-promise-then.ts](conformance/syntax-promise-then.ts) | `new Promise` executor runs in a goroutine; `.then` consumes the channel on a wait group |
216
219
  | `Promise.all` | ✅ | [syntax-promise-all.ts](conformance/syntax-promise-all.ts) | `TnPromiseAll` drains every promise channel into a slice |
217
- | `Promise.resolve` / `reject` / `.catch` / `.finally` | ❌ | — | No probe yet |
218
- | `Promise.race` / `allSettled` / `any` | ❌ | — | No probe yet |
219
- | `setInterval` / `clearInterval` / `clearTimeout` | ❌ | — | No probe yet |
220
- | `queueMicrotask` | ❌ | — | No probe yet |
220
+ | `Promise.resolve` | ✅ | [lib-promise-resolve.ts](conformance/lib-promise-resolve.ts) | Buffered channel holding the value |
221
+ | `Promise.reject` / `.catch` / `.finally` | ✅ | [lib-promise-catch.ts](conformance/lib-promise-catch.ts) | Rejected promises are closed channels with a reason; `await` rethrows |
222
+ | `Promise.race` / `allSettled` / `any` | ✅ | [lib-promise-combinators.ts](conformance/lib-promise-combinators.ts) | Goroutine per promise; first settled / all settled / first fulfilled |
223
+ | `clearTimeout` | ✅ | [lib-timers.ts](conformance/lib-timers.ts) | `TnClearTimeout` stops the timer |
224
+ | `setInterval` / `clearInterval` | ✅ | [lib-set-interval.ts](conformance/lib-set-interval.ts) | `time.Ticker`; the process lives until cleared |
225
+ | `queueMicrotask` | ✅ | [lib-queue-microtask.ts](conformance/lib-queue-microtask.ts) | Runs after the current synchronous code (end of main or a timer callback) |
221
226
  | `setTimeout` | ✅ | [lib-set-timeout.ts](conformance/lib-set-timeout.ts) | `time.AfterFunc` registered on a wait group the process waits on |
222
227
 
223
228
  ## Semantics (JS behaviour preserved)
@@ -237,6 +242,7 @@ self-hosted binary). Each ❌ row is a known gap with no passing probe yet.
237
242
  | String-number concatenation order | ✅ | [semantics-string-number-concat.ts](conformance/semantics-string-number-concat.ts) | `'a' + 1 + 2` vs `1 + 2 + 'a'` |
238
243
  | Array truthiness | ✅ | [semantics-array-truthy.ts](conformance/semantics-array-truthy.ts) | Empty array is truthy |
239
244
  | Loop closures capture per-iteration `let` | ✅ | [semantics-loop-closures.ts](conformance/semantics-loop-closures.ts) | |
245
+ | Functions stored in Records | ✅ | [semantics-record-functions.ts](conformance/semantics-record-functions.ts) | `rec.fn()` → `rec.Get("fn")()`, also for names like `get` / `sort` |
240
246
 
241
247
  ## Standard library
242
248
 
@@ -249,8 +255,8 @@ Every standard-library API TypeNative ports, split by module. Per
249
255
  | API | Status | Probe | Notes |
250
256
  | ---------------------------------- | :----: | ------------------------------------------------------ | ------------------------------------------------------ |
251
257
  | `console.log` | ✅ | [lib-console-log.ts](conformance/lib-console-log.ts) | Mapped to `fmt.Println` |
252
- | `console.error` | ❌ | — | Mapped to `fmt.Fprintln(os.Stderr, ...)`; no probe yet |
253
- | `console.warn` | ❌ | — | Mapped to stderr like `console.error`; no probe yet |
258
+ | `console.error` | ✅ | [lib-console-error.ts](conformance/lib-console-error.ts) | `fmt.Fprintln(os.Stderr, ...)` |
259
+ | `console.warn` | ✅ | [lib-console-error.ts](conformance/lib-console-error.ts) | Mapped to stderr like `console.error` |
254
260
  | `console.time` / `console.timeEnd` | ✅ | [lib-console-time.ts](conformance/lib-console-time.ts) | Via `time.Now` / `time.Since` |
255
261
 
256
262
  ### `Math`
@@ -262,11 +268,11 @@ Every standard-library API TypeNative ports, split by module. Per
262
268
  | `Math.min` / `Math.max` | ✅ | [lib-math-min-max.ts](conformance/lib-math-min-max.ts) | Go builtins `min` / `max` |
263
269
  | `Math.max(...arr)` / spread & variadic | ✅ | [lib-math-min-max.ts](conformance/lib-math-min-max.ts) | Spread and any number of arguments via `slices.Max` / `max` |
264
270
  | `Math.random` | ✅ | [lib-math-random.ts](conformance/lib-math-random.ts) | Mapped to `rand.Float64()` |
265
- | `Math.log` / `log2` / `log10` | ❌ | — | Mapped to `math.Log` / `math.Log2` / `math.Log10`; no probe yet |
266
- | `Math.sin` / `cos` / `tan` | ❌ | — | Mapped to `math.Sin` / `math.Cos` / `math.Tan`; no probe yet |
267
- | `Math.trunc` / `sign` | ❌ | — | Mapped to `math.Trunc` / inline sign check; no probe yet |
268
- | Constants (`Math.PI`, `Math.E`, …) | ❌ | — | No probe yet |
269
- | `Math.asin` / `acos` / `atan` / `atan2` / `hypot` / `cbrt` / `exp` | ❌ | — | No probe yet |
271
+ | `Math.log` / `log2` / `log10` | ✅ | [lib-math-functions.ts](conformance/lib-math-functions.ts) | `math.Log` / `math.Log2` / `math.Log10` |
272
+ | `Math.sin` / `cos` / `tan` | ✅ | [lib-math-functions.ts](conformance/lib-math-functions.ts) | `math.Sin` / `math.Cos` / `math.Tan` |
273
+ | `Math.trunc` / `sign` | ✅ | [lib-math-functions.ts](conformance/lib-math-functions.ts) | `math.Trunc` / inline sign check |
274
+ | Constants (`Math.PI`, `Math.E`, …) | ✅ | [lib-math-constants.ts](conformance/lib-math-constants.ts) | `math.Pi`, `math.E`, `math.Sqrt2`, … |
275
+ | `Math.asin` / `acos` / `atan` / `atan2` / `hypot` / `cbrt` / `exp` | ✅ | [lib-math-more.ts](conformance/lib-math-more.ts) | Corresponding `math` functions |
270
276
 
271
277
  ### `JSON`
272
278
 
@@ -281,9 +287,9 @@ Every standard-library API TypeNative ports, split by module. Per
281
287
  | ---------------------------------------------------------- | :----: | ---------------------------------------------------------- | ------------------------------------------------------------------- |
282
288
  | `Object.keys` / `values` / `entries` | ✅ | [lib-object-helpers.ts](conformance/lib-object-helpers.ts) | Map key/value iteration helpers; typed results for maps and records |
283
289
  | `Object.assign` | ✅ | [lib-object-assign.ts](conformance/lib-object-assign.ts) | Sources (structs, maps, dynamic objects) copied into an ordered map |
284
- | `Object.freeze` / `seal` / `isFrozen` | ❌ | — | No probe yet |
285
- | `Object.fromEntries` | ❌ | — | No probe yet |
286
- | `Object.hasOwn` / `defineProperty` / `getOwnPropertyNames` | ❌ | — | No probe yet |
290
+ | `Object.freeze` / `seal` / `isFrozen` | ✅ | [lib-object-freeze.ts](conformance/lib-object-freeze.ts) | Integrity level tracked by identity; writes rejected by `Readonly<T>` types |
291
+ | `Object.fromEntries` | ✅ | [lib-object-from-entries.ts](conformance/lib-object-from-entries.ts) | `TnFromEntries` → dynamic object |
292
+ | `Object.hasOwn` / `defineProperty` / `getOwnPropertyNames` | ✅ | [lib-object-own.ts](conformance/lib-object-own.ts) | Maps, dynamic objects and typed objects (literal keys); `{ value }` descriptors |
287
293
 
288
294
  ### `String`
289
295
 
@@ -305,8 +311,8 @@ Every standard-library API TypeNative ports, split by module. Per
305
311
  | `match` / `matchAll` / `search` | ✅ | [syntax-top-level-scope.ts](conformance/syntax-top-level-scope.ts) | Via `regexp` package (`String.match` with groups) |
306
312
  | `at` (negative indices) | ✅ | [lib-array-at.ts](conformance/lib-array-at.ts) | Supports negative indices |
307
313
  | Unicode length / iteration | ✅ | [lib-string-unicode.ts](conformance/lib-string-unicode.ts) | `.length` counts runes; `[...str]` spreads runes |
308
- | `String.raw` | ❌ | — | No probe yet |
309
- | `normalize` | ❌ | — | Unicode normalization; no probe yet |
314
+ | `String.raw` | ✅ | [lib-string-raw.ts](conformance/lib-string-raw.ts) | Raw template text with values interpolated |
315
+ | `normalize` | ✅ | [lib-string-normalize.ts](conformance/lib-string-normalize.ts) | `golang.org/x/text/unicode/norm`, copied from GOROOT's vendor tree (offline) |
310
316
 
311
317
  ### `Array`
312
318
 
@@ -332,10 +338,11 @@ Every standard-library API TypeNative ports, split by module. Per
332
338
  | `entries` / `keys` / `values` | ✅ | [lib-array-entries.ts](conformance/lib-array-entries.ts) | `[index, value]` pairs destructured in `for...of` |
333
339
  | `length` truncation (`arr.length = 0`) | ✅ | [syntax-top-level-scope.ts](conformance/syntax-top-level-scope.ts) | Clear via length assignment |
334
340
  | `filter(Boolean)` | ✅ | [syntax-top-level-scope.ts](conformance/syntax-top-level-scope.ts) | Constructor as predicate |
335
- | `concat` | ❌ | — | No probe yet |
336
- | `reduceRight` | ❌ | — | No probe yet |
337
- | `copyWithin` | ❌ | — | No probe yet |
338
- | Change-preserving copies (`toSorted` / `toReversed` / `toSpliced` / `with`) | ❌ | — | ES2023; no probe yet |
341
+ | `concat` | ✅ | [lib-array-concat.ts](conformance/lib-array-concat.ts) | Arrays flattened one level, values appended |
342
+ | `reduceRight` | ✅ | [lib-array-reduce-right.ts](conformance/lib-array-reduce-right.ts) | `reduce` over a reversed copy |
343
+ | `copyWithin` | ✅ | [lib-array-copy-within.ts](conformance/lib-array-copy-within.ts) | Go `copy` (overlap-safe) |
344
+ | Change-preserving copies (`toSorted` / `toReversed` / `with`) | ✅ | [lib-array-copies.ts](conformance/lib-array-copies.ts) | Clone, then sort / reverse / set |
345
+ | `toSpliced` | ✅ | [lib-array-to-spliced.ts](conformance/lib-array-to-spliced.ts) | `slices.Concat` of the kept parts |
339
346
 
340
347
  ### `Map` / `Set`
341
348
 
@@ -345,9 +352,9 @@ Every standard-library API TypeNative ports, split by module. Per
345
352
  | `Map` iteration (`for...of`, destructuring) | ✅ | [lib-map-iteration.ts](conformance/lib-map-iteration.ts) | Key/value iteration, `Object.entries()` unwrapping |
346
353
  | `Set` (`add` / `has` / `delete` / `size`) | ✅ | [lib-set.ts](conformance/lib-set.ts) | `Set<T>` → Go `map[T]struct{}`; constructor with values |
347
354
  | `Set` iteration / spread | ✅ | [syntax-top-level-scope.ts](conformance/syntax-top-level-scope.ts) | `for...of`, `[...set]` |
348
- | `Map.clear` / `Set.clear` | ❌ | — | No probe yet |
349
- | `WeakMap` / `WeakSet` | ❌ | — | No probe yet |
350
- | Set operations (`union` / `intersection` / `difference`) | ❌ | — | ES2025; no probe yet |
355
+ | `Map.clear` / `Set.clear` | ✅ | [lib-map-clear.ts](conformance/lib-map-clear.ts) | `TnMap.Clear()` |
356
+ | `WeakMap` / `WeakSet` | ✅ | [lib-weak-collections.ts](conformance/lib-weak-collections.ts) | Same as `Map` / `Set` (weakness is not observable) |
357
+ | Set operations (`union` / `intersection` / `difference`) | ✅ | [lib-set-operations.ts](conformance/lib-set-operations.ts) | Plus `symmetricDifference` / `isSubsetOf` / `isSupersetOf` / `isDisjointFrom` |
351
358
 
352
359
  ### `Number`
353
360
 
@@ -357,8 +364,8 @@ Every standard-library API TypeNative ports, split by module. Per
357
364
  | `toFixed` | ✅ | [lib-number-format.ts](conformance/lib-number-format.ts) | `n.toFixed(2)` via `strconv.FormatFloat` |
358
365
  | `parseInt` / `parseFloat` / `Number()` | ✅ | [lib-number-parse.ts](conformance/lib-number-parse.ts) | Mapped to Go's `strconv` package |
359
366
  | `Number.isInteger` / `isNaN` / `MAX_SAFE_INTEGER` | ✅ | [lib-number-checks.ts](conformance/lib-number-checks.ts) | Number predicates and constants |
360
- | `Number.EPSILON` / `isFinite` / `toPrecision` | ❌ | — | No probe yet |
361
- | `String()` / `Boolean()` conversions | ❌ | — | No probe yet (`Number()` ✅ above, `filter(Boolean)` ✅) |
367
+ | `Number.EPSILON` / `isFinite` / `toPrecision` | ✅ | [lib-number-misc.ts](conformance/lib-number-misc.ts) | `toPrecision` → `strconv.FormatFloat(x, 'g', n, 64)` |
368
+ | `String()` / `Boolean()` conversions | ✅ | [lib-conversions.ts](conformance/lib-conversions.ts) | JS formatting / truthiness |
362
369
 
363
370
  ### `Date`
364
371
 
@@ -366,7 +373,7 @@ Every standard-library API TypeNative ports, split by module. Per
366
373
  | ------------------------------------------------ | :----: | ---------------------------------------------- | ----------------------------- |
367
374
  | `new Date()` / `getTime` / `toISOString` | ✅ | [lib-date.ts](conformance/lib-date.ts) | `new Date(ms)` → `time.UnixMilli`; `getTime`/`toISOString` mapped to `time.Time` |
368
375
  | `Date.now()` | ✅ | [lib-date-now.ts](conformance/lib-date-now.ts) | `time.Now().UnixMilli()` |
369
- | Component getters (`getFullYear`, `getMonth`, …) | ❌ | — | No probe yet |
376
+ | Component getters (`getFullYear`, `getMonth`, …) | ✅ | [lib-date-getters.ts](conformance/lib-date-getters.ts) | Local and `getUTC*` getters, `Date.UTC` |
370
377
 
371
378
  ### `RegExp`
372
379
 
@@ -381,8 +388,8 @@ Every standard-library API TypeNative ports, split by module. Per
381
388
  | Named groups | ✅ | [lib-regex-named-groups.ts](conformance/lib-regex-named-groups.ts) | `(?<name>` → `(?P<name>`; `exec` returns a match with `.groups` |
382
389
  | 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 |
383
390
  | Lookbehind | ✅ | [lib-regex-lookbehind.ts](conformance/lib-regex-lookbehind.ts) | Lookaround patterns run on the backtracking engine |
384
- | Remaining flags (`s` / `u` / `y`) & `source` / `flags` | ❌ | — | No probe yet |
385
- | `split` with RegExp | ❌ | — | No probe yet |
391
+ | 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 |
392
+ | `split` with RegExp | ✅ | [lib-regex-split.ts](conformance/lib-regex-split.ts) | `re.Split(s, -1)` |
386
393
 
387
394
  ### `Promise` / timers
388
395
 
@@ -390,10 +397,12 @@ Every standard-library API TypeNative ports, split by module. Per
390
397
  | ---------------------------------------------------- | :----: | ------------------------------------------------------------ | ------------------------------------------------------------------- |
391
398
  | `Promise` constructor / `.then` | ✅ | [syntax-promise-then.ts](conformance/syntax-promise-then.ts) | Channel lowering works (see [Async & timing](#async--timing)) |
392
399
  | `Promise.all` | ✅ | [syntax-promise-all.ts](conformance/syntax-promise-all.ts) | Channel lowering works (see [Async & timing](#async--timing)) |
393
- | `Promise.resolve` / `reject` / `.catch` / `.finally` | ❌ | — | No probe yet |
394
- | `Promise.race` / `allSettled` / `any` | ❌ | — | No probe yet |
395
- | `setInterval` / `clearInterval` / `clearTimeout` | ❌ | — | No probe yet |
396
- | `queueMicrotask` | ❌ | — | No probe yet |
400
+ | `Promise.resolve` | ✅ | [lib-promise-resolve.ts](conformance/lib-promise-resolve.ts) | Buffered channel holding the value |
401
+ | `Promise.reject` / `.catch` / `.finally` | ✅ | [lib-promise-catch.ts](conformance/lib-promise-catch.ts) | Rejected promises are closed channels with a reason; `await` rethrows |
402
+ | `Promise.race` / `allSettled` / `any` | ✅ | [lib-promise-combinators.ts](conformance/lib-promise-combinators.ts) | Goroutine per promise; first settled / all settled / first fulfilled |
403
+ | `clearTimeout` | ✅ | [lib-timers.ts](conformance/lib-timers.ts) | `TnClearTimeout` stops the timer |
404
+ | `setInterval` / `clearInterval` | ✅ | [lib-set-interval.ts](conformance/lib-set-interval.ts) | `time.Ticker`; the process lives until cleared |
405
+ | `queueMicrotask` | ✅ | [lib-queue-microtask.ts](conformance/lib-queue-microtask.ts) | Runs after the current synchronous code (end of main or a timer callback) |
397
406
  | `setTimeout` | ✅ | [lib-set-timeout.ts](conformance/lib-set-timeout.ts) | Lowered to `time.AfterFunc` (see [Async & timing](#async--timing)) |
398
407
 
399
408
  ### Misc globals
@@ -403,13 +412,13 @@ Every standard-library API TypeNative ports, split by module. Per
403
412
  | `assert` | ✅ | [lib-console-log.ts](conformance/lib-console-log.ts) | Transpiled to `panic` on failure |
404
413
  | `process.argv` / `process.platform` | ✅ | [lib-process.ts](conformance/lib-process.ts) | Mapped to `os.Args` / `runtime.GOOS` |
405
414
  | `process.env` | ✅ | [syntax-top-level-scope.ts](conformance/syntax-top-level-scope.ts) | Environment variable access |
406
- | `process.exit` | ❌ | — | Mapped to `os.Exit`; no probe yet |
407
- | `process.cwd()` | ❌ | — | Mapped to `os.Getwd()`; no probe yet |
408
- | `Infinity` | ❌ | — | No probe yet (`NaN` semantics ✅) |
409
- | Global `isNaN` / `isFinite` | ❌ | — | `Number.isNaN` ✅; global forms unprobed |
410
- | `encodeURIComponent` / `decodeURIComponent` | ❌ | — | No probe yet |
411
- | `structuredClone` | ❌ | — | No probe yet |
412
- | `globalThis` | ❌ | — | No probe yet |
415
+ | `process.exit` | ✅ | [lib-process-exit.ts](conformance/lib-process-exit.ts) | `os.Exit` |
416
+ | `process.cwd()` | ✅ | [lib-process-cwd.ts](conformance/lib-process-cwd.ts) | `os.Getwd()` |
417
+ | `Infinity` | ✅ | [lib-globals.ts](conformance/lib-globals.ts) | `math.Inf(1)` |
418
+ | Global `isNaN` / `isFinite` | ✅ | [lib-globals.ts](conformance/lib-globals.ts) | `math.IsNaN` / `math.IsInf` |
419
+ | `encodeURIComponent` / `decodeURIComponent` | ✅ | [lib-uri.ts](conformance/lib-uri.ts) | `TnEncodeURIComponent` / `url.PathUnescape` |
420
+ | `structuredClone` | ✅ | [lib-structured-clone.ts](conformance/lib-structured-clone.ts) | Reflection deep copy |
421
+ | `globalThis` | ✅ | [lib-global-this.ts](conformance/lib-global-this.ts) | `globalThis.x` is the global `x`; `(globalThis as any)` is a dynamic object |
413
422
 
414
423
  ### Node builtins (`node:*`)
415
424
 
@@ -417,7 +426,7 @@ Every standard-library API TypeNative ports, split by module. Per
417
426
  | ------------------------------------------------------------------------------------ | :----: | ------------------------------------------------ | ----------------------------------------------------- |
418
427
  | `node:path` (`join`, `dirname`, `basename`, `extname`, `resolve`) | ✅ | [lib-node-path.ts](conformance/lib-node-path.ts) | Mapped to Go `path`/`filepath` |
419
428
  | `node:fs` (`read/write/append/exists/mkdir/readdir/copy/rm/unlink`) | ✅ | [lib-node-fs.ts](conformance/lib-node-fs.ts) | Via Go helpers |
420
- | `node:url` (`fileURLToPath`, `pathToFileURL`) | ❌ | — | Declared but no probe yet |
429
+ | `node:url` (`fileURLToPath`, `pathToFileURL`) | ✅ | [lib-node-url.ts](conformance/lib-node-url.ts) | `TnFileURLToPath` / `TnPathToFileURL` |
421
430
  | `node:os` (`platform`, `homedir`, `tmpdir`) | ✅ | [lib-node-fs.ts](conformance/lib-node-fs.ts) | `platform()` covered; `homedir`/`tmpdir` unprobed |
422
431
  | `node:child_process` (`exec`, `execSync`, `spawnSync`, `spawnInherit`) | ✅ | [lib-node-fs.ts](conformance/lib-node-fs.ts) | Sync API shape, stdio-inherit runs |
423
432
  | `node:readline` (`question`) | ❌ | — | Declared (TypeNative sync extension) but no probe yet |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typenative",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Build native applications using Typescript.",
5
5
  "type": "module",
6
6
  "bin": {
package/tsparser/main.go CHANGED
@@ -19,18 +19,30 @@ import (
19
19
  "github.com/buke/typescript-go-internal/pkg/ast"
20
20
  "github.com/buke/typescript-go-internal/pkg/core"
21
21
  "github.com/buke/typescript-go-internal/pkg/parser"
22
+ "github.com/buke/typescript-go-internal/pkg/scanner"
22
23
  )
23
24
 
25
+ // The parsed source, for template raw text
26
+ var sourceText string
27
+
24
28
  func main() {
25
29
  sourceBytes, err := io.ReadAll(os.Stdin)
26
30
  if err != nil {
27
31
  fmt.Fprintln(os.Stderr, "read stdin:", err)
28
32
  os.Exit(1)
29
33
  }
34
+ sourceText = string(sourceBytes)
35
+ // --tsx: parse JSX (.tsx sources)
36
+ fileName, scriptKind := "/main.ts", core.ScriptKindTS
37
+ for _, arg := range os.Args[1:] {
38
+ if arg == "--tsx" {
39
+ fileName, scriptKind = "/main.tsx", core.ScriptKindTSX
40
+ }
41
+ }
30
42
  sourceFile := parser.ParseSourceFile(
31
- ast.SourceFileParseOptions{FileName: "/main.ts"},
43
+ ast.SourceFileParseOptions{FileName: fileName},
32
44
  string(sourceBytes),
33
- core.ScriptKindTS,
45
+ scriptKind,
34
46
  )
35
47
  out := serializeNode(sourceFile.AsNode())
36
48
  enc := json.NewEncoder(os.Stdout)
@@ -42,6 +54,21 @@ func main() {
42
54
  }
43
55
 
44
56
 
57
+ // var / let / const / using / await using (await using sets Const | Using)
58
+ func declarationKind(flags ast.NodeFlags) string {
59
+ switch {
60
+ case flags&ast.NodeFlagsAwaitUsing == ast.NodeFlagsAwaitUsing:
61
+ return "await using"
62
+ case flags&ast.NodeFlagsUsing != 0:
63
+ return "using"
64
+ case flags&ast.NodeFlagsConst != 0:
65
+ return "const"
66
+ case flags&ast.NodeFlagsLet != 0:
67
+ return "let"
68
+ }
69
+ return "var"
70
+ }
71
+
45
72
  // Nodes currently being serialized (cycle guard).
46
73
  var inProgress = map[*ast.Node]bool{}
47
74
 
@@ -125,8 +152,14 @@ func serializeNode(n *ast.Node) any {
125
152
  case ast.KindIdentifier, ast.KindPrivateIdentifier, ast.KindStringLiteral,
126
153
  ast.KindNumericLiteral, ast.KindBigIntLiteral, ast.KindNoSubstitutionTemplateLiteral,
127
154
  ast.KindRegularExpressionLiteral, ast.KindTemplateHead, ast.KindTemplateMiddle,
128
- ast.KindTemplateTail, ast.KindJsxText:
155
+ ast.KindTemplateTail:
129
156
  obj["text"] = n.Text()
157
+ case ast.KindJsxText:
158
+ // Node.Text() doesn't cover JsxText
159
+ obj["text"] = n.AsJsxText().Text
160
+ }
161
+ if n.Kind == ast.KindVariableDeclarationList {
162
+ obj["declarationKind"] = declarationKind(n.Flags)
130
163
  }
131
164
 
132
165
  // Binding-pattern holes (`[a, , b]`): ts-go parses them as an empty
@@ -141,6 +174,23 @@ func serializeNode(n *ast.Node) any {
141
174
  if data.IsValid() {
142
175
  collectFields(data, obj)
143
176
  }
177
+ // ts-go's PostfixToken is ? or !; the TypeScript API names a ! exclamationToken
178
+ if tok, ok := obj["questionToken"].(map[string]any); ok && tok["kind"] == "ExclamationToken" {
179
+ delete(obj, "questionToken")
180
+ obj["exclamationToken"] = tok
181
+ }
182
+ // Template pieces: rawText is the source between their delimiters
183
+ // (`…`, `…${, }…${, }…`), with line endings normalized like JS
184
+ switch n.Kind {
185
+ case ast.KindNoSubstitutionTemplateLiteral, ast.KindTemplateHead, ast.KindTemplateMiddle, ast.KindTemplateTail:
186
+ start, end := scanner.SkipTrivia(sourceText, n.Pos())+1, n.End()-1
187
+ if n.Kind == ast.KindTemplateHead || n.Kind == ast.KindTemplateMiddle {
188
+ end--
189
+ }
190
+ if start <= end && end <= len(sourceText) {
191
+ obj["rawText"] = strings.ReplaceAll(sourceText[start:end], "\r\n", "\n")
192
+ }
193
+ }
144
194
  return obj
145
195
  }
146
196
 
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/tsparser/tsparser.exe
3
- size: 37234176 bytes
4
- sha256: ce98ee3136dc50c07e1d3c12ace366c7f7180982c7cc14615ac614ab34fc63ae
3
+ size: 37236736 bytes
4
+ sha256: 325117ab33bbcf3ee1557ea5a7f5983e3aa5c9f217586bfdc9d7c33eb4d80ac2
@@ -9,7 +9,7 @@ declare module 'node:path' {
9
9
  }
10
10
 
11
11
  declare module 'node:fs' {
12
- export function readFileSync(path: string): string;
12
+ export function readFileSync(path: string, encoding?: string): string;
13
13
  export function writeFileSync(path: string, content: string): void;
14
14
  export function appendFileSync(path: string, content: string): void;
15
15
  export function existsSync(path: string): boolean;
@@ -17,6 +17,7 @@ declare module 'node:fs' {
17
17
  export function readdirSync(path: string): string[];
18
18
  export function copyFileSync(src: string, dest: string): void;
19
19
  export function rmSync(path: string, options?: { recursive?: boolean }): void;
20
+ export function unlinkSync(path: string): void;
20
21
  }
21
22
 
22
23
  declare module 'node:url' {
@@ -38,8 +39,11 @@ declare module 'node:child_process' {
38
39
  }
39
40
  export function exec(command: string): ExecResult;
40
41
  export function execSync(command: string): string;
41
- export function spawnSync(file: string, args: string[], options?: object): ExecResult;
42
- export function spawnInherit(file: string, ...args: string[]): number;
42
+ export function spawnSync(
43
+ file: string,
44
+ args: string[],
45
+ options?: { stdio?: string; input?: string; encoding?: string }
46
+ ): ExecResult;
43
47
  }
44
48
 
45
49
  declare module 'node:readline' {