Skip to content

v0.4.15

Latest

Choose a tag to compare

@github-actions github-actions released this 21 Nov 06:39
e30bb27

0.4.15

Highlights

  • Node.js parity:
    • Set and Map take Map, Set and typed-array elements: each is one object for its whole life, so JavaScript compares it by identity, and the collection holds it, finds it, deletes and re-adds it, iterates it in insertion order and seeds another Map from [key, value] pairs holding it, instead of failing with SC2020; Set<Uint8Array> and Map<Map<string, number>, T> compile and keep two objects with equal contents apart.
    • A collection constructor's seed cast from an untyped value, new Set(u as Key[]) where u is unknown, lowers as the ordinary checked array conversion rather than as a single key, so it compiles like const keys = u as Key[]; new Set(keys) and every element keeps the identity the untyped name still sees; a key written on its own (set.add(u as Key)) stays refused, because copying a key would change the object the collection holds.
    • A class declared in a module of an import cycle behaves as Node's temporal dead zone makes it: a reference that can run before the class statement — new, a static read, the class value, instanceof, a subclass's extends clause in another module, generic classes included — throws Node's ReferenceError naming the binding, and every later reference sees the one class, instead of the program failing to build with SC1016. The check sits where the class is read, so a computed extends expression keeps its own work and its unselected arms: only a heritage expression that IS the class value — a name, a namespace member, a parenthesized or asserted one — carries it, while an implements clause and a heritage type argument, which Node erases, carry none.
    • RegExp(pattern, flags) called without new compiles as the constructor call Node runs, instead of throwing SC2020 at startup, and a RegExp pattern whose flags argument is undefined — spelled that way or only undefined at run time — answers the pattern itself, keeping its identity and lastIndex; a pattern the compiler cannot see is a string is judged by the runtime, so an untyped pattern keeps that rule too.
    • sqlite: node:sqlite compiles, from DatabaseSync and StatementSync through backup(), user functions, aggregates, sessions, serialization and tag stores, with statement results and row values that can be stored.
    • worker_threads: workers answer resourceLimits, cpuUsage and loop metrics through worker.performance, carry Blob, File, Map and Set values through messages, validate transfer lists, answer a fresh promise from every terminate() call, and expose stdout and stderr without stream options.
    • http and https: agents take Node's keep-alive hooks, createConnection and maxTotalSockets, requests take Node's header value forms and support writeInformation, write callbacks and cork/drain, and IncomingMessage reports signal, finished and destroyed state.
    • http2: trailers, informational responses and stream error codes follow Node, alongside the server, settings and session surface.
    • stream: Readable.toWeb, Writable.toWeb, Duplex.fromWeb, duplexPair, readable.wrap and readable.iterator compile, ReadableStream.values() works as a stored iterator, stream/consumers handles blobs, and high-water marks and close ordering match Node.
    • fs: fs.watch recurses on Linux and Windows, fsPromises.watch and StatWatcher follow Node's liveness, readdir accepts every encoding with withFileTypes and recursive listing, mkdtempDisposable compiles, and FileHandle closes through Symbol.asyncDispose and answers a readable web stream.
    • crypto: X448, ML-KEM, Argon2, KMAC, SHA-3, cSHAKE, TurboSHAKE and KangarooTwelve compile; WebCrypto adds AES-OCB, ChaCha20-Poly1305, ECDH, X25519 and RSA-OAEP, converts KeyObjects to CryptoKeys and back, and derives public keys.
    • tls: servers build through the class, tls.exportKeyingMaterial compiles, and native verification applies Node's blocked-SPKI policy.
    • dgram: the socket class, udp6 and the synchronous members compile, with block lists and bind options enforced as Node enforces them.
    • console and util: the whole Console prototype compiles with per-instance state, inspectOptions and color mode are honored, console.createTask answers Node's task object, global console calls publish their arguments on their diagnostics channels, util.inspect compact and util.getCallSites compile, and console.table inspects cells with the instance's options.
    • module: module.findPackageJSON, import.meta as a value, export * over CommonJS modules, CommonJS metadata reads and exports chosen at run time compile.
    • perf_hooks: createHistogram and RecordableHistogram compile with skewness, kurtosis, confidence intervals and Welch's t-test, and performance.timerify and resource timing entries are supported.
    • node:test: subtests with options, test tags, t.plan options, suite timeouts, t.signal, t.error, mock contexts and records, snapshot serializers, the callback form and tracing-channel events compile.
    • globals and events: BroadcastChannel, MessagePort as an EventTarget with MessageEvent and CloseEvent, structuredClone of primitive wrappers, AsyncResource and AsyncLocalStorage.withScope over async hooks, trace_events, AbortSignal instanceof, navigator and performance entry tags compile.
    • buffer and assert: Buffer.copyBytesFrom and buffer.resolveObjectURL compile, Buffer copy, search and optional positions match Node, and assert accepts Error objects and non-string messages with Node's generatedMessage and property order.
  • TypeScript parity:
    • A relative JavaScript import resolves to its sibling declaration for types, as tsc resolves it: ./lib.js is typed by lib.d.ts, ./lib.mjs by lib.d.mts and ./lib.cjs by lib.d.cts when the file sits beside the JavaScript, while the compiled module is the JavaScript Node loads. A call is checked against the declaration (an optional declared parameter stays optional although the JavaScript's inferred parameter type requires it), so a vendored dependency keeps its published types instead of losing them to the JavaScript's inferred shape. A declaration a project's tsconfig include loads beside its implementation also stays in the program, where a JSX project previously reported it as a missing file.
    • A promise executor's resolve called without an argument, such as a requestAnimationFrame callback that settles its promise when the frame arrives, compiles instead of failing with SC0001: Node settles the promise with undefined, the checker reports the call as TS2810, the JavaScript spelling of the arity error that names the missing JSDoc hint, and unchecked JavaScript admits that diagnostic as it already admits TS2554, while a // @ts-check file, or a project that sets checkJs, keeps it. A program that does not hit the diagnostic compiles to the same IR.
    • A fetch overload set merged from lib.dom and the Node declarations compiles as one function, so a record holding it stays static.
    • A void call's value, read through a variable in a truthiness test, compiles.
    • A var read above its declaration compiles when every read follows the store.
    • Operators in unchecked JavaScript read the value a binding actually holds.
    • arguments.length counts in functions with optional, default or rest parameters.
    • require() inside a function or immediately-invoked function evaluates once and answers the same exports object, while CommonJS var and let bindings holding require() stay mutable.
    • Inline callbacks in JSX attributes take the attribute's contextual types.
    • A destructuring of a void-typed value compiles, function declaration bindings can be replaced, and a named function expression's inner binding keeps its refusal.
  • Performance:
    • Loop counters now carry integer facts and aligned function entries, and a small loop callee inlines together with the bodies it calls.
    • Programs that do not use promises no longer link the promise unit, and programs without workers no longer link their dynamic invocation support.
    • A self-slicing string scan reads the base string at an offset instead of copying it.

Fixes

  • A checked-dynamic module global, such as the object literal React's bundles build for a context, keeps that storage when the optional analysis would narrow it, so a function declared above the declaration reads the global at the type it holds instead of failing the build with an internal error. A discarded conditional of void calls under && or || lowers as the branch it is, instead of failing the same way.

  • console.createTask compiles the way Node 24 runs it: the call answers a task object whose run(callback) calls the callback and answers its result, the global console member is one function value (so React's development build can store it in a binding and call it there), and a Console instance answers undefined, as Node's instances do. A missing or non-string name, and a callback that is not a function, throw Node's messages.

  • A callback written inline in a JSX attribute keeps the types the element's attribute type gives its parameters, for intrinsic elements and components: the rewrite constrains an expression whose functions have no annotations with the slot's contextual type (read through the component's own props type, so a prop type private to the component's module stays usable), so onClick={(event) => event.button} lowers with event typed instead of failing preflight with SC0001, and a JavaScript file keeps the unchecked lowering it had.

  • A require() inside a function or an immediately-invoked function compiles as Node's loader runs it: the dependency evaluates on the require's first call and every later require — the same call again, another function, or a plain statement — answers the same exports object, so a library that wraps require("react") in an IIFE (React's development jsx-runtime) builds and runs. A module whose exports form a static table answers such a nested require with the runtime's per-module view over its export globals, so member reads are live and identity holds across requires; that view is read-only and lists its keys sorted, where Node's exports object accepts writes and keeps insertion order, and the top-level spelling keeps its named value fence.

  • A typeof comparison against a literal no typeof can answer, such as React's "unknown" !== typeof event.returnValue, compares the runtime kind string instead of refusing the program, and the operand still evaluates once. process.emit on the exception events calls their listeners, answers whether any existed and propagates a listener's throw, as Node's emitter does; the special error event throws Node's unhandled-error error, and a spread argument vector is built before any listener runs.

  • A CommonJS var/let holding require()'s result is an ordinary mutable binding, as in Node: var lib = require("./lib.cjs"); lib = { … } compiles, the declaration still evaluates the module, and reads and writes of the binding see the replacement. A module that exports one value (module.exports = function …) or one object literal (module.exports = { … }) supplies the stored value; a module that assigns its members one by one (exports.x = …) keeps a named refusal until its exports object has a first-class value. An ES import binding and a const require binding stay immutable.

  • A var read above its declaration compiles when every read is proven to run after the first store: a function declared above the variable reads the value the declaration stored, in the binding's own storage, where the build previously reported SC1030. A read that can run before the store keeps answering undefined, including one behind a non-null assertion or a declaration written var x!: T.

  • An operator in an unchecked JavaScript file reads the value a binding actually holds, not the shape one assignment gave it: shipped JavaScript reuses one var for a property descriptor, an array of stack lines and a count, so 1 <= namePropDescriptor, RunInRootFrame++, hostSiblings += 1 and getTargetInstFunc && … compile to the dynamic conversion Node applies instead of failing with SC0001 or SC1090. A var read before its first assignment answers undefined, as the hoisted declaration does in Node. A // @ts-check file keeps the checker's diagnostics, and an operator whose operand is a static object keeps its refusal.

  • A module namespace object read through a value the checker cannot resolve, such as (ns as any).log, answers undefined for a name the module does not export and the export for one it does, as Node does, instead of failing with SC1090.

  • A function declaration's binding can be replaced (value = () => 2), as Node's mutable binding allows, and a named function expression's own inner binding keeps its refusal, where strict code throws. A truthiness test of a void-typed call through a plain object's member reads the value the call answered, because the function the program stores in that member keeps its own result. value instanceof AbortSignal tests the runtime's signal handle, answering true for a signal and false for every other value, and new AbortSignal() throws Node's ERR_ILLEGAL_CONSTRUCTOR.

  • A checked value from an indexed object's optional member, such as JsonWebKey's alg?: string over [key: string]: unknown, keeps the present undefined a (T | undefined)[] slot admits instead of throwing expected string at $, got undefined: an array literal, an index write, push, unshift, splice, toSpliced, with, fill, Array.of and new Array(...) print null from JSON.stringify and read back as undefined, as Node does.

  • A property descriptor read from a class's prototype through an untyped value, such as a UI SDK's Object.getOwnPropertyDescriptor(Object.getPrototypeOf(el), "value"), builds and answers Node's descriptor — the accessor pair the class declares, with its attributes — instead of failing the build with an empty SC3004: a class value's static table reflects a static method whose parameters complete as the checked-dynamic function Node holds, and a member the table cannot hold leaves the class's statics fenced rather than aborting lowering. Building the prototype view itself no longer reports the retry's diagnostic for a member whose body cannot run over a dynamic receiver (a typed field used as a Map key, say); that statement fences at run time. A native build that fails inside the compiler now names the failure, and no SC3002–SC3004 diagnostic is empty.

  • A class method read from a prototype view — an untyped value's Object.getPrototypeOf, or a descriptor taken from it — runs its class's compiled method instead of throwing at run time: a member whose body reads a generic method through this (a DOM node's insertBefore calling this.appendChild) has no checked-dynamic form to hand out, so the view answers that member's compiled, receiver-checked value and the body keeps the class's own this, where the generic call lowers as its typed call site does.

  • Release stack frames record call and throw positions, and Error.prepareStackTrace compiles as program state.

  • A class value's statics table and prototype views answer accessors, descriptors and subclass instanceof as Node does.

  • require(esm) and partial CommonJS cycles follow Node's semantics.