Limitations
scriptc supports a subset of JavaScript, TypeScript, and the Node.js APIs.
This page is a reference for the remaining restrictions and for runtime behavior that differs from Node.js.
You don't need to read it front to back: run scriptc coverage on your program, and come here when a diagnostic or a behavior difference needs more context.
The Node.js compatibility reference lists support API by API.
Some entries mention checked values.
When the type of a value is only known at runtime, such as unknown, any, the result of JSON.parse, or a value passed through untyped JavaScript, scriptc stores it together with its runtime type and checks it when the program converts it back to a specific type.
Entries that say a value "retains identity through checked storage" mean the same object comes back out, rather than a copy.
Language and API restrictions
The following sections describe what compiles and what doesn't, area by area. They are not exhaustive; the compiler's diagnostics are the authority for a specific program.
Language features
- Error causes: Accessor constructor options are unsupported.
Subclasses may redeclare
causeasunknownorobject(for examplecause?: unknown), which defines the own property aftersuper()returns as Node does; redeclarations with other types, parameter properties, and accessors namedcauseare unsupported.Error,TypeError,RangeError, andSyntaxErrorotherwise accept{ cause }, including through inherited constructors. Reads, writes, deletion, and"cause" in errordistinguish an absent cause from an explicitly undefined cause. Constructor causes are non-enumerable; assignment to an absent cause creates an enumerable property. Property descriptors and checked-value aliases share the cause, including getters and setters installed after construction. - Class reflection:
JSON.stringifyandObject.keysrequire every declared field to have a representation that can pass through runtime-checked storage.JSON.stringifywrites Date fields as their ISO text and Map and Set fields as{}, as Node.js does, and refuses classes with RegExp or Promise fields withSC1090.Object.keysraises an error for classes with opaque fields such as native Maps. Class fields, inherited accessors, and added properties retain identity through untyped values. - Class members: A method, an accessor, or a static method of a TypeScript class that cannot be compiled is refused by itself: the class, its fields, and its other members compile.
Using the refused member where the compiler can see it is a compile error at the use, which names the member, and the member's own diagnostic is reported once.
A call that reaches the member another way throws an error that carries the diagnostic's code at run time: through an untyped value, through an interface, or through a base-class receiver when the member is an override.
A refused field, constructor, base class, decorator, or index signature still rejects the whole class, as does a member that overrides an async, generator, or generic method of its base class.
An override may declare a narrower parameter than the method it overrides: one arm or some arms of the base's union, a required parameter where the base's is optional, or a subclass of the base's class.
A call through the override's own class is direct; a call through the base class, an interface, or an untyped value checks each such argument and throws a
TypeErrornaming the method and the parameter when the value is outside the type the override declares. Node.js runs the override with that value; a compiled override reads its parameter as the declared type, so the call is refused instead of running with a value the type does not describe. An override may also declare fewer parameters than its base: the arguments past its last parameter are dropped, as in Node.js. A call through an untyped value must still pass the base's arguments, and a shorter override that a subclass overrides again is callable through its own class only when the dropped parameters are optional. An override with fewer parameters whose body readsarguments, or with a tuple where the base declares an array, is refused as a member. - Method values: Borrowing a class method onto an unrelated object is unsupported.
Detached methods that use
this, builtin method values, abstract declarations, unspecialized generic methods, and incompatible override signatures produce runtime errors or compilation diagnostics. Supported class methods can be stored and passed as unbound functions. A method of a TypeScript class that mentionsthisorsuperchecks its receiver each time it is called through a value, and throws aTypeErrorunless the receiver is an instance of the class. A method that tests its receiver (this === undefined,!this,this instanceof C) therefore throws thatTypeErrorwhen it is called without an instance, where Node.js runs the method and takes the method's own branch. The same holds when the call supplies another object as the receiver, where Node.js answers the test for that object. A method that never mentionsthisruns without a receiver. A member called through parentheses, a non-null assertion, or a type assertion ((obj.method)(),obj.method!(),(obj.method as F)()) is called on its object, as in Node.js; an element access in parentheses ((obj["method"])()), a parenthesized optional chain, and an optional method declared without a body and called with!lose the receiver. A field call supplies its containing instance asthis;call,apply, andbindwork when the signature supports runtime-checked conversion. Extracted overrides retain the selected method, and receiver validation accepts the declaring class and its subclasses. - Loose equality: Object-to-primitive
==and!=comparisons are unsupported becausevalueOfandtoStringcan execute user code. Convert the object explicitly before comparing. Comparisons between represented primitives and primitive unions support number, string, boolean, and BigInt coercions, includingx == nullandx != null. - Resource disposal: Top-level and switch-clause
usingdeclarations, andAsyncDisposableStack, are unsupported. Block- and function-scopedusingandawait usingsupport compiled classes with zero-parameter disposal methods, object literals and otherDisposable- orAsyncDisposable-typed values, and supported FileHandle, timer, immediate, child-process, and readline handles. A class instance reached through aDisposable- orunknown-typed value throws an SC2020 error when its declaration runs; declare the variable with the class type. Arrayfor (using ... of ...)loops also compile.SuppressedErrorvalues exposeerrorandsuppressed;extends SuppressedErrorand castingunknowntoSuppressedErrorare unsupported (narrow withinstanceof).DisposableStacksupportsuse,adopt,defer,move,dispose,disposedand[Symbol.dispose], and works withusing;useaccepts class instances, object literals and otherDisposable-typed values, and refuses unions that include class instances (narrow the value first). Disposal runs in reverse order and raises Node'sSuppressedErrorchain when more than one callback throws. - Async iteration: Async
yield*delegation, stored Web or Node iterator handles, and general structural async-iterator objects are unsupported. Typed async generators support lazy execution,await, directyield, queued.next()/.return()/.throw()requests, andfor await.for awaitalso accepts NodeReadablestreams, WebReadableStreamvalues, and compiled class iterators whose zero-parameternext()returns a promise of a{ value, done? }record. A class instance whose[Symbol.asyncIterator]()returns an object literal, or that has only[Symbol.iterator](), iterates through the checked-dynamic async protocol, and an early exit awaits the iterator'sreturn(). Abrupt completion runs cleanup, including literaldestroyOnReturnandpreventCanceloptions. Thenode:timers/promisessetInterval(delay, value)iterator compiles without AbortSignal options.Array.fromAsyncaccepts arrays of values or of promises and typed async generators, with an optional mapping function; athisArgand arrays that mix values and promises are unsupported. - Iterable values: A value typed
Iterable<T>can hold an array, a Set, a Map (forIterable<[K, V]>), a string (forIterable<string>), a generator, or a Map, Set or array iterator. Class instances with their own[Symbol.iterator]method and typed arrays can't be stored in anIterable<T>and are reported at the conversion. - Generics: Generic functions declared inside other functions, generic class expressions, and generic methods requiring dynamic dispatch are unsupported.
Generic classes can extend generic bases when each specialization has a concrete layout.
Independent concrete uses have no specialization-count limit; recursively expanding demands and type layouts produce diagnostics.
Other generic calls compile when the target resolves statically.
Generic generator methods, sync and async, compile like other generic methods.
A generic async generator method called through an untyped value, or through an interface whose receiver's class the compiler does not know, throws a coded SC2020 error.
Generic function values require a concrete signature at use and a binding that is never reassigned.
Inside a generic instance whose binding holds values of several record layouts, a statement that takes the binding's value as the one record type its constraint names (an argument for a parameter of that type, a function literal's parameter, or a destructuring pattern) builds with warning
SC6015and throws aTypeErrorwhen it runs with a value of another layout, where Node completes it. - Variadic wrappers: A generic higher-order wrapper is specialized to each wrapped function's exact signature.
Parameters<F>,ReturnType<F>, and rest parameters typed as fixed tuples become that signature's parameter list. A function expression with no parameters that readsargumentscompiles only when its value is asserted to, or contextually typed as, one fixed-arity signature;argumentsis then that signature's tuple. Forwarding it withfn.apply(this, arguments)passesthisthrough. Readingfn.nameon a wrapped function requires its name to be known where the wrapper is called, such as a function declaration or aconst-bound function.Parameters<F>over a signature with optional or array-typed rest parameters is unsupported, because that tuple has no fixed length. - Function values: Immutable aliases of overloaded program functions retain per-call overload resolution and identity.
A function stored in a slot with a different signature remains the same function for equality, array searches,
length, and own properties. A method value'slengthis the length of the method its object's class declares, whatever type the receiver is read through. Thelengthof a function declaration, a static method, or a method of a JavaScript class counts a parameter with a default, where Node.js stops counting at the first one. Typed rest-parameter functions can be stored and called indirectly, including through a slot with fixed parameters, where the slot's arguments arrive in the rest array. That store is refused withSC1090when the program hands a function of the slot's type to a caller that passes more arguments than the type names, because the rest array would not receive them. Builtin function values have API-specific restrictions; see Builtin function values. A function called as a member of an object, a tuple, or an array (holder.fn(),holder["fn"](),holder.fn?.(),list[0]()) receives that object asthis, as in Node.js, and writes throughthisreach it. A timer calls its callback without athis, where Node.js passes the timer object. In a TypeScript source, a callback whose own body readsthis, or whose signature declares athisparameter, is refused withSC1090when it is passed to a timer, aprocesslistener, anode:cryptoornode:zlibcallback, or a stream option as a function value, where Node.js passes an object of its own. A function stored under a type that declares nothisparameter is called without athisby a timer, an event emitter, aprocesslistener, and a stream, where Node.js passes the timer, the emitter,process, or the stream. - JavaScript parameters: In a JavaScript file TypeScript does not check, a prototype method (
C.prototype.m = function (...) {}) takes whatever values its callers pass; its JSDoc types document the usual values without constraining them. A sloppy-mode function with named parameters may readargumentsonly where the aliasing of its parameters cannot show: it readsarguments.length, or reads elements and never writes a parameter or an element. Other uses ofargumentsin such a function are refused withSC1090; ES modules,'use strict'code, classes, and functions with default, rest, or destructured parameters have no such restriction. Theargumentsobject is the list of the call's arguments, an array, where Node.js has an object that is not one. For the name itself or a constant that holds it,Array.isArrayanswersfalseas in Node.js, and theconcatof an array or a string, orJSON.stringify, over it is refused withSC1090.instanceof ArrayandObject.prototype.toString.callanswer as in Node.js in a function that only reads the object. These answers are the built-in functions' only: a method namedconcat,isArray,stringify,toString,call, orapplythat the program defines, a binding that shadowsArray,Object, orJSON, and a method called through an untyped receiver are called with the array. Converted to a string, printed, read for a member such asconstructororslice, tested withinstanceofor for its tag in a function that also writes to it or passes it on, or tested by the code it was passed to, it is the array. A sloppy-mode function called withundefinedornullas its receiver gets the global object asthis, as in Node. Called with a primitive receiver, itsthisis the primitive itself, where Node passes the primitive's wrapper object (typeof thisis"object"there). - Argument spreads: Non-empty fixed tuples can spread into fixed signatures; arrays, Sets, and compiled class iterables can spread into typed rest parameters.
Runtime-length spreads into fixed or rest parameters require types that support checked
unknownconversion. Other JavaScript calls use the checked-value path; unsupported static forms produce a diagnostic. Calls with no native parameter slot are unsupported for runtime-length spreads. Arguments evaluate once, in source order, before defaults run, including surplus arguments. - Dynamic imports: A specifier the build can bound to a finite set compiles to one load per value; the bound covers a string literal, a
constor never-reassigned binding, string concatenation and template parts,?:/??/||branches, the pure String methodsreplace,replaceAll,slice,toLowerCase,toUpperCase,trimandconcatover bounded values, and a parameter of a module-local function whose every call passes one of these. A specifier the build cannot bound is refused withSC1090, naming the source that stopped it. A value naming a supported Node builtin loads it natively. A value naming one of the program's own modules compiles that module and answers the one instance, however many static and dynamic edges reach it; a value that names no file rejects at run time with Node'sERR_MODULE_NOT_FOUND, so a missing.jsvariant never falls back to the.tsbeside it. Import attributes, CommonJS namespace synthesis, and imports of shipped JavaScript packages are unsupported unless the target is a compiled ESM module. Literalimport()of compiled ESM and TypeScript modules and of supported Node builtins compiles. A literalimport()of a package that nothing imports statically loads the package in a Node island at the call; with--node-islands=offit is a build error that names the package. Evaluation is lazy and microtask-delayed, top-levelawaitis honored, repeated imports share namespace identity, exported mutable bindings stay live, and namespace keys use Node's sorted order. - CommonJS
require: Literalrequire()calls of compiled modules, supported builtins, and JSON documents compile. Reading a top-levelconstorletrequire binding before itsrequireruns throws the sameReferenceErroras Node.js. Avarbinding that code above itsrequirecan reach is unsupported, and so is a read that compiles to no checkable expression, such as exporting the binding before therequire. Arequire()of a relative path that names no file when the program is built throws the sameMODULE_NOT_FOUNDerror as Node.js, where the call runs. The error has Node'scodeandmessageand norequireStackproperty. JSON documents are parsed at build time, and everyrequire()of a document returns the same object. Destructuring the exports of a module supports plain and renamed properties, plus nested patterns for builtin sub-modules such asutil.types. Computed keys work when they fold to a constant, such as a string literal or aconstbinding. A computed key whose value is only known at run time is unsupported. Any pattern works on a JSON document. Defaults, rest elements, and nested patterns over other modules are unsupported. A require cycle compiles when each of its modules assigns all of its exports before its firstrequireand uses the other modules of the cycle only inside functions that its top-level code can't call. Other require cycles are rejected withSC1016. A top-levelreturnends the module's evaluation. It is unsupported when the module assigns exports after it, or when a function that exists before it runs reads a binding declared after it, such as a callback created above thereturnor a function declaration. - JSX: JSX in
.tsx,.jsxand JavaScript files compiles with the project'sjsxsetting:"react"withjsxFactory,jsxFragmentFactoryorreactNamespace, and"react-jsx"or"react-jsxdev"withjsxImportSource, as well as the@jsx,@jsxFrag,@jsxImportSourceand@jsxRuntimepragmas. The checker types JSX with these settings, and each element becomes the call TypeScript emits for it, importing the automatic runtime's functions from<jsxImportSource>/jsx-runtimeorjsx-dev-runtime."jsx": "preserve"and"react-native", which keep JSX in the output, are refused. The call an element becomes must type-check: a factory or runtime function whose parameters do not accept what an element passes is reported at the element. With"react-jsxdev",jsxDEVreceivesundefinedasselfwherethishas no declared type (in a function that is not a method), which is the value such a function observes when called without a receiver.
Types and class definitions
- BigInt: BigInt filesystem stats are unsupported.
Typed code cannot construct
BigInt64ArrayorBigUint64Array; JavaScript that names either one gets the checked-dynamic element kinds, where elements are BigInts. Arbitrary-precision BigInts otherwise support literals, operators, conversions, arrays, records, classes, closures, unions, promises, typed Map keys and Set elements, Buffer 64-bit reads/writes, and DataView 64-bit access. Nativeunknownand JavaScriptanystorage preserve BigInts, including checked Map keys and Set elements. JSON serialization throws aTypeErrorunless a replacer converts the value. - Interfaces: Interfaces explicitly implemented by compiled classes retain live object identity through checked native values.
Method-signature interfaces and callable-property interfaces structurally implemented by class methods use the same representation.
A call to a method signature of such an interface calls the class's method directly when the receiver is an instance of a compiled class, and a read of a property signature reads the class's field directly; object literals, accessors, and methods the program replaces on an instance or prototype use dynamic property lookup.
Arrays of such interface values are native arrays whose elements keep their identity; methods without a native form for them run on the array's dynamic view, which shares its elements.
Other data interfaces retain native record layouts and their copy-coercion rules.
Generic methods require a statically resolved body; a
constinterface binding initialized directly withnewcan keep the concrete class for specialization. Unsupported member representations produce diagnostics. - Record shapes: Records use exact native layouts.
Passing
{ a, b }where{ a }is expected can produceSC2002. Accepted flows into a strict field-subset shape copy the record; see Record identity and property order. A type that reaches a graph of types so large or so entangled that one mapping of it takes more than 500,000 steps ends the build withSC2016, which names the type and points at its declaration. This holds under every tier, because the checked-dynamic form of the same value maps the same types. Declaring the value with a narrower type, or withunknownwhere the graph of types closes, compiles. - Unions: Narrow a union before an operation whose members require incompatible native representations, such as reading
u.lengthonstring | string[]. Some union-to-union widening and unions combining function and data members are unsupported. Same-representation methods on class unions,mapandforEachon array unions, and shared or joinable field reads compile.console.log(u)supports printing a whole union. A union may hold one promise beside other members, such asT | Promise<T>orPromise<R | void> | R | void:await, an async function'sreturn,Promise.resolve, andinstanceof Promiseact on the member it holds, with Node's microtask timing.instanceofagainst one of the program's classes answers for the member the union holds as well, and is false for the promise. A promise member beside a member that declaresthen, two promise members in one union, andconsole.logof a union holding a promise are unsupported. - Dynamic slots: A field, parameter, return value, variable or expression whose declared type has no native representation compiles as a checked dynamic slot instead of failing the build.
The parts of the type that compile keep their native layout, and only the failing parts hold checked-dynamic values.
Operations on those values run in the dynamic tier, and reading one into typed code checks it against the type that reads it, so a value that contradicts its declaration throws a
TypeErrorwhen typed code first uses it rather than when it is stored. Each slot is anSC6104warning;scriptc coverage --fail-on=dynamic-slotsfails on them, and--tier=static-onlyturns them back into build errors. A slot declared with the library'sPromiseLike<T>is such a slot: it holds a promise or an object of the program with athenmethod, andawait,Promise.resolve,Promise.all,Promise.race, and a call of itsthenask the value as Node.js does. What a thenable hands over is checked againstTwhere typed code reads it. A class whosethenmethod has type parameters cannot be called through such a slot and throwsSC2020when it is awaited; athenwithout type parameters, or an object literal, can. A promise given to one of the program's own types with athenmethod is refused withSC2002; declare the slotPromiseLike<T>instead. A member that the program adds to the libraryPromisetype, such asPromise<T> & { status?: string }, cannot be written on a promise the program made: the write throws aTypeErrorwhen it runs, and the build reports it as anSC6013warning. Keep such state beside the promise, in a wrapper record or in aWeakMapkeyed by the promise. Values that scriptc cannot produce at all, such asWeakRefinstances, still fail where they are created. A promise typed with extra members, such asPromise<T> & { settle(value: T): void }, is such a slot: a promise that a Node island hands over keeps its members, while a promise the program made holds none of its own. Assigning a member to a promise the program made, as inconst p = new Promise(...) as Promise<T> & { settle(value: T): void }; p.settle = finish, builds and throws when the statement runs: anErrorthat names the write withSC1090where the compiler sees how the promise was made, and aTypeErrorotherwise. Return the members beside the promise instead, such as{ promise, settle }. - Null and optional values:
undefinedandnullcompile as standalone values and union members. Optional record and class fields and optional, default, and rest parameters also compile, including rest parameters typedunknown[]orany[], whose functions take any number of arguments. A function value whose fixed parameters are allunknownorany, or that has none, can be stored where such a variadic function type without fixed parameters is expected: each call passes the arguments in order,undefinedfor the ones the caller left out. Other function values with fixed parameters cannot be stored there. A function value of such a variadic type can be stored where the program declares a function type with fixed parameters (a typed binding, parameter, result, field, member, or element): each call passes the declared arguments, avoidresult is discarded, and any other result is checked. That store is refused when the expected type's last parameter is optional, isunknownorany, or includesundefined, because the function would receiveundefinedwhere the call passes nothing. It is also refused withSC1090when the program hands a function of the expected type to a caller that can pass more arguments than the type names: a function type with more parameters, or a library function whose callback takes more. The stored function would not receive those arguments. Untyped code that receives the stored function calls the original, with every argument it passes. A variadic function passed directly to a library function that calls its callback with a fixed argument list is refused withSC1090. Event listeners, promise executors, timers, andprocess.nextTickpass such a function every argument, as do the methods of arrays whose elements areunknown. In a function expression written where a callback or listener is expected,arguments.lengthis the number of parameters that slot's function type declares. Handed where no function type is expected (ananyorunknownslot, a JavaScript module's function,Reflect.apply), such a function expression is refused withSC1090. - Runtime-optional storage: A binding, field, or parameter whose value comes from a read that can miss — an array element, a record key, or a read asserted with
!— keepsundefinedin its storage, and a call site that passes such a read adds that arm to the callee parameter's storage, so the callee receives every value the call site can produce. The checker's narrowing does not remove the stored arm: inside atypeofor=== undefinedguard, lowering extracts the stored value through a checked narrowing. A parameter widened this way keeps the arm even when the call site's checker type has noundefined, so a construct that needs the declared type can refuse while an arm the program never wrote is still stored; the refusal's hint names both the narrowed type and the stored arms that block it. Bind the guarded value to a local declared as the narrowed type and pass that local when a construct needs the declared type.scriptc coverage --explain-dynamiclists each widened slot and the reads where the checker's type is narrower than its storage. - Static field updates: Numeric static fields support
++and--through the declaring class or an immutable alias. Updates through a subclass name are unsupported because JavaScript creates a separate property on the subclass. - Array subclasses: A class that extends
Arraycompiles: its instances are arrays, andmap,filter,sliceand the other methods that create arrays return instances of the subclass, as in Node.js. A generic subclass (class Bag<T> extends Array<T>), a class that extends such a subclass, and a subclass that declaresSymbol.speciesare unsupported. A method whose result the subclass's constructor cannot construct throws aTypeError: the constructor's parameters must take the one length argument, and amapto another element type needs a constructor that adds no elements. - Local class expressions: Static fields and static blocks in TypeScript files, decorators, private brands, and generic members are unsupported.
Static methods read the enclosing function's bindings and are inherited by subclasses.
A named class expression's methods and static members can refer to the class by its name.
Supported expressions preserve fresh constructor identity and shared captures across constructors, methods, accessors, and arrow fields.
Local inheritance requires a compiled base class.
Constructors retain identity,
typeof,name, andlengththroughunknown; cast back to their exact type before construction. Construction and static-member access directly throughunknownare unsupported. - Constructor-function inheritance: Module-level JavaScript classes can extend compiled ordinary constructor functions.
Constructors that return replacement objects, spread
superarguments, and reflective static inheritance are unsupported. Supportedsupercalls preserve receiver and field initialization order and capture the base prototype at class evaluation. - Symbol fields: Instance fields require a stable module-level
Symbol()orSymbol.for()binding with a literal description or constant string binding. A[Symbol.toStringTag]field or getter with a string value sets the tag thatString(),Object.prototype.toStringandutil.inspectprint; fields keyed by other well-known symbols are unsupported. Reassigned keys, runtime-computed descriptions, distinct symbols with the same description in one class, and copying symbol fields with rest bindings orObject.assignare unsupported. JavaScript object spreads copy represented own symbol fields. Equal registry keys share a field across modules. Uninitialized JavaScript fields start asundefined; TypeScript fields require an initializer or unconditional constructor assignment. Represented symbol fields and methods, including inherited members, remain accessible through checked values. - Unassigned fields: A field that a method reads before the constructor has assigned it holds
undefined, as in Node.js, when construction calls that method throughthis. This covers a method the constructor calls before the assignment, the override a derived class supplies for a method its base constructor calls, and a callback written in either that capturesthis.typeof, comparisons withundefinedornull, truthiness tests,??, string conversion andconsole.logsee theundefined. Arithmetic on an unassigned number field givesNaN, and reading a member of an unassigned object, array or string field throws aTypeError, as in Node.js. Any other use that needs the declared type throws aTypeErrorfor an object, array, string or bigint field, and readsNaNfor a number field andfalsefor a boolean field, where Node.js passesundefinedon. When a constructor hands the instance to other code before it has assigned a field, such asregister(this), a read of that field in that code does not seeundefined: a number reads0, a boolean readsfalse, and using an object, array or string field stops the program. Assign the fields first, or includeundefinedin the field's type. - Class index signatures: A class may declare
[key: string]: anyor[key: string]: unknown. The signature takes no storage: a name the class does not declare is an own property of the instance, absent until something assigns it, as in Node.js. Reads, assignments, computed keys,in,Object.keys,JSON.stringifyand untyped views of the instance see the same property. An instance lists its declared fields before the added properties, as Node.js does when every added property is written after the fields exist. A class that could write one earlier is refused: a field initializer of the class or of a base class that mentionsthisor calls a function, or a base class constructor that calls a function or hands the instance out while a class below it declares fields. Assign such a field in the constructor instead. A signature with another value type or a number key is refused. A subclass of such a class cannot declare instance fields of its own; declare them in the class that has the signature, or assign them through it. Assigning a declared field through a computed key checks the value against the field's type and throws aTypeErroron a mismatch, where Node.js stores the value. Compound assignment,++,--,deleteand method calls on a name the signature admits, and object spread of the instance, are refused.
Promise.all([work(1), work(2)]) infers a tuple.
Some tuple operations, such as .at() and .concat(), are unsupported.
If you need array operations on the result, declare the input as an array:
const jobs: Promise<number>[] = [work(1), work(2), work(3)];
const results = await Promise.all(jobs); // number[]Promise.allSettled and Promise.any take the same Promise<T>[] input and return PromiseSettledResult<T>[] and T.
Builtin APIs
A declaration in the standard library does not guarantee that an API compiles.
Unsupported declared APIs produce SC2020, with alternatives where available.
Check the Node.js compatibility reference for API-level support.
- Text encoding:
TextEncoderandTextDecodercan be stored in fields, arguments, return values, arrays, and closures. Encoding supports UTF-8, includingencodeIntointo a Uint8Array or Buffer view.new TextEncoder(...)evaluates its arguments and ignores them, as Node does, sonew TextEncoder("utf-8")is a UTF-8 encoder. Codec properties expose the canonical encoding and decoder flags. Codecs held inanyorunknownstorage keep their identity and streaming state, and dynamic code can callencode,encodeIntoanddecode, with options objects, and read their properties. Decoding accepts recognized WHATWG labels, including runtime labels and omitted or undefined encodings. Literal constructor options supportfatalandignoreBOM; literal decode options support streaming UTF-8, UTF-16, and single-byte encodings. Other legacy streaming encodings, runtime options objects, inspection, JSON conversion, and module-scope declarations usingvaror lacking an initializer are unsupported. Use initializedletorconstbindings for stored codecs. - EventEmitter: Literal event names use fixed argument tuples.
Number,
null,undefined, and boolean names register underString(name), as in Node. Computed string names with a constant prefix or suffix that excludeserror, meta events, and stream-internal events pass arguments of the exact arity with checked conversion. Other names reach an EventEmitter as through an untyped value: a name computed at run time converts withString(name), then the name is matched against the program's literal event names when the call runs. The name expression is evaluated before it converts; a name whose static type is a string or number literal is a compile-time key only when reading it runs no program code (a literal, anull,undefined,trueorfalsekeyword, a binding read, a stored field or record entry read), and a call or an accessor lowers as a run-time name. On streams, those names and names that may reach internal events are unsupported. Symbol event names are supported: a symbol keys the registry by identity, so twoSymbol("s")names are different events and aSymbol.for()name is one event at every call site.eventNames()lists symbol names after every string name, and the max-listeners warning renders a symbol name asSymbol(description). Registering or removing a listener under a symbol name while anewListenerorremoveListenerlistener is registered is unsupported, as iseventNames()on an emitter with a registerederrorMonitorlistener. A stream's event names are strings: a symbol name is a type error at a typed call site and throws through an untyped value. Once the program registers a listener under an unrestricted name, typedlisteners()/rawListeners()results are unsupported for events that literal names register with typed listeners. An emitter reached through an untyped value shares one listener list with its typed uses, so untyped registrations and emits reach typed listeners and typed emits reach untyped listeners. Apipeorunpipeemission reaches such a listener with a live view of the stream (its methods and properties), not the same object identity. An untypedemitof an event that has a listener with typed parameters converts its arguments to the event's typed tuple before any listener runs, and throws aTypeErrorwhen they do not convert. Through an untyped value,listeners()andrawListeners()of an event with a listener that has typed parameters are unsupported, andemit('error')of an object that is not an Error with noerrorlistener is unsupported. AnewListenerorremoveListenerlistener registered through an untyped value receivesundefinedin place of a listener registered with typed parameters. A typederrororerrorMonitorlistener throws aTypeErrorwhen an emitted payload that is not an Error does not convert to its parameter. Reading EventEmitter methods as properties through an untyped value (typeof emitter.listeners) answersundefined.EventEmitter.prototype.<method>.call(receiver, ...)runs the method typed whenreceiveris statically an emitter instance; a receiver of typeanyruns the untyped method over its JavaScript_events, which does not reach a compiled emitter's listeners. The method is read fromEventEmitter.prototypeor from an emitter reached through a binding, a stored field, or a record entry; an accessor or a call on that path is unsupported, since skipping it would drop its effects.events.oncetakes any options expression and validates it as Node does:optionsmust be an object, only itssignalproperty is read, and a non-AbortSignal value or an aborted signal rejects the promise. An EventEmitter or stream needs a literal event name, a stream'sdataevent is unsupported, and every other receiver takes the runtime path: an EventTarget resolves with the dispatched event and any other value rejects as Node does.EventEmitter.captureRejectionSymbolandevents.captureRejectionSymbolread as Node'sSymbol.for('nodejs.rejection')value and work as an event name; thecaptureRejectionsoption and the rejection protocol behind it are unsupported.events.onlowers over an EventEmitter with a literal event name and over any other receiver through a checked-dynamic value, with the iterator'sclosenames,signalaborts, 'error' handling and watermarks; a computed or meta event name on a compiled emitter is unsupported. ReadingdefaultMaxListenersthrough a CommonJS destructured or member binding (const { defaultMaxListeners } = require("events")) is unsupported. - AsyncLocalStorage: timer, interval,
setImmediate,process.nextTickandqueueMicrotaskcallbacks run with the stores that were active when they were scheduled, as in Node. The completion callbacks offs,cryptoandzlibcallback APIs,dns.lookup,child_process.execFile,server.listen,net.connect,http.request,http.getanddgramrun with the stores that were active at the call, as in Node. Events ofnet,tls,httpandhttpssockets, servers, requests and responses run with the stores Node runs them with. A socket's or client request's events see the context of the call that created it, and a server's events and its requests' and responses' events see the context of itslisten()call. Socketwriteandendcallbacks,'finish'andserver.close(callback)see the context of their call. Stream events and callbacks run with the stores of the code that triggers them, as in Node. Stream steps that Node defers withprocess.nextTicksee the context that scheduled them, andstream.finishedandstream.pipelinecallbacks see the context of their call.fsread and write streams andzlibstreams run their events and callbacks in the context that created them. Events ofchild_processchildren, their standard streams and their IPC channels see the context of thespawn()orfork()call; stdin's'finish'andsend()callbacks see the context of their call. A clienthttp2session's events see the context of itshttp2.connect()call, and a client stream's events the context of itsrequest()call. Anhttp2server's'session'and'stream'events and the compatibility API's request handler see the context of itslisten()call; a server stream's own events, and its compatibility request's and response's, run with no store, as in Node.AsyncResourcehas no lowering yet. - Streams and readline: Stream chunks are Buffers or strings, and on an object-mode side any value that converts to a checked-dynamic value.
NodeJS.ReadableStreamandNodeJS.WritableStream, andstream.Readableandstream.Writableunder@types/node, accept every stream: when a program passes file, zlib, ornode:streamstreams through them, child-process pipes andprocess.stdoutandprocess.stderrjoin those streams asReadableandWritableinstances.readable.pipe(process.stdout)andreadable.pipe(process.stderr)compile and, as in Node, do not end the process stream. When an untyped value reachesNodeJS.ReadableStreamorNodeJS.WritableStream, those two interfaces hold any value, so JavaScript stream objects (constructor-function streams, plain objects withonandpipe) pass through TypeScript functions typed with them and come back to JavaScript as the same objects. Member calls on such a value use the native stream when it is one and call the object's own members otherwise;readable.pipe()into a JavaScript destination follows Node's pipe protocol. The firstpipelinestage may arrive as an untyped value that is a native stream, aCipherivorDecipherivvalue, or an iterable: a string, an array, a generator object, or any value with aSymbol.asyncIteratororSymbol.iteratormethod, which the pipeline pumps into the next stage as Node does. It may also be a source function, which the pipeline calls with{ signal }and whose iterable result it pumps, or a{ readable, writable }pair, whose readable side it pumps. Laterpipelinestages that arrive as untyped values may be native streams,CipherivandDecipherivvalues, functions, and iterables. A function is called with the previous stage and{ signal }as a function stage: before the last stage it must return an async iterable, and as the last stage it may return a promise, whose value resolves the pipeline, or an async iterable, which feeds the PassThrough thatpipeline()returns. An untyped source function, function stage, or destination that returns a stream is unsupported. An iterable becomesDuplex.fromof it, which the next stage reads from while the stages before it are not read, as in Node. A pipeline branches at run time on whether each of its first three untyped stages after the first is a function; a function in a later untyped stage, an untyped web stream, and a{ readable, writable }pair after the first stage throw a not-supported error.for awaitsources that arrive as untyped values must be native streams, orCipherivandDecipherivvalues, at run time; other values throw a not-supported error. Native streams expose noemitto JavaScript, so a JavaScript stream whose ownpipe()emits on its destination (the legacyStreampipe) cannot pipe into one.Readable.fromaccepts strings, Buffers, arrays, Sets, Maps, Map and Set iterators, generators, async generators, and class iterables and async iterables, and in JavaScript any iterable or async iterable. In JavaScript, a sync iterator value with athenmethod that is not a promise, and an object whose[Symbol.asyncIterator]or[Symbol.iterator]method is a generator method, are unsupported. TheobjectModeoption, and thereadableObjectModeandwritableObjectModeoptions of aDuplex,Transform, orPassThrough, taketrueorfalseliterals in an options object literal; options passed as a value are read when the stream is built. In typed code, awriteortransformcallback, or a_writeor_transformmethod, may declare its chunk with any type that converts to a checked-dynamic value: the chunk converts when the callback runs, and a value of another type throws a TypeError there. An object-mode write passes its encoding argument towriteandtransformas Node does (undefinedwhen absent,nullwhen a callback took its place); a parameter declaredstringreceives""forundefinedandnull, and one declaredstring | null | undefinedreceives Node's value.readable.read()on an object-mode stream answers any value it holds.node:stream/consumersand readline interfaces read object-mode streams of strings and Buffers; other values throw a not-supported error.pipelineaccepts function stages anywhere among its streams: async generator functions (async function* (source), iteratingsourcewithfor await), an async generator source function (async function* ({ signal })), an async generator function as the destination, and an async function destination whose value resolves the promise form and reaches the callback's second argument. A stage is written inline, or named by a function declaration or aconstbound to a function expression that nothing reassigns. The source may also be an array, a string, aSet, aMap, a generator or async generator object, or a synchronous generator function without parameters; their elements reach the next stage on the same ticks as in Node. Stages may take the{ signal }argument. With a function destination,pipeline()returns an object-mode PassThrough that receives an async generator destination's values, or an async function destination's value unless it isnullorundefined.@types/nodetypes that result asNodeJS.WritableStream, sofor awaitover it needs thePassThroughtype (pipeline(...) as PassThrough, or a JSDoc@type). In typed code, a pipeline callback with an async function or async generator destination receivesnullfor no error when its error parameter cannot holdundefined(@types/node declares itNodeJS.ErrnoException | null), andundefinedwhen it can, as in Node.Readable.fromacceptsobjectModeandhighWaterMarkoptions. TheReadableoperators (map,filter,forEach,toArray,some,find,every,flatMap,drop,take, andreduce) acceptconcurrency,highWaterMark, andsignaloptions. Their callbacks may take the{ signal }argument,mapmay return any value, andflatMapmay return any iterable, async iterable, or stream.Duplex.fromaccepts an async generator function, which reads what is written to the Duplex, aDuplex,TransformorPassThrough, which it returns, and the valuesReadable.fromaccepts, which give a Duplex that is not writable. It also accepts a loneReadableorWritableand a{ readable, writable }pair, which the Duplex reads and writes through, a promise, whose value it reads, and an async function, which reads what is written and must resolve tonullorundefined. ADuplex.frombody function may take the{ signal }argument, which is aborted with the error the Duplex is destroyed with.stream.composeaccepts streams and async generator functions in any position, an async function as the last stage, and an array, a string, or a generator as the first stage; one stage isDuplex.fromof it. A webReadableStreamis read as an async iterable byReadable.fromand as the first stage ofcomposeorpipeline, and through its reader byReadable.fromWeb(withobjectMode,highWaterMark,encoding, andsignalin an options object literal) andDuplex.from. In TypeScript,new TransformStream()without arguments builds the identity transform: its readable side is a webReadableStream, its writable side supportsgetWriter,abort,close, andlocked, and the writer supportswrite,close,abort,releaseLock,ready,closed, anddesiredSize, with Node's backpressure (a write completes when the readable side reads its chunk). In TypeScript,tee,pipeTo, andpipeThrough, theWritableStreamconstructor with an underlying sink, and aTransformStreamwith a transformer or queuing strategies compile: a program that uses one of them builds itsReadableStream,WritableStream, andTransformStreamvalues with the same classes as JavaScript, and aResponseorRequestbody has those members too. A TypeScript program that uses onlygetReader,cancel,locked, and the identityTransformStreamkeeps the smaller native streams. A web stream in a later compose stage is unsupported.stream.isDestroyed,isErrored,isDisturbed,isReadable, andisWritable, andReadable.isDisturbed, answer for thenode:streamclasses and their subclasses, for file and zlib streams, for an untyped value that holds one of those, and for primitives. For any other value, such as a plain object, a web stream, a socket, an HTTP message, or a process stream, they throw a not-supported error, and for a child-process stream they answer only about the side the stream has.readableAborted,readableDidRead,readableEncoding, andwritableAbortedread as in Node, on a typed stream and through an untyped value.writableAbortedisundefinedon aDuplex,Transform, orPassThrough, as in Node, so abooleanslot refuses that read with a TypeError.stream[Symbol.asyncDispose]()andawait usingwork on a value typed as a stream class; on an untyped value they are unsupported.stream.setDefaultHighWaterMark,stream.duplexPair,readable.wrap,Readable.toWeb,Writable.toWeb,Writable.fromWeb,Duplex.fromWeb, andDuplex.toWebare unsupported. TheERR_INVALID_ARG_VALUEmessage for a stream that is no longer readable or writable names the stream's class instead of printing the stream.readable.compose(stage, { signal })isstream.compose(readable, stage)with the signal added; the options are an object literal whosesignalis a variable or a property read.pipelinefromnode:stream/promisesaccepts a trailing{ signal, end }object, with or without function stages, andfinishedacceptsreadable,writable,error,cleanup, andsignaloptions, with boolean literals for the flags. Stream constructors accept asignaloption in an options object literal, andstream.addAbortSignalaccepts any stream. Theconstructoption and_constructmethod,decodeStrings, anddefaultEncodingwork on every stream class, and thewritevoption and_writevmethod on every class with a writable side. AdecodeStringsordefaultEncodingvalue known only at run time is unsupported after an option member whose value has effects (a call or an assignment). In typed code, awriteventry'sencodingdeclared as a string receives""where Node passesundefinedornull(an object-mode write).setDefaultEncoding()takes any encoding Node knows.node:readlineandnode:readline/promises(also reached asreadline.promises) interfaces, fromcreateInterface(options)orcreateInterface(input, output, completer, terminal), readprocess.stdinor a readable stream:question,prompt,write(with a key object literal ofname,ctrl,meta, andshift),pause,resume,'line'/'close'/'pause'/'resume'/'error'/'history'/'SIGINT'/'SIGTSTP'/'SIGCONT'listeners, andfor awaitcompile.on,once, andaddListenerreturn the interface, so registrations chain. Thehistory,historySize,removeHistoryDuplicates,completer,tabSize, andescapeCodeTimeoutoptions are validated as in Node. Withterminal: true, or with noterminaloption andprocess.stdoutas the output when it is a TTY, the interface runs Node's terminal mode: the editing keys, the kill ring, undo and redo, history recording and recall, Tab completion through the completer, Ctrl+C, Ctrl+D, and Ctrl+Z,TERM=dumb, redrawing the prompt and line when the output's'resize'event arrives, and the same escape sequences written to the output. The cursor never stops between the two UTF-16 units of a supplementary character: where Node's Up or Down movement through a multiline line would, the cursor moves to the character's start or end. A'history'listener receives the interface's history array itself: the same objectrl.historyanswers, in typed and JavaScript code alike. A change the listener makes lands in that array, so an entry it removes never reaches recall or the later history.rl.history,historySize,historyIndex,crlfDelay,tabSize,escapeCodeTimeout,line,cursor, andterminalread as in Node;rl.cursorisundefinedon an interface that is not a terminal.rl[Symbol.dispose]()closes the interface, andinstanceofwithreadline.InterfaceorreadlinePromises.Interfaceanswers whether the interface came from that module, as in Node. In JavaScript, the input and output can be any expression that evaluates to a stream, such as a function's result or an object's member; a value that is not a stream is unsupported.readline.cursorTo,moveCursor,clearLine, andclearScreenDownwrite toprocess.stdout,process.stderr, a writable stream, or nothing fornullandundefined; their callbacks take no parameters. Thereadline/promisesReadlineclass writes to the same outputs.readline.emitKeypressEventsemits'keypress'events onprocess.stdinor a readable stream, shared with terminal interfaces on that stream as in Node; a listener's first parameter must admitundefined, which it receives for escape sequences. Chained listener registration is unsupported.node:stream/webexports the same classes as the globals; in TypeScript,ReadableStream,WritableStream, andTransformStreamhave lowerings. In JavaScript,ReadableStream,WritableStream, andTransformStreamwith their default readers, writers, and controllers,CountQueuingStrategy,ByteLengthQueuingStrategy,TextEncoderStream, andTextDecoderStream, as globals and asnode:stream/webexports, are constructor values with Node's prototypes, brand checks, and errors. Their underlying sources, sinks, and transformers, queuing strategies with asizefunction, readers and writers,tee,pipeToandpipeThroughwith their options and an abort signal,ReadableStream.from, and async iteration settle promises in Node's order, and the streams take own properties.TextDecoderStreamdecodes UTF-8; its other encodings are unsupported. A JavaScriptReadableStreamgiven as aResponseorRequestbody, or asfetch's body, is read through a stream of its own:response.bodyis that stream rather than the one passed in, and the stream passed in is locked from the start. In JavaScript, aResponseorRequestbody has the members of aReadableStream, includingtee,pipeTo,pipeThrough,values, andfor await, and its lock andbodyUsedfollow them. After one of those members is used, a body given to a newResponseorRequestis locked from the start, as a JavaScriptReadableStreamis. In a program that names none of the web stream classes, those members are available when the program's JavaScript names one of them or iterates a body withfor await; reached only through a computed key, they are not. In JavaScript, a byte stream (type: 'bytes'), a BYOB reader, a class that extends one of these classes,Object.getPrototypeOfon these values, their use asWeakMapandWeakSetkeys, andReadableStream.fromof a function that is not iterable are unsupported. - HTTP/2: Server push is not implemented:
pushStream,createPushResponse, and the'push'event are refused. A client says so in its settings (ENABLE_PUSH = 0), so itslocalSettings.enablePushand the server'sremoteSettings.enablePushfor it arefalsewhere Node reportstrue. On the compatibility response,'finish'listeners run whenend()returns rather than when the stream closes, so they run before the request's'close'and before anend()callback, and a response that never ended emits no'finish'. Trailers,goaway(), timeouts,respondWithFile, and the stream and sessionstaterecords are refused; on a session or stream that reached untyped code they throw instead of being ignored. Aping()callback declares its duration and payload optional, because a cancelled ping calls back with the error alone, as in Node. A settings record withcustomSettingsis refused, insession.settings()and ingetPackedSettings()(where Node 24 answersundefined). - CommonJS metadata: The module graph is fixed at build time.
Cache deletion or reloading, metadata writes,
module.pathsmutation, andrequire.extensionsare unsupported. Read-only access tomodule.id,filename,path,paths,loaded,isPreloading,parent,children,require.main, andrequire.cachelookup/enumeration compiles. - ESM metadata: Native
import.meta.url,filename,dirname, andmainsupport dot access, statically known keys, and destructuring selected fields. Storing or mutating the metadata object, rest bindings, runtime keys, and storedresolvecallbacks are unsupported. Nativeimport.meta.resolve()requires a literal specifier. Module instances distinguished by URL query strings or fragments are unsupported. - Date: Spread constructor arguments are unsupported; the locale formatters take the locales and options that
Intl.DateTimeFormattakes (see Intl.NumberFormat and Intl.DateTimeFormat). Dates are objects with identity:===and==compare identity,new Date(date)makes a new Date, setters change the one Date every reference holds, and Dates compile in arrays (includes,indexOf,lastIndexOf,join, and defaultsortbytoString()text), in unions with other types, as Map and Set keys and values, and in records, tuples, class fields, closures, promises and generators. Thrown and rejected Dates keep their identity;structuredCloneandpostMessagecopy them. Zero-argument, single number/string, and local-time year/month field constructors,getTime,valueOf,toISOString,toUTCString,toJSON(astring | null: null for an invalid date, as in Node),toString,toDateString,toTimeString,toLocaleString(),toLocaleDateString()andtoLocaleTimeString()(without arguments: the default locale's ICU patterns over the host time zone, as Node prints them), the local and UTC calendar getters and setters,setTime,getTimezoneOffset, and single-stringDate.parsecompile. Unary+,-andNumber(date)read the time value;String(date), template literals and+with a string read thetoString()text;date[Symbol.toPrimitive](hint)compiles with a literal hint. A Date converted tounknownis the same Date object. See Dates and timezones for timezone data. - URL: Absolute inputs and relative inputs with runtime string or URL bases, including optional bases, compile.
URL.canParse,URL.parse,toString(), andtoJSON()compile; the factories use the same parser as construction, returningfalseornullfor rejected inputs while preserving conversion errors.href,protocol,username,password,host,hostname,port,pathname,search, andhashsupport assignment in native code. Invalid component writes are ignored except for invalidhrefvalues, which throw; credentials are percent-encoded and ports accept valid leading digits. Native URL assignments require statically known property keys;+=accepts primitive operands, while other assignment operators and object operands for+=are refused.originis read-only.searchParamsis a live view whose identity survives query and URL replacement. - Legacy URL API:
url.parse(),url.format(),url.resolve(),url.domainToASCII(), andurl.domainToUnicode()compile, including Punycode hostnames and theDEP0169/DEP0170warnings. A parsedUrlobject supports reads, writes, and itsformat()method; itsparse(),resolve(),resolveObject(), andparseHost()methods throwSC2020, andurl.Urlandurl.resolveObject()are unsupported.ERR_INVALID_URLerrors have noinputproperty. - Deprecated
punycodeandconstantsmodules:punycode.encode(),decode(),toASCII(),toUnicode(),ucs2.decode(),ucs2.encode(), andversioncompile, with theDEP0040warning Node.js reports when the module loads. Arequire("punycode")made from insidenode_modulesdoesn't warn; arequire()used inside a larger expression, such asrequire("punycode").toASCII(name), doesn't warn either. Thepunycode.ucs2object itself is unsupported as a value. Theconstantsmodule is the frozen object Node.js builds fromos.constantsandfs.constants, plus thecrypto.constantsof Node.js 24.22.1. - Filesystem flags:
fs.openSyncsupports inline bitwise OR expressions ofO_RDONLY,O_WRONLY,O_RDWR,O_CREAT,O_EXCL,O_NOFOLLOW,O_NONBLOCK,O_TRUNC, andO_APPEND, with an optional creation mode. Computed numeric flags are unsupported because bit values vary by target.fstatSync,fchmodSync,fsyncSync, andlinkSyncsupport direct calls. On Windows, numeric opens withO_NOFOLLOWand calls tofchmodSyncthrowENOSYS; use a POSIX target if you require these operations. - Filesystem URL paths:
fsandfs.promisesfunctions acceptfile:URL paths and convert them asfileURLToPathdoes;existsSyncanswersfalseand thefs.promisesfunctions reject for a URL that does not convert. A URL path with options that are not literals is refused where Node checks those options before it converts the URL, except areadFileSyncencoding.fs.promisesfunctions also refuse a string path before a URL path; passfileURLToPath(url)instead. In JavaScript, an untyped path of a synchronousfsfunction is checked as Node.js checks it: a string, afile:URL or aUint8Arrayis the path, and any other value throws Node'sERR_INVALID_ARG_TYPE.readFileSync,writeFileSyncandappendFileSynctake a file descriptor only as a statically typed number; a number passed through an untyped value throwsSC2020. AUint8Arraypath must hold UTF-8 text; other bytes, which Node.js hands to the system unchanged, throwSC2020.existsSync,realpathSync,truncateSync, the callback functions andfs.promisesreport an untyped path that is not a string with aTypeErrorthat has nocode. - Copy:
fs.cpSync,fs.cp, andfs/promisescpsupport every option and follow Node's two implementations:cpSyncreports the native binding's errors, and the callback and promise forms reportSystemErrors. Files, directories, and symbolic links are copied in directory order, as in Node. The callback and promise forms complete the copy before the callback runs or the promise settles. An asyncfiltermust return a promise that is already settled; a pending one throwsSC2020. On Windows, the three functions throwSC2020. - Glob:
fs.globSync,fs.globandfs/promisesglobsupport every option.withFileTypesmust be a literaltrueorfalse, andexcludefunctions cannot be combined withwithFileTypes. Thefs/promisesiterator is supported only as the source of afor awaitloop, and its walk completes when the loop starts.fs.globcallbacks receive file names, not Dirents. - FileHandle and descriptor I/O: Static reads and writes accept Buffer and Uint8Array windows, numeric positions, and UTF-8 strings.
FileHandle reads also accept options records and allocate a buffer when omitted.
Vector I/O, truncation, syncing, and permission changes compile.
Ownership changes, timestamps, and bigint Stats remain unsupported; FileHandle streams and
readLinesare covered under File streams. Dynamic descriptor I/O accepts other ArrayBuffer views and Buffer encodings; read positions outside the safe integer range are refused. File operations complete synchronously before their callbacks or promise continuations. Descriptor permission changes on Windows throwENOSYS. - File streams:
fs.createReadStream,fs.createWriteStream,new fs.ReadStreamandnew fs.WriteStream(in JavaScript sources), and FileHandlecreateReadStream,createWriteStreamandreadLinesreturn Readable and Writable streams. Options are checked when the stream is created, with Node's errors and order;flagsandmodeare checked when the file opens, so their errors arrive as'error'events.bytesRead,bytesWritten,path,pending,close(),close(callback)with a() => voidcallback, and the'open'and'ready'events compile. Thesignaloption destroys the stream with anAbortErrorwhen the signal aborts, asstream.addAbortSignaldoes. As in Node, a signal that is already aborted destroys the stream when it is created and the file is still opened afterwards, so'open'and'ready'follow'close'and that descriptor stays open. A program links that support when the options of one of its file streams writesignalor have a type that can hold it,anyandunknownincluded; in any other program, a signal that still reaches a file stream inside a wider object, behind an options type withoutsignal, throws when the stream is created. Numericflags, thefsandwindowsHandleoptions, write streams with an encoding other than UTF-8, andinstanceof fs.ReadStreamorfs.WriteStreamare unsupported. - File watching:
fs.watchreturns anFSWatcherwhoseon,once,off, andclosetakechange,rename,error, andcloselisteners. A listener may take the event name and the entry name, but the name arrives as a string (Node's default encoding), so a listener annotated with theBufferarm of@types/node'schangeoverload has no lowering. Watching a directory on macOS with a listener that reads the entry name is refused withSC2020because FSEvents is not implemented yet; file watches and listeners that ignore the name work on every target. - Stat polling:
fs.watchFilepolls the resolved path everyintervalmilliseconds (default 5007) and calls its listener with(current, previous)Stats;fs.unwatchFileremoves the last listener registered with that callback, or every listener when called without one. The call must be a statement of its own, because theStatWatcherit returns in Node.js is not lowered, andbigint: trueis refused. - Crypto: Hashing, HMAC, PBKDF2, and HKDF support every digest
crypto.getHashes()lists in Node 24, with OpenSSL's aliases and object identifiers. Hash and Hmac accept every Buffer encoding and any TypedArray or DataView,createHashandhash.copytakeoutputLength, andcrypto.hashtakes its options object; HMAC, PBKDF2, and HKDF reject the SHAKE and KMAC digests with Node's errors. Hash and Hmac values are also Transforms: they can be written, piped into, used aspipeline()stages, read, and listened to, and they report Node's errors after the stream flushes.copy()of a Hash whose stream flushed, and stream use of a value after its stream closed, throw a coded SC2020 error. Throughunknownandanyslots and untyped JavaScript, Hash and Hmac values keep their identity and supportupdate(),digest(), and Hash'scopy(), called or read as values; their stream and event members there throw a coded SC2020 error.timingSafeEqualcompares any view or ArrayBuffer. Secret KeyObjects (createSecretKey,generateKeyandgenerateKeySyncforhmacandaes) supporttype,symmetricKeySize,export(),equals(), andinstanceof KeyObject, and createHmac, hkdf, createCipheriv, and createDecipheriv accept them;KeyObject.from()andtoCryptoKey()are not available.randomFill,randomFillSync(every view kind and ArrayBuffer),randomInt,randomUUID, andrandomUUIDv7follow Node 24.22, including callback timing; arandomIntcallback whose error parameter is typedError | nullreceivesnullwhere Node passesundefined. Scrypt supports its default parameters, numeric options, aliases, and memory limit. Both KDFs accept strings, Buffers, numeric typed arrays, DataViews, and fixed-length ArrayBuffers.createCipherivandcreateDecipherivsupport aes-128, aes-192, and aes-256 in CBC, CTR, GCM, CCM, ECB, CFB, CFB8, CFB1, and OFB modes and as key wrap (the wrap and wrap-pad ciphers and their -inv forms), des-ede3 in CBC, ECB, CFB, CFB8, CFB1, and OFB modes, des-ede in CBC, ECB, CFB, and OFB modes, chacha20, and chacha20-poly1305, on native targets, throughupdate(),final(),setAAD(),setAutoPadding(),getAuthTag(), andsetAuthTag(); other ciphers and wasm32-wasi builds are refused.getCipherInfoanswers Node's info for every cipher OpenSSL names, including the ones without a native implementation.getCipherInfooptions whose class defineskeyLengthorivLengththrow a coded SC2020 error. The result is Node's object; the SIV ciphers and the SM4 GCM, CCM, and XTS ciphers have nonid, and reading it where the declaredCipherInfotype givesnumberthrows a TypeError. Cipheriv and Decipheriv values are also Transforms: they can be written, piped into, used aspipeline()stages, read, iterated withfor await, and listened to, and their stream properties read as in Node; written chunks go throughupdate(), and the end pushesfinal()or reports its error through'error'. Throughunknownandanyslots and untyped JavaScript, in a program that uses streams, their stream properties and theiron,once,off,pipe,unpipe,read,pause,resume,setEncoding,write,end,destroy,cork, anduncorkmembers work;writeandendtake no encoding or callback there, and the other stream members throw a coded SC2020 error. Hash, Hmac, Cipheriv, and Decipheriv streams count a written string's bytes inwritableLength, where Node counts the string's length. Decrypting chacha20-poly1305 without an authentication tag fails infinal(); Node 24.22 returns unverified plaintext. Afterupdate()fails, for example past the AES-GCM limit of 2^36 - 32 bytes per message, every later call on that cipher throws; Node still letsfinal()run. An output encoding that is a function or an instance of a class definingtoStringthrows a coded SC2020 error.createECDHandECDH.convertKeysupport prime192v1, secp224r1, prime256v1, secp384r1, secp521r1, secp192k1, secp224k1, secp256k1, brainpoolP256r1, brainpoolP384r1, and brainpoolP512r1, on native targets, throughgenerateKeys(),computeSecret(),getPublicKey(),getPrivateKey(),setPrivateKey(), andsetPublicKey(), in compressed, uncompressed, and hybrid forms; the other curvescrypto.getCurves()lists and wasm32-wasi builds are refused. A call on an ECDH value whose arguments no @types/node overload accepts (getPublicKey("HEX")) is refused at compile time, as iscomputeSecret(view, encoding): Node reads that encoding as the input encoding and answers a Buffer where @types/node declares a string. ECDH property reads and writes throw a coded SC2020 error.createDiffieHellman,getDiffieHellman, andcreateDiffieHellmanGroupsupport the modp1, modp2, modp5, and modp14 through modp18 groups, explicit primes and generators, and generated safe primes, on native targets, throughgenerateKeys(),computeSecret(),getPrime(),getGenerator(),getPublicKey(),getPrivateKey(),setPublicKey(),setPrivateKey(), andverifyError, with Node's private key lengths, DH_check results, and errors; wasm32-wasi builds are refused. Primes longer than 8192 bits throw a coded SC2020 error; Node accepts primes up to 10000 bits for key generation and secrets.setPublicKey()andsetPrivateKey()keys longer than 80000 bytes, not counting leading zero bytes, throw a coded SC2020 error, as does a generator that long with a prime below 512 bits; Node accepts them. A call on a DiffieHellman value whose arguments no @types/node overload accepts, or whose output encoding is typedany, is refused at compile time, as are itsObject.prototypemethods; other property reads, and property writes, throw a coded SC2020 error.Object.keys()andindo not see a DiffieHellman's ownverifyErrorproperty, andJSON.stringify()andinstanceofare refused. AftercreateDiffieHellman(primeLength)throwsInvalid DH parameters, the next OpenSSL error Node throws can list the failed generation's errors inopensslErrorStack; errors in a compiled binary list only their own. The error for key material that no decoder accepts has Node'slibrary,reason, andopensslErrorStack, whose last entry is the reported error. When a PEM body begins with a valid structure and fails further in, the entries OpenSSL lists before that last one are missing, and a malformed public key or DER input is reported asERR_OSSL_UNSUPPORTEDwhere Node reports the ASN.1 parser's own code.crypto.diffieHellmancomputes ECDH and X25519 secrets from EC and X25519 keys, given as KeyObjects or in any formcreatePrivateKeyandcreatePublicKeyread, with Node's errors; DH keys have no KeyObjects here, and theDiffieHellmanandDiffieHellmanGroupconstructors are not available.checkPrime,checkPrimeSync,generatePrime, andgeneratePrimeSyncsupport bigint, ArrayBuffer, typed-array, Buffer, and DataView values and thechecks,safe,add,rem, andbigintoptions on native targets, with Node's errors; the callback forms compute before they return and call back in a later macrotask. Candidates and sizes longer than 262144 bits throw a coded SC2020 error, and wasm32-wasi builds are refused. Node calls their callbacks withundefinedas the error, which a callback whose error parameter is typedError | null, as @types/node declares it, receives asnull. RSA, RSA-PSS, EC, Ed25519, and X25519 private and public KeyObjects come fromgenerateKeyPairSync,generateKeyPair,createPrivateKey, andcreatePublicKey, on native targets.generateKeyPairSyncandgenerateKeyPaircheck their arguments in Node's order, with Node's errors, including the OpenSSL errors for RSA modulus lengths below 512 or above 2147483647 bits and for public exponents of 0, 1, or an even number, whichgenerateKeyPairpasses to its callback. RSA keys generate with modulus lengths from 512 to 8192 bits, an odd length from 2048 bits yielding one bit less as in Node, and odd public exponents up to 4294967295; longer moduli that Node accepts, andparamEncoding: 'explicit', throw a coded SC2020 error. The EC curves are prime256v1 (P-256), secp384r1 (P-384), secp521r1 (P-521), and secp256k1. Keys read and write PEM and DER as PKCS#1, SEC1, PKCS#8, and SubjectPublicKeyInfo, and JWK (Ed25519 and X25519 keys use PKCS#8, SubjectPublicKeyInfo, and JWK);createPublicKeyalso takes a private key or an X.509 certificate. EC, Ed25519, and X25519 keys also read and write theraw-publicandraw-privateformats, including compressed EC points. Raw X448, Ed448, and post-quantum keys, EC scalars of 0 or at least the curve order, and the EC point at infinity, which Node accepts, throw a coded SC2020 error. They supporttype,asymmetricKeyType,asymmetricKeyDetails,export(),equals(), andinstanceof KeyObject.crypto.sign,crypto.verify,createSign, andcreateVerifysupport RSA PKCS#1 v1.5 and PSS padding and ECDSA with DER and IEEE P1363 encodings over SHA-1 and SHA-2 digests, and Ed25519 throughcrypto.signandcrypto.verifywith anullorundefinedalgorithm. RSA-PSS keys follow their RSASSA-PSS-params as Node does: PSS padding only, the key's digest and MGF1 digest, and salts of at least the key's length, with OpenSSL's errors; their details name the parameters, they export as PKCS#8 and SubjectPublicKeyInfo only, and digests other than SHA-1 and SHA-2 in their options throw a coded SC2020 error. Ed25519 signing, verification, and private keys link when a string literal in the program namesed25519(in any case); without one they throw a coded SC2020 error, while Ed25519 public keys still import and export. X509Certificate supportspublicKey,verify(),checkIssued(),checkPrivateKey(),checkHost(),checkEmail(),checkIP(),toLegacyObject(),toString(), andtoJSON(), andString(), template literals, and+give its PEM text astoString()does.publicKey,verify(), andcheckPrivateKey()are refused in wasm32-wasi builds, and an Ed25519 certificate'sverify()needs theed25519literal like the other Ed25519 operations. Own-key walks over a certificate (Object.keys(),Object.entries(), spread,for...in, andhasOwnProperty) are refused, since Node keeps its fields as prototype getters.JSON.stringify()andconsole.log()of a certificate, a certificate stored in anunknownoranyslot, and its methods on a union-typed value are also refused. Sign and Verify values are Writable streams:write()accumulates data asupdate()does,end()finishes the stream, andpipe()can pipe into one; they have no Readable side, as in Node. Private keys export encrypted (cipher,passphrase) with aes-128, aes-192, and aes-256 in CBC and ECB modes and with des-ede3-cbc, PKCS#8 as PBES2 with PBKDF2-HMAC-SHA256 and PKCS#1 and SEC1 as traditional PEM, and the ciphers OpenSSL refuses for a form throw its errors; a cipher option can also be an OID; other ciphers Node encrypts with throw a coded SC2020 error. Encrypted private keys import with apassphrasefrom PBES2 with HMAC-SHA PRFs and the CBC and ECB ciphers, and from traditional PEM with the CBC ciphers, with Node's errors for a missing or wrong passphrase; other schemes and ciphers throw a coded SC2020 error once a passphrase is given. The other key types (dsa,ed448,x448, and the rest) and wasm32-wasi builds throw a coded SC2020 error or are refused. Comparing keys of different types withequals()answers false; Node also leaves an OpenSSL error queued, which a later key operation can report.publicEncrypt/privateDecryptremain unsupported. The WebCryptocryptoglobal, which node:crypto also exports aswebcrypto, supportsrandomUUID()andgetRandomValues(), also read as values from untyped JavaScript. Itssubtleobject, also node:crypto'ssubtleexport, supportsgenerateKey()andexportKey()for HMAC and AES keys,importKey()for HMAC, AES, PBKDF2, and HKDF keys,encrypt()anddecrypt()with AES-GCM, AES-CBC, and AES-CTR andwrapKey()andunwrapKey()of secret keys with AES-KW or those ciphers on native targets,deriveBits()andderiveKey()with PBKDF2 and HKDF, HMACsign()andverify(), and SHA-1 and SHA-2digest(). Secret keys import and export in theraw,raw-secret, andjwkformats.generateKey(),importKey(),exportKey(),sign(), andverify()also support ECDSA (P-256, P-384, and P-521), Ed25519, RSASSA-PKCS1-v1_5, and RSA-PSS, with thespki,pkcs8, andjwkformats andrawfor ECDSA and Ed25519 public keys; ECDSA, Ed25519, and RSA are refused in wasm32-wasi builds. ECDSA, Ed25519, and RSA link when a string literal in the program names the algorithm; a name built only at run time throws a coded SC2020 error.wrapKey()andunwrapKey()of ECDSA, Ed25519, and RSA keys throw a coded SC2020 error. Other SubtleCrypto methods, algorithms, and key formats are refused or throw a coded SC2020 error. Native derivations finish before their deferred callbacks, so computation blocks the caller. - Assertions: Assertion failures throw
assert.AssertionErrorwith Node'smessage,generatedMessage,code,actual,expected,operator, anddiffproperties.new AssertionError(options),instanceof, andassert.throws(fn, AssertionError)compile. WhenstrictEqualcompares function values,actualandexpectedread asundefined; whenassert.throwsorassert.rejectsreports an error that is not an instance of the expected class, or that does not match an expected object,expectedreads asundefined. Values whose type can be cyclic, such as recursive records, also read asundefined.assert.AssertionErrorused as a value outsideinstanceofthrowsSC2020. The comparison methods,ok,failandifErrorare function values that assert as the methods do; called through a stored value,okwithout a message reportsvalue == true, where Node quotes the call, andfailtakes at most one argument.throws,rejects,doesNotThrow,doesNotReject,matchanddoesNotMatchas values throwSC2020.strictEqualandnotStrictEqualcompare a number, string or boolean that can benullorundefined, such aschild.signalCode, with any number, string, boolean,nullorundefined.notStrictEqualof another value that can benullorundefined, such aschild.stdin, againstnullorundefinedcompiles;strictEqualof one throwsSC2020.assert.deepEqualandassert.notDeepEqualfollow Node's loose comparison, including Maps, Sets, Dates, regular expressions, typed arrays, and errors; operands whose type can be cyclic or holds functions inside a structure are refused.assert.partialDeepStrictEqualfollows Node's partial comparison over the same values, with the same refusals. Checked-dynamic values compared deeply have no cycle detection. Errors in failure messages print as[Name: message], where Node prints the stack when only one side is an error.new Assert(options)compiles when it initializes aconstwith literaldiff,strictandskipPrototypeoptions, or none, and the binding is only used to call assertion methods. Other instances, such as ones passed as values, destructured, bound withlet, or built from options that are not a literal, throwSC2020. WithskipPrototype,deepStrictEqualandnotDeepStrictEqualcompare class instances, and operands of different static types, as checked-dynamic values. - Concurrent tests: with
{ concurrency }above 1, subtests run on their own fibers, and results are reported in declaration order, as in Node. Concurrent bodies resume in Node's order aroundbeforeEachhooks and nested suites. Other runner steps, such asafterEachandafterhooks, take no microtask turns between bodies, so code that observes the interleaving of concurrent bodies across those steps can see a different order than Node. - Snapshots:
t.assert.snapshotandt.assert.fileSnapshotcompile, with Node's default serializer,JSON.stringify(value, null, 2), or anoptions.serializersarray literal. A compiled test reads the snapshot file Node writes beside the entry file,<entry file>.snapshot, at the entry file's path when the program was compiled. Running the binary with Node's flag--test-update-snapshotsas its first argument writes the snapshot files instead; as in Node, the flag is kept out ofprocess.argvand appears inprocess.execArgv. Snapshot files are read in the form Node writes them,exports[`key`] = `value`;statements. Thesnapshot.setDefaultSnapshotSerializersandsnapshot.setResolveSnapshotPathmodule functions throwSC2020. - Reporters: the binary writes the spec report, so
--test-reporter=specis the only reporter it takes, and any other name ends the run before the tests start withscriptc: unknown test reporter '<name>': only the spec reporter is supported.--test-reporter-destination=stdout, its default, sends the report to stdout,stderrsends it to stderr, and any other value names the file the binary writes the report to; the program's own output stays on stdout in every case. As in Node, both options are leading arguments, in any order, kept out ofprocess.argvand listed inprocess.execArgv. A file destination that cannot be opened ends the run the same way, withscriptc: cannot open test reporter destination '<path>': <reason>. - TestContext values:
t.filePathis the entry file's path when the program was compiled.t.attemptis0, since a test runs once.t.passedisfalsewhile the body runs and the test's outcome in itsafterEachandt.afterhooks.t.workerIdisNumber(process.env.NODE_TEST_WORKER_ID) || undefined, as in Node.t.tagsis[], since thetagstest option throwsSC2020; the array is not frozen as Node's is. - Suite and hook contexts: a
describebody may take itsSuiteContext, which hasname,fullName,filePath,attempt,passedanddiagnostic. Hooks may take their context, as in Node: the suite's forbeforeandafter, the test's forbeforeEach,afterEach,t.beforeandt.after. TheSuiteContextsignalandlogmembers, and hookdonecallbacks, throwSC2020. - Module-level hooks:
beforehooks outside any suite run at theirbefore()call, and the first top-level test waits for the async ones;afterhooks outside any suite run after the last top-level test. Both get the root's context, named<root>. As in Node, a throwing rootbeforefails each top-level test with its error, without running its body, and cancels the tests and suites inside each top-level suite. A throwing rootafterreports the entry file as a failed result, and the exit code is unchanged. - Timeouts: when a test's
{ timeout }elapses, its running subtests are cancelled, as in Node. Subtests do not take their parent'stimeoutas their own, where Node's do, and the subtests of a timed-out test with{ concurrency }above 1 run to completion before the test reports. A body that keeps running after its timeout and callst.testagain runs that subtest, where Node reports it as not started. - Thrown values: a test that throws a value that is not an
Errorreports it in the failing section asutil.inspectrenders it, as Node does, for strings, numbers, booleans, objects, arrays,nullandundefined. A thrown class instance that is not anError, such asthrow new Point(1, 2), reports[object Object], where Node printsPoint { x: 1, y: 2 }. - Test names: a test without a name, or with an empty one, takes its function's name or
<anonymous>, as in Node, when the function's name is known at compile time: a function expression, a function declaration, or aconstbound to an arrow or anonymous function. A name computed at run time, with a function the program received as a parameter, is used as given, so an empty one stays empty where Node uses the function's name.test(fn)andtest("", fn)with such a function throwSC2020. - Current context:
getTestContext()returns the context of the test, suite or hook whose code is running, as in Node:undefinedat module top level, the root's context in module-level hooks, the suite's in a suite body and in the suite's hooks, and the test's in its body, in the code it awaits, and in the timers, immediates,process.nextTickandqueueMicrotaskcallbacks it schedules. Node returns, for a suite, aTestContextthat is a different object from theSuiteContextpassed to the suite body and itsbeforeandafterhooks; in a compiled program they are the same object, so comparing them with===givestrue. Completion callbacks of callback-style I/O APIs, such asfs.readFile, getundefined, as AsyncLocalStorage stores do. - Test mocks:
mock.fn,mock.method,mock.restoreAllandmock.resetcompile, on the module'smockand ont.mock.mock.methodmocks a function-valued field of a record, such as an object literal or an interface-typed object. Class instances, builtin objects, and object literals whose methods usethisthrowSC2020. Calls through the object record it asthis, including calls of a method read off the object and called on its own, where Node recordsundefined.object.method === mockisfalse, because the field holds a wrapper of the mock.mock.fn()without an original returnsundefinedand records the arguments of each call, as in Node; with a function type whose return type does not includeundefined, such asmock.fn<() => number>(), it throwsSC2020. A mock function'smockcontext is a non-enumerable own property of the returned function, sotypeofis"function"andObject.keysis empty as in Node;"mock" in mockFnandObject.getOwnPropertyNamessee the property, where Node's proxy hides it.mock.getter,mock.setter,mock.property,mock.moduleand mock options throwSC2020. - Mock timers:
mock.timers.enable,tick,runAll,reset,setTimeand[Symbol.dispose]()compile, on the module'smockand ont.mock, for thesetTimeout,setInterval,setImmediate,Date,scheduler.waitandAbortSignal.timeoutAPIs.enable()takes no options or an object literal whoseapis, when given, is an array literal. Options andapislists that are not literals, and theMockTimersobject used as a value, throwSC2020. As in Node, the global timer functions,Date.now(),new Date()andscheduler.waitare mocked, and other calls through named and namespace imports ofnode:timersandnode:timers/promisesuse real timers. As in Node, once a reset givesscheduler.waitback, calling it throwsERR_INVALID_THIS. Whilescheduler.waitis mocked, calling it with asignaloption throws anSC2020error. A mock timer's handle converts to a negative number, where Node's mockTimeoutconverts toNaN. When two trackers have timers enabled, clearing a timer through the tracker that did not create it leaves the timer queued, where Node removes the entry at the same queue position in the clearing tracker. - Exit status: Numeric
process.exitCode = valuewrites in statement position set the implicit exit status, whichprocess.exit()uses when called without an argument.process.exit(code)andprocess.exitCodethrow aRangeError(ERR_OUT_OF_RANGE) for a code that is not a safe integer, and convert other codes to int32, as Node does. Readingprocess.exitCodeanswers the assigned code, orundefinedbefore any assignment;process.exit(code)assigns it before the'exit'listeners run. Resets (process.exitCode = undefined) and assignments used as values are unsupported. - Process memory:
process.memoryUsage()readsrssfrom the operating system andheapTotalandheapUsedfrom the runtime's allocator, so the heap figures start near zero and grow as the program allocates.arrayBuffersis the storage of the ArrayBuffers, typed arrays, Buffers, DataViews and SharedArrayBuffers the program holds, andexternalis the same storage without SharedArrayBuffers, as in Node. Node also counts its own startup allocations in both, so a program that holds no such storage reports0where Node reports a few megabytes. In a program with worker threads,externaland the non-shared part ofarrayBufferscount the calling thread's storage. The storage comes from the same allocator, so it also counts inheapTotalandheapUsed. - V8 heap statistics:
node:v8can be imported.v8.getHeapStatistics()returns Node's fields in Node's order, computed from the runtime allocator likeprocess.memoryUsage():total_heap_sizeandtotal_physical_sizeare the bytes the heap holds,used_heap_sizethe bytes allocated,external_memorythe same figure asprocess.memoryUsage().external,heap_size_limitthe machine's memory (the heap has no fixed ceiling), andtotal_available_sizethe limit minus the used bytes. Fields that describe V8 itself (total_heap_size_executable,malloced_memory,peak_malloced_memory, the global handle sizes, anddoes_zap_garbage) are0, andnumber_of_native_contextsis1. The values are approximate and are not V8 heap figures. The othernode:v8members observe the V8 engine, such as heap snapshots, profiles, flags, and serialization, and throwSC2020where they are used. - Performance entries:
performance.mark(),measure(), and thegetEntriesmethods return entries with Node's fields,toJSON(), inspection, and identity.Object.keys,for...in, object spread, andhasOwnPropertyon an entry are unsupported, and an entry stored in anunknownslot prints as a plain object. - Event-loop metrics:
performance.eventLoopUtilization()counts the main thread's CPU time since the event loop started as active time, so blocking system calls count as idle where Node counts them as active.monitorEventLoopDelay()supportsenable(),disable(),reset(),percentile(), and themin,max,mean,stddev,count, andexceedsreadings; the BigInt readings,percentiles, and non-literal option objects are unsupported. - Builtin module lookup:
process.getBuiltinModule()with a string-literal id that@types/nodetypes as a supported module answers that module, as an import of it does, also behind?.. With any other id it exposes native subsets ofpath,path/posix,path/win32,os,util/types,node:sea, and current-threadworker_threadsmetadata, and answersundefinedfor an id Node.js does not have. Stored module references and functions retain identity. Other modules and exports, including storedWorkerconstructors, throwSC2020. DirectWorkerimports use the native worker support described below.process.versionsis a shared dictionary containingnodeandopenssl; other component versions are absent unless defined by the program. - Compile cache:
module.enableCompileCache()answers{ status: module.constants.compileCacheStatus.DISABLED, message }and creates no directory, because a compiled program loads no JavaScript whose compiled form could be cached. Themessageis Node.js's own whenNODE_DISABLE_COMPILE_CACHEis set, and otherwise says that a compiled program has no compile cache.module.getCompileCacheDir()answersundefinedandmodule.flushCompileCache()writes nothing. The calls validate their arguments as Node.js does, and they never start Node.js in a program that has a Node island. - Single executable applications: a compiled program is not a Node.js single-executable application, so
node:seaanswers what Node.js answers outside one.isSea()isfalse, andgetAsset(),getRawAsset(),getAssetAsBlob(), andgetAssetKeys()check their arguments and then throwERR_NOT_IN_SINGLE_EXECUTABLE_APPLICATION. - ArrayBuffers and typed arrays: Fixed-length ArrayBuffers support shared typed-array and DataView storage.
Resizing and transferring are unsupported.
Typed code cannot construct
BigInt64ArrayorBigUint64Array; JavaScript that names either one gets the checked-dynamic element kinds, where elements are BigInts.Float16Arraystores IEEE 754 half-precision values, rounding each stored number to nearest-even as Node does;Math.f16round,DataView.prototype.getFloat16andsetFloat16, andutil.types.isFloat16Arraycompile. The typed-array callback methods (forEach,map,filter,some,every,find,findIndex,findLast,findLastIndex,reduce,reduceRight) compile;mapandfilterreturn the receiver's kind, a Buffer for a Buffer, and athisArgargument is unsupported. Numeric typed arrays and Buffers preserve their kind and shared storage throughunknown, including when nested in records and arrays. Numeric typed-array constructors can be stored and used withnew, including constructors read from an array'sconstructorproperty. JavaScript numeric-array parameters and returns preserve typed-array storage.Buffer.from,Buffer.allocUnsafe, andBuffer.concatreturn views into a per-thread pool ofBuffer.poolSizebytes (64 KiB by default) when the size is belowBuffer.poolSize >>> 1, as in Node; a pool slab stays in memory while any of its Buffers does. Node's own startup code allocates from the first slab, so thebyteOffsetof Buffers in that slab differs from Node's. Buffers returned by other Node APIs, such asfs.readFileSyncandzlib, own theirArrayBuffer, where Node allocates small ones from the pool. - Blob and File:
new Blob()andnew File()accept arrays, typed arrays,Set, andMapas sources. Other iterables throwSC2020.blob.stream(),blob.textStream(),URL.createObjectURL(), andstream/consumersblob()are unsupported. Blobs cannot be sent to workers. - Prototypes: Named properties and methods on program class prototypes support replacement, inheritance, and deletion.
A module-level JavaScript class's prototype can become the prototype of other objects:
Object.create(C.prototype),Object.setPrototypeOf(F.prototype, C.prototype),Object.setPrototypeOf(object, C.prototype), andutil.inherits(F, C)with an ordinary constructorF. The inherited methods and accessors run with the inheriting object asthis. Methods that use#privatemembers orsuperthrow a TypeError for a receiver that is not an instance of the class.C.prototypealso reads as a value forObject.getPrototypeOfand for===and!==comparisons. Changing the prototype of a class prototype (Object.setPrototypeOf(C.prototype, X),util.inherits(C, F), orObject.setPrototypeOfon a class prototype reached through an instance) is unsupported. Other bare prototype reflection, TypeScript class prototypes as values, accessor replacement, and prototype storage on local, generic, mixin, or runtime-provided classes are unsupported. Plain objects, arrays, functions, class instances, and Date, RegExp, Map, Set, WeakMap, WeakSet, and Promise values inheritconstructor,valueOf,toString,hasOwnProperty, andpropertyIsEnumerablefromObject.prototypeas in Node, sovalue.constructor === Objectandvalue.valueOf === Object.prototype.valueOfcompare identities exactly. Named reads such asvalue.valueOfanswer these inherited members; computed-key reads such asvalue[key]do not. In a TypeScript source,instance.constructoron an instance of a program class is the instance's own class, whatever class the static type names. Itsname, comparisons with a class,new (this.constructor as typeof C)(...), and statics read or called through(this.constructor as typeof C).memberanswer as in Node. The constructor of a generic class's instance answers itsnameonly, andconstructoris unsupported in a hierarchy that includes a function-local class extending another function-local class. Bindingthis.constructor as typeof Cto a variable is unsupported when a subclass takes different constructor arguments, and so isconstructorread through the static type of an array, Map, Set, function, or builtin error. Static accessors of TypeScript classes compile, including inherited ones andsuperin a static member; compound assignment and++on a static accessor are unsupported.Object.prototype's own members read as values; its mutation and other reflection, such asisPrototypeOfand__proto__, are unsupported. The constructorsObject,Function,Date,RegExp,Map,Set,WeakMap,WeakSet, andPromiseread as function values; through a stored value onlyObjectcan be called.newthrough a storedObject,Date,Map,Set,WeakMap, orWeakSetbuilds the same value as thenewexpression.newthrough a storedRegExporPromise,newof a storedObjectwith a primitive argument, andinstanceofagainst these constructors are unsupported.instanceof Objectandinstanceof Functionon untyped values follow the prototype chain as in Node, so an object built withObject.create(null)is not anObject. - Built-in members: A program that replaces, deletes or shadows a member of one of the language's built-in objects and also uses that member natively is refused at build time, a deliberate difference from Node.js.
Compiled code reaches a built-in such as
Array.prototype.pushorMath.randomdirectly and never reads it from its object, so that use would keep running the built-in. The write is refused withSC1092, which names the write and the use: an assignment,delete,Object.defineProperty,Object.defineProperties,Object.assign, or aReflectcall whose target is a built-in constructor, itsprototype,Math,JSON,Reflect, or the global object. A use is a call of the member through a value of the built-in, a call or a read through the built-in object, another built-in that reads it (promise.catch()readsthen,String(array)readsjoin), or a language construct that reads it: a string or numeric conversion (toString,valueOf,Symbol.toPrimitive), an iteration (Symbol.iterator), an awaited or resolved value (then), orJSON.stringify(toJSON). The write and the use may be in different modules or packages, and the rule applies to TypeScript and JavaScript sources alike. Addingthen,toJSON,Symbol.iteratororSymbol.toPrimitiveto a built-in prototype that does not have it counts as such a write. A write whose member nothing in the program uses natively compiles as it did before this rule. The readers that do see a change are a value read of the member throughArray.prototypeor through an untyped value,for…of, array spread andArray.fromover an untyped value, and theMap,Set,WeakMapandWeakSetconstructors reading their adder. A use that runs before every write of the member, such asconst original = Date.nowat the top of the module that then replacesDate.now, is not counted. A polyfill guarded by a test of the member, such asif (!Array.prototype.at) { ... }, compiles: the member exists in Node 24, so the guarded code never runs, and a program that also changes the tested member is refused. Redefining a member with the same value to change its attributes, assigningError.stackTraceLimit, and a write Node itself rejects, such as an assignment toMath.PI, are not refused. A write the build cannot see, where the object or the key arrives as a value, is not refused:Math,JSONandReflectmembers throw at run time, and for other built-ins compiled code keeps calling the built-in. To change what a built-in does, for a test mock for instance, call a function of your own and replace that. A package that contains a refused write runs in a Node island under the default--node-islands=auto. - Intl.NumberFormat and Intl.DateTimeFormat: Formatter objects compile, with their options and
format(), over ICU 78 (the release Node.js 24 bundles). The options object is read when the program runs, by the steps ECMA-402 gives, so it can be a variable or hold computed values, and an invalid option throws the error Node.js throws.Number.prototype.toLocaleString,Date.prototype.toLocaleString,toLocaleDateStringandtoLocaleTimeStringtake a locale and options and build the same formatters. The locale is the default locale (no argument, orundefined),"en-US"or"en"; any other locale and a list of locales are refused, because which locale Node.js picks for a requested tag is not modelled.formatToParts,formatRange,formatRangeToParts,resolvedOptions,supportedLocalesOf, detachedformatmethods, BigInt and numeric-string inputs, and thecalendarandnumberingSystemoptions ofIntl.DateTimeFormatare unsupported. The otherIntlconstructors (Collator,PluralRules,ListFormat,RelativeTimeFormat,DisplayNames,DurationFormat,Locale) andlocaleComparewith a locale argument are unsupported. A program that uses these forms links ICU and needs the data fileicudt78l.dat(18.7 MiB) beside the executable;scriptc buildputs it there. Time zone rules and names are those of the ICU release, which can be older than the time zone data Node.js ships: Node.js 24.22 prints the offset for the namesEST5EDT,CST6CDT,MST7MDTandPST8PDTandUTCforGMT0where scriptc prints the zone's name, and the two disagree aboutAfrica/CasablancaandAfrica/El_Aaiunfrom October 2026 on. - Intl.Segmenter: Unicode grapheme segmentation, iteration, and
containing()compile, with the default locale or one language tag of the form language[-script][-region] written as a string literal (grapheme clusters do not depend on the locale). Word granularity compiles too, over ICU's UAX #29 word iterator at that locale; its segments carryisWordLikeexactly as Node.js's do. In JavaScript dependencies, sentence segmenters construct, and theirsegment()throws an SC2020 error; in TypeScript sources the construction is refused. Locale negotiation over several locales, sentence segmentation,resolvedOptions(), and detached methods are unsupported. - Globals: Stored
globalThisreferences support identity and probes for absent capabilities. A name that Node.js 24 defines but scriptc does not implement, such asWebSocket,FormData,BroadcastChannel, orURLPattern, is not an absent capability: reading it (typeof X,X,globalThis.X,globalThis["X"], or through a storedglobalThis) answers Node's constructor rather thanundefined, so the value carries Node'snameandlength,typeofanswers"function", andx instanceof Xanswersfalsefor every value because native code never produces an instance. The value carriesname,lengthandprototype; reading any other member, such as the class's staticWebSocket.OPENor a method on its prototype, raisesSC2020naming the global, because native code does not provide that surface. Constructing or calling that value raisesSC2020naming the global, withhost-globalas the Node island reason; in JavaScript the raise is the throw of the reachednew X(...)orX(...)statement, so a module that reads the global at load time still runs. Probes for capabilities Node.js 24 also lacks, such asBun,Deno, orTemporal, still answerundefined. In JavaScript, reading a builtin global through the global object by name (globalThis[name], or a stored global object) answers what the global's own spelling reads, and builtin module members that are global objects in Node, such asrequire("buffer").atobandrequire("timers").setTimeout, are the same values.WebAssemblyread this way, and builtin members read through a global object that untyped code received, can raiseSC2020.for (key in globalThis)visits Node's enumerable globals in Node's order, then the program's own global properties.key in globalThisandReflect.has(globalThis, key)answer for the names of Node's global object, the names it inherits fromObject.prototype, and the program's own global properties. A global object that untyped code received answersfalsetoinfor every name. In JavaScript, a name no declaration binds reads the program's own global property of that name, as in Node: afterglobalThis.X = class X {}orglobal.X = function () {}, in the same module or another,X,new X(),X()andtypeof Xuse that value; with no such property, a read throwsReferenceError: X is not definedandtypeof Xis"undefined". A sloppy-mode function'sthis.X = valuewrite lands on that global object when it runs with no receiver (a plain call, orcall/applywithundefinedornull), so the name reads the property afterwards too.navigatoranswers Node'shardwareConcurrency,language,languages,platform, anduserAgent, withlanguagederived fromLC_ALL,LC_MESSAGES, orLANGas Node does.navigator.locksraisesSC2020, as doesnavigator.languagefor a locale outside thelanguage_TERRITORY.codeset@modifierform, or one whose language or territory needs ICU's tables (a three-letter territory, for example).Temporalis not defined, as in Node.js 24:typeof Temporalis"undefined",globalThis.Temporalisundefined, and any other use throwsReferenceError: Temporal is not defined. Programs that name it type-check against TypeScript'sTemporaldeclarations. - Map and Set: Keys and elements support numbers and strings by value, and records, classes, arrays, functions, symbols, server handles, and unions of these reference types by identity.
Map values may also be functions.
unknownslots use native checked values, comparing supported primitives by value and retaining supported object references. Typed nested collections other thanMap<unknown, unknown>andSet<unknown>, and promises requiring payload adapters, cannot pass into these slots.Promise<unknown>retains its native representation. Storedkeys(),values(), andentries()iterators compile, retain element identity, and observe live collection mutations until exhausted. They support.next(),for...of, array spreads, and mapper-lessArray.from. They also support the iterator helper methods, such as.map()and.take(). JavaScript sources compile a method value read from Set, Map, WeakMap, or WeakSet: calling it with.callapplies the method to that receiver and throws Node's brand-check TypeError when the receiver is not the matching collection. Typed sources still refuse a method read as a value with SC1090. Constructing a Map, Set, WeakMap or WeakSet, or callingObject.fromEntries, with a checked-dynamic iterable (a native iterator, a generator, or an object with aSymbol.iteratormethod) takes all of its values before adding the first one. When an entry of a Map seed is not an object, the TypeError comes after the iterable is exhausted; Node closes the iterator at that entry. The Set composition methods (union,intersection,difference,symmetricDifference,isSubsetOf,isSupersetOf,isDisjointFrom) accept a Set of the same element type or a Map keyed by it; other set-like arguments are unsupported. - Compression: The one-shot
deflate,inflate,deflateRaw,inflateRaw,gzip,gunzip, andunzipfunctions and theirSyncforms accept Node's options, validated at run time, includingdictionary,maxOutputLength, andrejectGarbageAfterEnd. Typed inputs are strings, Buffers, and Uint8Arrays; untyped JavaScript values may also be other TypedArrays, DataViews, and ArrayBuffers. A literalinfo: truein an options object answers Node's{ buffer, engine }result in the sync, callback and promisified forms, and an options value whose type does not carry the literaltruestill takes the Buffer form and refuses. TheDeflate,Inflate,Gzip,Gunzip,DeflateRaw,InflateRaw, andUnzipstreams, fromcreateGzip()and the other factories ornew zlib.Gzip(), accept Node's options and support writes, piping,pipeline, async iteration,flush,params,close,reset, andbytesWritten. Each output chunk is its own Buffer rather than a slice of a shared chunk-size buffer.zlib.constantsmembers and their module-level copies read as Node's values. The Brotli one-shotsbrotliCompressandbrotliDecompressand theirSyncforms, and theBrotliCompressandBrotliDecompressstreams, accept Node's options, includingparamsanddictionary, and produce the same bytes as Node. The zstd one-shotszstdCompressandzstdDecompressand theirSyncforms, and theZstdCompressandZstdDecompressstreams, accept Node's options, includingparams,dictionary,pledgedSrcSize, andrejectGarbageAfterEnd, and produce the same frames as Node.util.inspectis unsupported. - Synchronous iteration: Checked
for...offollows live iterator methods, including compiled class methods and abrupt-completion cleanup. Mapper-less checkedArray.fromaccepts those iterators and plain array-like objects. Sparse checked arrays and general borrowed iterator factories are unsupported. Direct statically typed class loops accept iterators that are class instances or object literals; a loop that exits early calls the iterator's zero-parameterreturn(), as Node's IteratorClose does. - Iterator helpers:
map,filter,take,drop,flatMap,toArray,forEach,reduce,some,everyandfindcompile on generators, on array, typed array, string, Map and Set iterators, and on the objects the helpers return. Helper objects support.next(),.return(),for...of, spreads,Array.fromandyield*, pull their source lazily, and close it (run itsreturn()) at the same points as Node: whentakereaches its count, when a short-circuiting method finds its answer, when a callback throws, and when the loop consuming the helper exits early. In TypeScript,h.return!()andh.return?.()compile whenhis a helper call or aconstinitialized with one.flatMapcallbacks return arrays, generators, Sets or Maps; a string result throws Node's TypeError.Iterator.fromaccepts arrays, strings, typed arrays, Sets, Maps and iterator objects such as generators. In JavaScript, untyped generators and array, string, Map and Set iterators answer the same methods, and array destructuring of untyped values steps generators, iterators, Maps and Sets the way Node does. Helper methods on untyped async generators are unsupported.console.log,util.inspectandObject.prototype.toStringprint iterator objects as Node does:Object [Iterator Helper] {},Object [Generator] {},Object [Array Iterator] {}, and Map and Set iterators with the entries they have left.Iterator.fromover an object with its ownnextmethod or over an untyped value, theIteratorglobal as a value, andString()and template literals of typed iterator objects are unsupported. - Regular expressions: Native checked storage preserves identity,
source,flags, flag properties, and statefultest, and the flag getters (global,unicodeSets, and the rest) compile on statically typed regexes. Staticexec, globalmatch, and numericlastIndexaccess use the native matcher. Runtime constructors accept checked strings and native regex copies;replaceandreplaceAllaccept native regex values with string templates or callbacks, including captures, named groups, and UTF-16 offsets. Named groups (groups) read on matches of a statically known regex: fromexecandmatch, through optional chains (m?.groups?.name), in afor...ofovermatchAll, and on the element parameter of an array-method callback overmatchAllrows. The groups object has a null prototype, as in Node. Non-numericlastIndex, detached methods, andexecthrough an untyped receiver are unsupported. Thev(unicode sets) flag supports class set operations (--,&&), nested classes,\q{...}string literals, and properties of strings such as\p{RGI_Emoji}.new RegExpwith an invalid pattern throws aSyntaxErrorwhose message comes from the native engine and can differ from Node's. Thed(match indices) flag is unsupported: regex literals andnew RegExpcalls with a literal flag string containing it fail to compile with SC1120, andnew RegExpwith a computed flag string containing it throws an error naming the flag. - Object freezing:
Object.freezeandObject.isFrozensupport plain checked dictionaries and primitives. Freezing is shallow and preserves accessors. Aliased typed records, arrays, proxies, and other native objects cannot be frozen. Class instances supportObject.freeze,Object.seal,Object.preventExtensions,Object.isFrozen,Object.isSealed, andObject.isExtensiblewhen the static type of the argument names the class. A write to a read-only field throws Node'sTypeErrorin strict mode code and leaves the field unchanged in sloppy mode code.Object.definePropertywith a string-literal key changes the value,writable,enumerable, andconfigurableattributes of a declared field; an object-literal accessor descriptor (getorset) for a declared field is refused at compile time withSC2020, and another accessor descriptor for a declared field throwsSC2020when the call runs.Object.freeze,Object.seal, andObject.preventExtensionsof a class instance held in an untyped value change the instance itself, so writes through its typed references are checked the same way. A typed record checked from a frozen untyped object (an object literal frozen in a JavaScript file, or a frozenJSON.parseresult) is frozen too, and writes through its typed references are checked the same way. TheTypeErrorfor a write to a read-only property that was added to a class instance through an untyped value names#<Object>where Node names the class. Functions supportObject.freeze,Object.seal,Object.preventExtensions,Object.isFrozen,Object.isSealed, andObject.isExtensible; the operations apply to the function's own properties (name,length,prototype, and the ones a program assigns). Class constructors are not supported. A write to a read-only property of a checked dictionary or a function throws aTypeErrorwhose message omits Node's'x' of object '#<Object>'(orof function '…') suffix. A JavaScript class field that is first created after its instance became non-extensible is added instead of throwing.
Builtin function values
Some builtins can be stored and passed as functions:
- Lowered
node:pathfunctions across the bare, POSIX, and win32 modules, including optionalbasenameand variadicjoin/resolve. Called through an untyped value, they validate their arguments with Node'sERR_INVALID_ARG_TYPE. In JavaScript, a direct call whose arguments are not strings,joinandresolveincluded, validates them the same way. A path module held by untyped code is a plain object with Node's members in Node's order. - Supported zero-argument
node:osfunctions andquerystring.escape/unescape. util.isDeepStrictEqual,styleText,stripVTControlCharacters,toUSVString,inherits,deprecate,callbackify,debuglog, anddebug.fs.existsSync,unlinkSync,chmodSync,chownSync,renameSync, andcloseSync, andfs/promises.unlink,chmod, andrename.
String, Number, Boolean, and BigInt are function values wherever they are stored, in TypeScript and JavaScript: an option table can hold them as type tags ({ "--port": Number, "--tag": [String] }), beside strings and arrays.
A held constructor is the same function everywhere in the program, so type === Boolean holds across modules, through unknown, and as a Map key or Set member.
Called through the value, it converts whatever arguments it is given, as the builtin does.
A call through a held constructor converts its arguments to untyped values first; a direct call such as Number(x), and a constructor written as the callback of an array method (xs.map(Number)), keep their typed conversion.
A held constructor converts to a function type that has a first parameter ((value: string, name: string) => unknown), whoever calls it.
Under a function type with no parameters it is called with no argument, and the store is refused when the program hands a function of that type to a caller that passes arguments, as for any function that reads its argument list.
Through a function type whose first parameter is optional or accepts undefined, a call that passes undefined there, or omits the argument, throws a TypeError: a constructor answers a missing argument differently from undefined (String() is ""), and the function type does not say which one the call passed.
The prototype of a held constructor and a Map or Set keyed by a union of several constructor types are refused.
new through a held constructor builds with warning SC6015, which names the statement, and the statement throws SC1090 when it runs.
In TypeScript, util.format("%o", f) of a function value and Object.getPrototypeOf of a held constructor build with the same warning and throw when they run.
A constructor passed into a Node island is the island's own constructor there, and the island's comes back as the program's.
Converted to a string (String(c), a template, +, c.toString(), %s), a held constructor is Node's function String() { [native code] }.
A program that hands a held constructor, or a table of them, to something the typed form has no lowering for (printing, JSON.stringify, in, key listing, an any slot, bind, an assertion) holds its constructors as untyped values instead, in the whole program, and builds as it did before constructors had a typed form.
JSON.stringify and %j write a Map or Set held by an object, an array, or a tuple as {}, as Node.js does, whatever it holds.
In JavaScript, setTimeout, setInterval, setImmediate, clearTimeout, clearInterval, clearImmediate, queueMicrotask, and process.nextTick are function values wherever they are stored, including conditional and logical expressions and assignments: typeof answers "function", identity holds across spellings, and calls schedule as the direct calls do, returning the same numeric timer handles.
Calls through these values bypass node:test mock timers.
In JavaScript, atob, btoa, and structuredClone are function values the same way, and calls through them run what the direct calls run.
In JavaScript, parseInt and parseFloat are the Number.parseInt and Number.parseFloat function values, isNaN, isFinite, and Symbol (with Symbol.for, Symbol.keyFor, and the well-known symbols) are function values whose calls run what the direct calls run, and Atomics is an object whose integer operations run.
Calling eval through its value throws the EvalError its direct calls throw.
escape, unescape, WeakRef, and AsyncDisposableStack have function values with Node's name and length that throw SC2020 when called or constructed.
globalThis.require, module, exports, __dirname, and __filename are undefined, as in Node.
In JavaScript, any other Node function or class stored as a value (a global such as URL or Headers, a builtin module member such as module.register or dns.lookup) is a function with Node's name and length: typeof answers "function", identity holds across spellings, and calling or constructing it through that value throws SC2020.
process and performance stored in JavaScript are objects with Node's members: a function member is the function the spelled member reads (held.nextTick === process.nextTick), argv, platform, arch, pid, execPath, execArgv, versions, debugPort, sourceMapsEnabled and performance.timeOrigin read their values, and reading any other data member through the stored object throws SC2020.
Assigning a data member through the stored object (held.exitCode = 1) throws SC2020; the spelled process.exitCode = 1 is not affected.
The stored object is frozen: redefining a member with Object.defineProperty, replacing a function member or adding a key through it throws a TypeError, where Node changes the process object, because the spelled members (process.pid, process.nextTick(f)) are compiled where they are written and would not follow the change.
Any other Node value that native code does not provide (process.finalization, performance.nodeTiming) throws SC2020 where JavaScript reads it, and typeof of it answers Node's type without reading it.
A global that Node 24 does not define by default (localStorage, sessionStorage) is not defined: typeof answers "undefined", the global object has no such property, and a read throws ReferenceError.
In a JavaScript ES module, typeof of require, module, exports, __dirname, and __filename answers "undefined", as in Node.
An ES module namespace of a builtin module has only the module's exports, so zlib.Z_NO_FLUSH through import * as zlib is undefined in JavaScript, as in Node, while the default import and require() have it.
In JavaScript, require("events") and the EventEmitter class assigned to an untyped binding or stored in an object (ReleaseEmitter = EventEmitter) are the untyped EventEmitter constructor that constructor functions inherit from (see below): new through it builds such an emitter object, and identity and instanceof agree with the class.
A class can extend require("events") directly.
Other immutable aliases of table-backed Node builtins support direct calls, but cannot be passed elsewhere.
util.promisify supports compile-time conversions of child_process.execFile, child_process.exec, setTimeout and setImmediate (to the timers/promises functions, as in Node), stream.finished and stream.pipeline (to the stream/promises functions, as in Node), the zlib callback one-shots deflate, inflate, deflateRaw, inflateRaw, gzip, gunzip, unzip, brotliCompress, brotliDecompress, zstdCompress and zstdDecompress (with or without options), the crypto callback functions randomBytes, pbkdf2, scrypt, hkdf, randomFill, randomInt and generateKey, dns.lookup (settling with { address, family }, or the address array with all: true) and dns.lookupService (settling with { hostname, service }), and the fs callback functions that have an fs/promises counterpart (access, appendFile, chmod, chown, copyFile, lchown, link, lstat, lutimes, mkdir, mkdtemp, readFile, readdir, readlink, realpath, rename, rm, rmdir, stat, statfs, symlink, truncate, unlink, utimes, and writeFile); calls through the converted function lower as the fs/promises call.
util.promisify over an untyped function (a value typed any, a function whose parameters are untyped, or any other target in JavaScript) returns a native wrapper that follows Node's callback rules and carries the original's name and length, and throws Node's ERR_INVALID_ARG_TYPE for values that are not functions.
Such a function with other own properties, util.promisify.custom among them, throws SC2020 where util.promisify runs, and the wrapper does not report Node's DEP0174 warning when the original returns a promise.
util.styleText supports standard formats and aliases, #RGB and #RRGGBB hex colors, arrays of formats, nested ANSI resets, and explicit color enabling with { validateStream: false }.
Native calls accept standard process streams; custom native streams and mutations to util.inspect.colors remain unsupported.
util.inherits links the prototypes of constructor functions, and util.deprecate, util.callbackify, and util.debuglog return native function values that forward receivers and arguments.
In JavaScript, a constructor function can inherit from EventEmitter, the legacy Stream constructor, or a stream class through util.inherits or Object.setPrototypeOf.
EventEmitter.call(this) and Stream.call(this) initialize the object as Node does, and its listener methods keep their state in the object's own _events, _eventsCount, and _maxListeners properties.
The captureRejections option and events.errorMonitor listeners are not supported on such objects.
Readable.call(this, options) and the same call on Writable, Duplex, Transform, or PassThrough give the object a native stream.
The stream calls the object's _read, _write, _final, _transform, _flush, and _destroy with the object as this, and the stream prototypes' methods and accessors work on it.
Its listeners live in the native stream rather than in _events, and _readableState and _writableState are read-only views that answer the commonly read fields.
Typed code that receives such an object as a stream class uses its native stream, and piping a native stream into it works.
The options the native streams refuse (signal and others) are refused here too, as are _writev on a Transform, _final on a Transform, symbol event names, listeners(), rawListeners(), wrap(), and pipes into a destination that overrides write() or end().
_construct and _writev are read when Readable.call(this, options) or Writable.call(this, options) runs, as Node's constructors read them.
Other class constructors passed to util.inherits or util.deprecate are refused.
Deprecation warnings are emitted on the next tick and follow assignments to process.noDeprecation and process.throwDeprecation; compiled binaries take no Node command-line flags such as --no-deprecation or --trace-deprecation, and process.traceDeprecation is unsupported.
A stored util.deprecate reports a length of 4, where Node reports 3.
In TypeScript, a util.callbackify result must reach a callback whose error parameter accepts null; the @types/node overloads that type it as non-null are refused.
util.debuglog reads NODE_DEBUG as the process started.
Its %s refuses functions and objects with symbol-keyed members, and object arguments are refused on a color terminal.
util.isDeepStrictEqual supports primitives, ordinary records and arrays, cycles, enumerable string and symbol properties, and byte views.
Its optional third argument skips prototype and constructor comparisons.
Structural comparisons of native Maps, Sets, class instances, Errors, proxies, accessor properties, and function-valued own constructor properties remain refused.
Synchronous and promise filesystem APIs with trailing arguments that affect behavior remain call-only. This includes writers, open, directory creation/removal, metadata readers, and directory readers. Passing them as values could discard modes, flags, encodings, or options during function-signature adaptation.
Native error-first filesystem callbacks can be stored and passed to platform adapters.
Reads support Buffer and UTF-8 results; writes preserve string flags and modes; copy follows fs.cp.
Reads and writes reject already-aborted signals, but native file operations complete synchronously before the deferred callback, so cancellation cannot interrupt I/O in progress.
Recursive directory reads and Dirent results report a native limitation.
fs.glob compiles only as a direct call; a stored fs.glob value throws SC2020.
Native worker threads
node:worker_threads runs workers as native threads.
Worker entry points must resolve at build time: use a source-relative new URL("./worker.ts", import.meta.url), the current module URL, an absolute path, or CommonJS __filename.
A computed entry the build can bound to a finite set of files (a new URL of bounded text against import.meta.url, the value a module-local function returns, a branch of ?:, ?? or ||) starts the compiled file its value names; a value outside that set throws ERR_SCRIPTC_WORKER_ENTRY when the constructor runs, where Node would start that file.
Each worker initializes its own module state, event loop, environment snapshot, and reference-counted heap.
Nested workers inherit their parent's environment snapshot.
Supported constructor options are workerData, argv, a transferList of MessagePorts, name (reported by threadName and worker.threadName), stdout, stderr and stdin, and resourceLimits.stackSizeMb, which sets the worker thread's stack size (at least 192 KiB; without it a worker's stack is 8 MiB, where Node's is 4 MiB).
The resourceLimits heap limits (maxOldGenerationSizeMb, maxYoungGenerationSizeMb, and codeRangeSizeMb), worker.resourceLimits while the worker runs, and resourceLimits read inside a worker are refused; in the main thread resourceLimits is {}, and after a worker exits worker.resourceLimits is {}, as in Node.
With the stdout or stderr option, the worker's writes to that stream reach worker.stdout or worker.stderr, a Readable that ends after the worker's 'exit' event; its chunks arrive in order with the worker's other events.
Without the option a worker writes to the process's own output, and reading worker.stdout or worker.stderr is refused.
With the stdin option, worker.stdin is a Writable whose chunks the worker reads from process.stdin, in order with the worker's other events, and process.stdin ends when worker.stdin ends; without it worker.stdin is null and the worker's process.stdin ends without data, as in Node.
Runtime paths, eval, loaders, and shared environments are unsupported.
setEnvironmentData and getEnvironmentData keep a map per thread with SameValueZero keys; each new Worker starts from a clone of its parent's entries taken by the constructor, which throws DataCloneError when an entry cannot be cloned.
Worker argument strings containing null bytes are also unsupported.
Workers support online, message, error, and exit events, postMessage, terminate, ref, and unref.
worker[Symbol.asyncDispose]() terminates the worker and resolves with undefined after its exit event, so await using disposes a Worker at the end of its block.
A worker's uncaught exception reaches its error listeners as Node's error serializer sends it: an Error keeps the nearest of Error and its six native subclasses (an AggregateError arrives as an Error named AggregateError) along with its name, message, cause, and other data properties and their enumerability, and other thrown values clone as messages do.
An unhandled rejection whose reason is not error-like arrives as an UnhandledPromiseRejection Error with code ERR_UNHANDLED_REJECTION quoting the reason.
A thrown value that does not clone, such as a function, arrives as an ERR_WORKER_UNSERIALIZABLE_ERROR Error, where Node sends its util.inspect string.
new MessageChannel() from node:worker_threads makes two entangled MessagePorts, in one thread or across threads once a port is transferred, with receiveMessageOnPort.
Port messages arrive in Node's order: each port's queued messages as one batch before setImmediate callbacks, a port's own 'close' after the poll phase, and the other port's 'close' after its queued messages while the loop keeps running.
A worker's messages to its parent, and the parent's messages in the worker, also arrive as one batch before setImmediate callbacks, each followed by its microtasks, as in Node: the messages queued when delivery starts, and those that arrive meanwhile until the batch holds 1000.
receiveMessageOnPort(parentPort) in a worker takes the parent's next message.
A port's onmessage property and addEventListener are unsupported.
BroadcastChannel delivers each message to every other open channel with the same name, in any thread, as a 'message' MessageEvent through onmessage and addEventListener; an open channel keeps the process alive until close() or unref().
A messageerror event is never dispatched.
The parent port supports message listeners, postMessage, close, start, ref, unref, and hasRef.
Messages clone primitives, plain object graphs, arrays, errors, ArrayBuffers, typed arrays, and DataViews, preserving cycles and aliases.
Program class instances arrive as plain objects with their own data properties, without their prototype, methods, accessors, or private fields, as in Node.
markAsUntransferable marks objects for the current thread, and a marked ArrayBuffer or MessagePort in a transfer list throws DataCloneError, as does the ArrayBuffer of a pooled Buffer; marked objects other than ArrayBuffers stay alive until their thread exits.
markAsUncloneable marks a plain object, an error, or a class instance, and structuredClone and postMessage then throw DataCloneError for it, also where it is nested; as in Node, the mark has no effect on primitives, arrays, typed arrays, and ArrayBuffers.
A plain object that the compiler copies into a container with a fixed element type, such as an array literal whose elements all have one shape, is a separate object in the copy, which is not marked.
Marked objects stay alive until their thread exits.
A MessagePort travels with a message when the message's transfer list (an array or { transfer }) names it, and the sending port is unusable afterwards; a port in a message without that listing throws DataCloneError.
Other transferable values, functions, proxies, and other native handles are refused.
SharedArrayBuffers share their backing storage while retaining separate wrappers in each thread.
Graphs made immutable with @scriptc/threads are passed by reference instead of cloned; see Sharing Data Between Workers.
SharedArrayBuffer storage is fixed-length.
Atomics supports integer load, store, exchange, compareExchange, add, sub, and, or, and xor over 8-, 16-, and 32-bit integer arrays.
wait and notify use Int32Array views; BigInt atomics, waitAsync, and growable buffers are unsupported.
Atomics operations run as sequentially consistent atomic instructions and take no lock.
Other reads and writes of shared storage access each element atomically; a copy, fill, or conversion that runs while another thread writes the same storage can observe some of those writes, as in Node.
terminate unwinds at runtime checkpoints, including loops and parked atomic waits, without running JavaScript catch or finally blocks.
Blocking native calls finish before the next checkpoint.
A worker that reaches a Node island posts each island operation to the thread that started the island, the main thread, and waits there for its answer, so a synchronous island call works from a worker.
The program has one instance of each island module for all its threads, where Node gives every worker an instance of its own: what an island module keeps between calls (a counter, a cache, a registered listener) is shared by the main thread and the workers.
The build warns at each load of an island module in a module that worker threads run (SC6011).
A program module that island code imports too is shared the same way: island code uses the main thread's instance of it whichever thread called the island, while a worker's own code uses that worker's instance, and the build warns for such a module as well (SC6011).
The main thread answers a worker's island operations from its event loop, so a worker's island call waits while the main thread runs synchronous code, and it is never answered when the main thread blocks until that worker is done, as with Atomics.wait.
An asynchronous island call from a worker rejects with ERR_SCRIPTC_ISLAND_WORKER_ASYNC, an island promise, symbol or byte value (a typed array, a Buffer or an ArrayBuffer) crossing into a worker throws ERR_SCRIPTC_ISLAND_WORKER_VALUE, and so does a worker's own symbol or byte value crossing into the island, and a native value the island passes by reference (a function, an object, an array, a Map, a Set, a promise, or an error) crossing between a worker and its island in either direction.
The error's message names the kind of value and the call, read, or write it was part of.
A promise that a worker resolves with an island thenable rejects with the same code, and one resolved with any other island object is fulfilled with it.
In a module that only worker threads run, an island call whose argument has a function, byte, promise, or symbol type is refused at build time (SC8012).
A worker entry must be a compiled module, so a Node island module as the worker's entry is refused at build time (SC8012).
Workers are unsupported in WASI, compiled libraries, and executables that use foreign-thread native callbacks. Ordinary callbacks that run on their owning script thread remain supported. Shared byte storage cannot expose unmanaged FFI pointers; copy it into an ordinary Buffer before passing it to native code.
Child-process workers
child_process.fork() requires a worker path resolved at build time from new URL("./worker.ts", import.meta.url) or fileURLToPath(new URL("./worker.ts", import.meta.url)).
Never-reassigned const aliases and statically resolvable template parts are accepted.
The worker and its imports are embedded in the executable, which re-executes itself to start that module.
Worker arguments begin at process.argv[2].
Supported options are default inherited stdio or an inline object with cwd, env, silent, windowsHide, or [stdin, stdout, stderr, "ipc"].
execArgv is accepted but has no native effect.
Runtime worker paths, custom execPath, advanced serialization, transferred sockets or servers, uid/gid, timeout/signal options, and other stdio arrays are unsupported.
Parent and child channels support send(message, callback?), connected, disconnect(), and on/once for message and disconnect.
Message listeners may return void or Promise<void>.
Messages use newline-delimited JSON, so their static types must be JSON-stringifiable or unknown backed by a checked JSON tree.
send() returns the channel's backpressure state and invokes its callback later with null or an Error.
disconnect() changes connected synchronously, before the later disconnect events.
A 'data' listener on a child's stdout or stderr whose chunk is unknown or any receives strings when a setEncoding() statement on the same stream precedes it in its block or an enclosing block, and Buffers when the function never calls setEncoding() on that stream.
Any other placement of setEncoding() is refused at compile time, and a setEncoding() call that runs elsewhere afterwards makes the listener throw a TypeError instead of receiving strings.
pause(), resume(), isPaused() and readableFlowing on a child's stdout or stderr follow Node: a paused stream holds up to 64 KiB, then stops reading, which blocks the child once the pipe is full, and the child's exit resumes the stream.
Pausing the output of an exec() or execFile() child that has a callback holds back its 'data' listeners, but the output is still read for the callback, so that child is not blocked.
The call's maxBuffer is counted while the stream is paused, so a child that writes past it is ended with the maxBuffer error at that point, where Node ends it once the stream is resumed.
A child's output arrives over a pipe where Node uses a socket pair, so the number of bytes a child can write to an unread or paused stream before it blocks differs from Node's.
An inline 'exit' or 'close' listener may declare (code: number, signal: string), which TypeScript accepts through the catch-all on overload; it receives the null values Node passes, and a typed use of a null value throws a TypeError.
A function passed by name as an 'exit' or 'close' listener may declare its first parameter as number; when a signal ended the child, where Node calls it with null, it is not called and a TypeError is thrown instead, and a string signal parameter of such a function is refused at compile time.
Untyped values
Supported uses of any use native checked values.
Operations without native lowering produce diagnostics such as SC2011.
Use unknown with a checked cast where an operation needs a concrete type.
Map and Set type arguments may use any, with the same checked storage as unknown.
Locals, parameters, and returns can carry untyped values; record and tuple fields can hold unknown.
JavaScript instance fields and TypeScript class fields declared unknown or object (also with null or undefined, or as arrays of those) can also hold native checked values.
Bare fields start as undefined, and redeclaring a field with the same checked-value type resets it in initialization order.
Explicit TypeScript any class fields, other checked-value static fields, statically typed array elements, and union members are unsupported.
Program class instances retain identity through unknown and casts back to their exact class or a base class, including classes with internal collections.
Inspecting dynamic properties throws a catchable TypeError if the class's fields cannot pass through checked storage.
Supported native handles also retain identity.
An instance of a class that declares toString, converted to a string where its class is not known (an untyped array's join, String() or a template over such an array, the default sort order), throws SC2020 instead of running the method; convert the instance where its class is known.
JavaScript argument and return conversions preserve native array references; other JSON-shaped record and array conversions can copy values.
Supported operations on unknown include truthiness, typeof narrowing, property access, +, switch, and throw.
Cast before using other operations.
In JavaScript, a call whose untyped argument could select an overload with another result type returns a checked value, whichever overload the type checker picks, and so do the unannotated bindings and functions that hold or return it.
In TypeScript, an any argument keeps the overload the type checker picks, and a value that selects another overload at runtime throws a TypeError where the result is used.
Type checking
scriptc checks programs against the es2025 standard library, the ESNext declarations for Array.fromAsync, explicit resource management and Error.isError, and its own ambient declarations.
Some declarations differ from TypeScript's standard library or @types/node: JSON.parse returns unknown, and a Promise executor's reject reason is typed as Error.
A program that passes its project's TypeScript check may still use unsupported operations.
A second preflight using the project's declarations distinguishes those sites from ordinary type errors and reports scriptc diagnostics with rewrite hints.
Declared APIs without a compiler implementation, such as unsupported console members, produce SC2020.
From the nearest tsconfig.json, scriptc takes the strictness flags, paths and baseUrl, the JSX settings, the declaration files that files and include name, the packages that types names, typeRoots, and verbatimModuleSyntax, isolatedModules and preserveConstEnums for import elision.
A declaration file of the project, such as a shared types.d.ts, a workspace package of types or the typings it writes for an untyped package, declares data types the program builds, like the same types written in a .ts file.
A value that a package running in a Node island hands to the program stays that package's object under such a type: the program reads and writes it in place, and copies it only with structuredClone, a spread or JSON.
A project that sets typeRoots and no types has every package directory of a type root outside node_modules loaded, as tsc does through TypeScript 5.9.
A type root also answers a /// <reference types> directive, and an import of a module for which no node_modules directory holds declarations.
In a project that compiles under moduleResolution: node10 (also spelled node, and tsc's choice through TypeScript 5.9 for module: commonjs when the setting is absent), a specifier that only the type checker reads (in a declaration file, an import type or an export type) can name a file that a package's exports map does not list, and a package's declarations are also found by path where the map names none, as that project's tsc resolves them.
A value import of a file the map does not list is refused, as Node.js refuses it at startup.
A project whose target is below ES2022, or that sets useDefineForClassFields to false, has its parameter properties assigned before its class field initializers run, as in tsc's output; a field declared without an initializer is still an own property that holds undefined.
The other settings keep one meaning.
lib does not change the library above, and no other library is loaded into the program that is compiled.
A library that lib names beside it, such as dom, decides only which names type-check.
A name that only such a library declares is an opaque type in compiled code, and a value of that type is checked dynamically.
As a value the name is absent at run time, as under Node.js: a read throws ReferenceError, typeof answers "undefined", and globalThis.document is undefined.
A global that Node.js defines is never treated as absent.
A /// <reference lib="dom" /> directive in a source file does load the library into the compiled program, where it conflicts with the declarations scriptc bundles for a project without @types/node; name the library in lib instead.
TypeScript files are ES modules or CommonJS by Node.js's rules (the file extension and the nearest package.json), whatever module and moduleResolution say, so import x = require() and export = are refused with SC0016 in a project that sets module to commonjs.
Legacy decorators (experimentalDecorators) are refused with SC0016, except a class decorator of one parameter, which behaves the same under both decorator semantics.
A project that does not enable strict or strictNullChecks is refused with SC0002.
TypeScript keeps the type of an assignment across a call, so after x = undefined a read of x is typed undefined even when a function called in between assigns x again.
scriptc reads the stored value there.
A function without a declared return type that returns such a read is inferred to return undefined; scriptc refuses that return with SC1090, and a declared return type compiles.
Contract types
Contract types are checked only where they are written as the annotation of a parameter, variable, class instance field or function result, Acyclic only on classes, interfaces and object type aliases, and ProgramLifetime only in the implements clause of a class declaration; other aliases, interface members and nested type positions are reported.
In programs that use worker threads, a surrounding try/catch does not discharge NoThrow.
Int32 refuses parameters of functions used as values and fields of classes whose instances are stored in any or unknown values.
Int32[] refuses arrays that can come from or escape to code scriptc cannot see, follows callback results only for callbacks written at a map or filter call that scriptc runs inline, and checks a copy made by slice or a spread as if it were its source array.
Element reads that find a value are int32s, but a scalar Int32 slot still needs a[i] | 0, because a read can miss and produce undefined.
Immutable refuses values stored in any or unknown or that another reference can still change.
ProgramLifetime applies to root classes of executables only; instances the program drops are never reclaimed unless they belong to a released lifetime region.
three.js
With --npm-static=three, native and WASI builds support published package imports and tested CPU workflows for math, bounds, procedural geometry, curves, shapes, extrusion, text geometry, scene graphs, cameras, lights, materials, textures, and render-target data.
Mesh workflows include instancing, batching, morph targets, skeletal deformation, LOD, and sprites.
Raycasting includes mesh intersections, sorted results, recursive traversal, layers, distance limits, camera rays, lines, and points.
Animation coverage includes tracks, clips, property binding, mixer playback, blending, and fading. In-memory loading covers scene, material, geometry, and animation JSON, OBJ, STL, PLY, and self-contained glTF/GLB scenes with buffers, PBR material data, and animation. This establishes the exercised workflows, not every loader extension or overload.
Tested CPU graph construction from three/webgpu and three/tsl includes scalar/vector nodes, mutable uniforms, Fn layouts and calls, and MeshBasicNodeMaterial data.
WebGL/WebGPU rendering, DOM controls, image and video resources, audio, and worker-based decoders require external host bindings. A browser or native application can render geometry and material state produced by a compiled library and receive its resource lifecycle notifications. Compressed model and texture decoding belongs to that host; shader execution and rendered output are outside the CPU coverage described here.
Runtime differences from Node.js
Compiled code has runtime behavior that can differ from Node.js. Account for the following differences when porting a program.
- Event order across native code and islands: Timers, worker output, and other macrotasks from the program and from JavaScript it runs in a Node island share one event loop under Node.js, so their order is fixed. A compiled program runs both on the event loop it hosts for Node.js, but it does not merge them into one order, so callbacks from the two sides can run in a different order than under Node.js, and the order can vary between runs. Only programs that depend on the ordering between native and island callbacks are affected.
- Island packages that read the machine when they load: The build keeps what an island package exports when it loads only when the load read nothing a run could answer differently.
A load that reads a clock, a random number, the process id, the arguments, the working directory, the user, the host, a file outside the package, or the time zone of a machine whose
TZis unset runs when the program imports the package, which starts Node.js there. A package imported after any load that runs at its import runs at its import as well: Node.js is running by then, and the executable holds nothing the build computed after that load, such as a value the earlier load read and left in a global. A load that reads an environment variable, the default locale, a time zone thatTZnames, or whether a standard stream is a terminal waits, and runs at the import in a run where that answer differs from the build's. A variable that has a value on the build machine keeps the load at the import unless the project lists it inscriptc.nodeIslands.publicEnv, so a build machine withLANGset does not defer a package that formats a number in the default locale. A package marked"evaluate": "lazy"waits whatever its load reads. The values it computed from the machine, the values of packages imported after it, and its members whose names do not appear in its files are then read from Node.js on first use. The build cannot see three things a load can depend on, and keeps the build machine's answer for them: memory the package allocated without initializing it, how deep the stack is, and a value computed from the package's own path that no longer contains the path. - Timers across native code and islands: A timer or immediate the program creates is a number in JavaScript that runs in a Node island, as it is in compiled code.
The island's
clearTimeout,clearIntervalandclearImmediateaccept that number and clear the program's timer of that kind (clearTimeoutof an immediate's number clears nothing, as in Node), buttypeofanswers"number"there and the value has noref,unref,hasRef,refreshorclosemethod. A timer the island creates stays the island'sTimeoutorImmediateobject: the program clears it with the clear functions, calls its methods and passes it back to the island. In TypeScript, keep such a timer in aconst; a variable or field typed as a timer holds only the program's own timers, and storing an island's timer in one is a compile-time error. - Abort listeners across native code and islands: An
AbortSignalshared between the program and JavaScript running in a Node island is one signal under Node.js, with one list of listeners that run in the order they were added. A compiled program keeps a signal on each side, and the two follow each other with the samereason; each side keeps its own list of listeners. When the signal aborts, the island's listeners run first, in the order they were added, and then the program's, in theirs. A signal the program made reportsabortedon both sides before any listener runs; a signal made in the island reports it natively once the island's listeners have run.getEventListenersandlistenerCounton either side count that side's listeners only. Only programs that depend on the order between a native and an island listener of one signal, or that count a signal's listeners across the two sides, are affected. - Compile cache in Node islands: Node.js keeps a module compile cache only when
NODE_COMPILE_CACHEis set, and a compiled program keeps one by default for the JavaScript it runs in a Node island. In island codemodule.getCompileCacheDir()therefore returns a directory where Node.js returnsundefined, andmodule.enableCompileCache()reports that the cache is already enabled. The cache is in the user's cache directory, beside the island's extracted files, and the program uses it only when that directory belongs to the user and no one else can write to it. The program runs without the cache, and reports nothing, when the directory is not private in that way, cannot be created, or is on a file system with no free space, when the user has no home directory to keep it in, and when the process's effective user or group differs from its real one.NODE_DISABLE_COMPILE_CACHE=1turns the cache off.NODE_COMPILE_CACHE=<directory>makes Node.js use that directory as it does on its own, without those checks. - Child process event order: A child's
stdoutandstderrchunks, and the'spawn','exit', and'close'events of several children, arrive in the order Node.js delivers them on Linux and macOS. The events of one stream relative to the child's exit differ: when a child exits, the rest of its output and each stream's'end'are delivered before its'exit', where Node.js fires'exit'first when the child's output and its exit arrive in the same turn of the event loop. A child that is spawned as the program's first act and writes tostderrbeforestdoutis delivered in the order written, where Node.js usually deliversstdoutfirst because the child finishes before Node.js starts its event loop. A child's output pipe does not hold the same amount as the socket Node.js gives it, so a child that fills one stream before it writes to the other can block at a different point and be delivered in a different order. On Windows,stderris delivered beforestdoutwhen both hold output, and the events of several children fire newest child first. - Objects converted from Node islands: An object or array made by JavaScript running in a Node island is one object under Node.js, whatever type the program gives it.
A compiled program keeps it as the island's object while it is typed
unknown,anyor by the island package's own declarations. It keeps it too under a record type of the program that the value takes straight from the island: a declared result, an import, a member, a parameter of a callback the island calls, or a type the program asserts it to (item() as Item). Every value of such a record type then uses checked dynamic storage, which is slower than native record fields, including the records the program builds itself. Where the program converts the value to an array type, or to a record type that declares a string-keyed dictionary or a library object such as aDate, aMapor aSet, itself or in a member, the conversion reads the members that type declares and builds a native value from them. That value is a copy: a later change made by the island does not show through it, a write made through it does not reach the island, it is not===to the island's object, and it holds only the members the type declares. An untyped value that the program stores in a member, an array element, a reassigned binding or a container before it gives it a type is copied the same way where it is read back and given a record type that the program's own source files declare. A type that a declaration file declares stays a view of the island's object there. scriptc reports each conversion it can see, and each such store, as anSC6007warning. Assert the type where the island hands the value over or declare it in the island package's declarations to keep the island's object, or write the copy yourself (structuredClone(value) as Item[]) so that Node.js copies too. - Child processes from Node islands: A
ChildProcessthat JavaScript in a Node island started, for example through a package that wrapsspawn, and that the program uses at theChildProcesstype is the island's own process object: its events arrive in Node.js's order, and its properties, its streams and its listeners are the island object's. The following differs from Node.js.onceforspawn,exit,closeanderrorregisters the listener for every emit of the event, which shows only when the event is emitted more than once. When the child has closed, the listeners the program registered on it, on its streams and on itsstdinare released: they stay registered on the island's object but no longer run, and a listener the program registers afterwards is not registered at all. While the program listens to anything on the child, one morecloselistener is registered on the island's object. Adatalistener that takesBufferchunks throws aTypeErrorwhen JavaScript in the island set an encoding on that stream, and one that takes strings throws when no encoding is set, where Node.js hands either listener whatever the stream delivers. A write to the child'sstdinafter the child closed reportsERR_STREAM_DESTROYEDto the write's callback, as under Node.js, and also emitserroron the stream. Anerrorevent's error has itsname,messageandcode, and itserrno,syscall,pathandspawnargsread asundefined. A listener runs outside theAsyncLocalStoragestore that was current when the child was started.
Array bounds and runtime errors
Typed-array reads at an index that is not an integer in the array's range return undefined, as in Node.js, and invalid numeric indexed writes are ignored, while the assignment expression retains its original value.
A non-null assertion on such a read (bytes[i]!) yields NaN instead of undefined.
Ordinary arrays track holes separately from present undefined values.
Missing reads and empty pop()/shift() return undefined, indexed writes can grow the array, and length growth creates holes.
Keyed reads of a Record or an index signature return undefined for a missing key, as in Node.js, with or without noUncheckedIndexedAccess.
A missing array element or key that reaches storage that cannot hold undefined, such as a class field typed number, throws a TypeError.
An array converted to an array of another element type, such as an array of narrower records, is copied element by element, and a hole or stored undefined that the new element type cannot hold throws a TypeError.
Runtime traps cannot be caught.
User-thrown values and supported exceptions, including JSON parse, checked-cast, filesystem, regex, and String.prototype.repeat count errors, can be caught; hard traps such as out-of-range reads of statically typed ordinary arrays terminate the process.
Deep recursion in Linux and macOS executables throws Node's catchable RangeError: Maximum call stack size exceeded, on the main thread, in worker threads, and inside async functions and generators.
The depth at which it is thrown differs from Node: the main thread uses the process stack limit (usually 8 MiB), worker threads get an 8 MiB stack, async functions and generators that keep a fiber run on 512 KiB stacks, and stackless ones run on the stack that resumes them, so native code usually recurses deeper than Node on threads and somewhat less deeply inside fiber bodies.
Recursion inside runtime library operations, such as serializing deeply nested data, is not checked.
Windows executables, WASI builds and library builds do not check the stack, and exhausting it there terminates the process.
Runtime type checks
Casts from values whose type is only known at runtime validate the value.
For example, JSON.parse(s) as Config throws a catchable error if the data does not match Config, identifying the offending path, such as expected number at $.port, got string.
A TypeScript assertion alone does not perform this validation when run under Node.js.
A program that catches that error without reading it therefore takes the handler's path for data that Node.js accepts, and prints nothing.
In the program below, the second line is valid JSON without usage.total: Node.js prints message 1 for it, and the compiled program prints skipped.
interface Usage {
input: number;
total: number;
}
interface Entry {
type: "message";
usage: Usage;
}
function parse(line: string): Entry | null {
try {
return JSON.parse(line) as Entry;
} catch {
return null;
}
}
const lines = [
'{"type":"message","usage":{"input":1,"total":2}}',
'{"type":"message","usage":{"input":1}}',
"not json",
];
for (const line of lines) {
const entry = parse(line);
console.log(entry === null ? "skipped" : entry.type + " " + entry.usage.input);
}An executable built with --optimization dev and without --strip reports such failures when it runs with the environment variable SCRIPTC_CONVERSION_TRACE set to a value other than the empty string and 0.
Each failed check then writes the error and the file, line, and column of the conversion to stderr at the moment it fails, whether or not the program catches the error:
$ scriptc build log.ts --optimization dev -o log
/app/log
$ SCRIPTC_CONVERSION_TRACE=1 ./log > /dev/null
scriptc: checked conversion failed: TypeError: expected number at $.usage.total, got undefined
at parse (/app/log.ts:11:12)The line that is not JSON fails with a SyntaxError, which is not a failed check and is not reported.
The report changes nothing else about the run, a release build has none, and the variable is read only when a check fails.
A record or class instance cast from unknown to a dictionary type such as Record<string, number> keeps its identity, and the cast does not validate it.
Reading a value that does not match the dictionary's value type throws a TypeError, such as expected number at $, got string, where Node.js returns the value.
A cast from unknown to undefined or void checks that the value is undefined, and so does a cast to a type argument that is one of them, such as value as T in a generic function called with <void>.
Any other value throws a TypeError, such as expected null | undefined at $, got object, where Node.js keeps the value.
Casts between program classes are checked too: casting an instance to a class it does not extend throws a TypeError, where Node.js reads the members structurally.
SC6004 reports calls that pass such an instance to a function that casts it.
A value typed by an interface that extends Error is an error object or a plain object that has the members.
Handing it to a slot typed by an Error class (a parameter, a binding, a return, a member or an element) checks that it is an error and throws a TypeError for the plain object, where Node.js reads the members.
SC6004 reports those sites too.
Inside a generic function or class it reports a value whose type is a type parameter that a call or a new expression binds to such an interface, whether the parameter's type is the type parameter itself or holds it, as in list: T[].
A Promise converted from unknown to a typed result validates its fulfilled value.
A mismatch rejects with a TypeError.
Rejection reasons and reference equality are preserved across conversions.
A rejection handler that declares its parameter's type, such as (error: Error) => ..., validates the rejection reason when it runs, whether it is written inline or passed as a function value.
A mismatch rejects the promise that catch or then returned with a TypeError, where Node.js calls the handler with the reason unchanged.
A non-null assertion (value!) checks the value when it extracts an object, array or other non-nullable member from a union.
If the value holds null or undefined, the assertion throws a TypeError, even when the result is never used; Node.js continues until a property of the value is read.
A callback of filter, find or findLast that is written as a type predicate, such as (item): item is Tagged => "tags" in item or a guard function passed by name, runs as an ordinary test.
The elements it accepts are checked against the predicate's type: an element that is not of that type throws a TypeError, where Node.js answers the element unchanged.
Record identity and property order
A record converted to a record type with a different set of properties, such as a narrower shape or one that adds optional properties, is copied.
Mutations through the converted reference do not affect the original, and the copy is not === to it.
Empty record layouts are also snapshots because they have no property storage.
scriptc coverage and scriptc build report SC6001 at each conversion that copies a value something else can still reach, in any position: an argument, a return value, a field, an array element, a collection value, a callback parameter.
The report is made when the program writes a field or element of either type, compares values of the converted type by identity (including includes, indexOf, and Set or Map keys), or passes either type to code scriptc cannot follow.
It is made from the compiled program, so a program that builds without it does not lose such a write or comparison.
It judges types rather than the path one value takes, so it can name a conversion whose copy the program never tells from the original.
A conversion of a new value, such as an object literal, a spread, or the result of a function that returns one, is not reported, because nothing else can reach that value.
The same holds for an array converted to an array of another element type and for a tuple converted to an array.
A record that something else can still reach is refused with SC1090 where it is converted to a class instance and the program writes either type, because the conversion constructs a new instance where Node.js has the one plain object.
A union value that something else can still reach is refused with SC2003 under the same condition where one of its members fits several members of the destination union and enters the one its own discriminant names, because that conversion builds a new object where Node.js has one.
Two conversions are not covered and copy without a report.
A promise used as a promise of another record type, such as a Promise<Wide> stored as a Promise<Narrow>, copies its payload when it settles.
A class stored in a record type, such as const counter: { count: number } = Counter, holds copies of the class's static fields.
An as assertion that only adds optional members to the properties a record type declares is not such a copy: it is erased, so the value keeps its identity and reading an added member answers what the object carries, as in Node.js.
scriptc build reports SC1031 where such a member is assigned, because a record's layout has no storage for it.
Declaring a record value with a record type that names the same properties, where every declared field fits the value's storage, keeps the value's own layout instead: both names are the same object, as in Node.js.
When a declared field cannot store the values its type admits, such as a declared field that is a wider union type than the value's field, the declaration, a call that passes the value to a parameter the callee writes, or a literal that stores the value in that field is refused with SC2021 if the program writes through the binding, because the copy would take the write instead of the original.
Assigning an existing value to a binding that keeps its initializer's layout, to one of its fields, or to an element of one of its arrays, is refused with SC2021, because the kept layout rebuilds the assigned value, so a later write through it would reach only the copy.
The refusal covers a short-circuit assignment that stores the value (&&=, or ??= on a binding that can be nullish) like the plain assignment it stands for.
A member of another binding that kept its initializer's layout carries that layout into the store, so no refusal is reported when the two layouts already match.
Bracket writes such as alias["k"] = v write the field in the kept layout, like their dotted spelling.
Typed records with declared fields, indexed records, and arrays retain identity and mutations through native checked storage.
An empty array literal with no element type of its own, such as the files of { files: [] } or const NONE = [] as const, takes its element type from the declared types its value reaches and is the same array under every name.
scriptc build reports SC2015 where one such array is used at two element types or reaches a typed array through a computed key; writing the type at the literal ([] as string[]) compiles.
A record or class instance converted to a string-keyed dictionary type such as Record<string, string>, directly, through a {}, object or unknown binding or parameter, or as an element of a constant unknown[] array that holds such records, keeps its identity when the program writes through, compares or inspects values of that dictionary type.
Every dictionary type with the same value type then uses checked dynamic storage, which is slower than a native dictionary.
Class instances retain identity at their exact type or a base class, and at any interface or object type that a class instance is passed, stored, returned, or asserted as when the program could tell a copy from the instance: values of such a type are checked views of the original object, so writes, identity comparisons, Set and Map keys, util.inspect, and JSON.stringify through them reach the instance, as in Node.js.
These types use checked dynamic storage, which is slower than native record fields, for all of their values, including plain objects.
A type whose values are only read field by field, from fields the class does not write after construction and does not implement as accessors, stays a native record and holds a copy.
Object spread of a class instance is refused.
Dense array literals created directly in checked storage preserve identity, and supported native handles pass by reference.
A type derived from a built-in class whose values are native handles, such as an interface that extends Response or an Omit or Pick of it, an intersection with it, or a subset alias, names the built-in object itself and uses checked dynamic storage, also for an object the program makes for the type.
A member such a type adds or declares again is read from the object by name and checked against its declared type, so reading a required member that the built-in object does not have throws a TypeError, where Node.js answers undefined.
Assigning a member that the built-in object does not have throws, where Node.js stores it on the object.
Object.keys, Object.values, Object.entries, for...in, JSON.stringify, and util.inspect enumerate a record's keys in the order the object created them, as in Node.js.
scriptc chooses one order per record type from the order in which the program's object literals create the keys, follows object spread, rest destructuring, and record conversions back to the values they copy, and places an optional key that the program assigns after construction after the keys the object was built with.
When the object literals of one record type create its keys in different orders, including literals of two types with the same properties and property types, each value records the order its literal used: copies made by object spread, rest destructuring, and record conversions keep their source's order, and assigning an optional key the object lacks, including after delete, moves the key last.
A type keeps the declaration order of its first type, and SC6002 reports object literals whose order differs where the program observes it, when one of its values gets its keys from a spread whose source order is not known, from a spread that also sets an optional key the source lacks, or from a copy of a value scriptc cannot trace, or when the type's values can take more than 16 orders.
SC6014 reports such a type once, at a construction its order depends on, when the program observes the type's key order, although the objects the program builds may still list their keys as in Node.js.
Object.assign adds its source's properties to a record in the order the source object created them, and SC6014 reports a call that adds two or more optional properties from a value converted at run time.
A record converted from a checked value, such as const rows: { score: number }[] = JSON.parse(text), keeps the properties its type does not declare.
So does a record converted from an object with more properties, such as const p: { a: number } = { a: 1, b: 2 } or an argument passed to a parameter of a narrower type.
JSON.stringify, Object.keys, Object.values, Object.entries, for...in, in, hasOwnProperty, propertyIsEnumerable, Object.hasOwn, util.inspect, and untyped views of the record see them, together with the declared fields, in the source object's key order.
String conversion, +, and calls of toString and toLocaleString run the source object's own toString or valueOf when it has one.
Calling valueOf or isPrototypeOf by name on a record type that such an object converts into reports SC1090 when the object has its own property of that name.
Object.values and Object.entries check those values against their static result type and throw a TypeError if one does not fit.
For a record converted from an object with more properties, these surfaces read the object's other properties when they run, so later writes to those properties are visible; the declared fields are a copy taken at the conversion.
Copies of such a record made by object spread, Object.assign or rest destructuring contain only the declared fields; a conversion to another record type keeps the properties too.
A record converted from an object keeps a property non-enumerable when the object held it as a non-enumerable data property that is writable and configurable, whether or not the record's type declares it.
Object.keys, Object.values, Object.entries, for...in, JSON.stringify, util.inspect, and untyped views of the record leave the property out, in, Object.hasOwn, and Object.getOwnPropertyNames include it, and its descriptor read through an untyped view reports enumerable: false.
A copy of such a record made by object spread, rest destructuring, or structuredClone holds a declared non-enumerable property as an ordinary enumerable one, where Node.js leaves it out of the copy, and Object.assign from the record throws a TypeError when the result's type requires the property.
propertyIsEnumerable called through the record's type answers true for a declared property that is not enumerable.
A conversion does not keep a declared property's read-only or non-configurable attribute or its accessor: it reads the property once, and typed writes to the field succeed.
A value that a compiled npm package returns into a type its declarations give it is refused with a TypeError when the object has an accessor, a read-only or non-configurable property, symbol-keyed properties, or a prototype, or when it is frozen, sealed, or not extensible, or when it has a non-enumerable property and the type keeps its keys without property attributes (an index-signature record).
Index-signature records list declared fields before the other keys.
A rest binding over an index-signature source copies its source's key order, so it lists the remaining declared fields before the other keys even when the source object created the other keys first.
An object literal asserted with as to a record type whose required properties it does not write, such as const point = {} as Point, keeps its identity, and the properties the program assigns afterwards complete it.
Reading a required property that nothing wrote throws a TypeError, where Node.js answers undefined.
The same holds for a read through a computed key, the read of a compound assignment such as row[key] ??= value, and an object spread of the value, which reads every property.
Freezing such an object freezes it for every reference, whether or not it is complete.
scriptc build reports SC3001 at such an assertion when the object cannot be completed in place: when values of the asserted type may be part of a reference cycle, are one arm of a union of object types, are published or keep more than one property order, or when the literal holds a function.
Write every required property in the literal instead, or collect the properties in a Record<string, T> or Partial<T> value and assert that value once it is complete.
Optional fields and properties added through a record's unknown view can be deleted.
A required field has no absent state, so deleting it through the view throws TypeError: Cannot delete property 'x' of #<Object> and leaves the record unchanged, where Node.js removes the property.
A property that a record keeps but its type does not declare can be deleted through an as assertion that adds it as an optional member, such as delete (entry as Entry & { legacy?: number }).legacy.
scriptc build reports SC1090 for such a delete when a record of a type that declares the property can be converted to the operand's type, because the property is then that record's field, which the delete cannot remove.
Records inherit toString, toLocaleString, valueOf, hasOwnProperty, isPrototypeOf and propertyIsEnumerable from Object.prototype.
A call of one of these methods by name runs the built-in with the record as its receiver, unless the record holds an own function under that name.
A keyed read such as handlers[name] of a record whose values are functions answers the built-in when the record lacks the key, so truthiness, typeof and calls match Node.js.
A keyed read of a record whose values are not functions, such as counts["toString"] on a Record<string, number>, answers undefined where Node.js answers the inherited function, so counts[word] ?? 0 counts such a word as new.
Calling a built-in read from a record of functions throws a TypeError when its answer does not fit the record's function type, for example valueOf read from a Record<string, (x: number) => number>.
Other inherited names, such as constructor, read undefined from typed records.
Buffer construction
Buffer.from accepts untyped strings, byte arrays, arrays, and plain array-like or Buffer JSON objects.
Encoding arguments must be supported literals.
Buffer.from(arrayBuffer, byteOffset, length) is a view of the ArrayBuffer or SharedArrayBuffer, with Node's offset and length checks.
Custom input valueOf hooks and opaque class or native-handle inputs throw an unsupported-operation error.
The deprecated Buffer() and new Buffer() take up to three arguments, without spreads, and follow Node: the first call made outside node_modules reports DEP0005 on the next tick, a number allocates zero-filled bytes, and other arguments convert as Buffer.from does.
In JavaScript, Buffer read as a value (the global or the buffer module's Buffer) is one function with Node's statics and poolSize.
Calling or constructing it through a stored value, reading its prototype, and its copyBytesFrom and of statics throw an unsupported-operation error.
Buffer.prototype members read as values are functions that run on Buffer receivers; inherited and symbol-keyed members throw an unsupported-operation error.
readable-stream
readable-stream 2.x, 3.x and 4.x compile as Node.js's built-in stream module.
For 2.x and 4.x, that is the package's own behavior when the READABLE_STREAM environment variable is disable.
Without that variable, Node.js runs the package's JavaScript copy of the stream classes, so a native build can differ from Node.js wherever a program depends on that difference: instanceof checks against the built-in classes, class identity, error messages, and timing details.
The package's lib/_stream_*.js files also compile as the matching built-in classes, although Node.js loads the package's own implementations through them in every environment.
readable-stream 3.x is a copy of Node.js 10's streams.
Its own disable mode throws on Node.js 24, so no setting makes Node.js run it against the built-in classes; a native build maps the members its entry exports (the stream classes, Stream, finished and pipeline) to the built-in ones.
HTTP headers
Without @types/node, the bundled declarations type every req.headers value as a string.
Reading headers["set-cookie"] is then refused, and a { ...req.headers } copy holds set-cookie as one string joined with ", ", where Node holds an array.
Read headersDistinct["set-cookie"], or install @types/node, whose headers["set-cookie"] is string[].
Request URL credentials
http.request(), http.get(), https.request(), and https.get() accept a URL string or URL object in place of the options, with the options and callback after it.
A URL that carries a username or password throws a catchable error before anything is sent.
Node turns those credentials into a Basic Authorization header, and scriptc refuses the call rather than send the request unauthenticated.
Pass the header yourself instead, for example { headers: { Authorization: "Basic " + Buffer.from("user:pass").toString("base64") } }.
JSON callbacks
Function replacers and two-argument revivers support nested replacements, object-property deletion, and thrown exceptions.
Omitting the root through a replacer returns undefined.
Array replacers list the object keys to serialize, as in Node.js.
Stored JSON.stringify functions accept numeric and string indentation; direct calls require literal indentation.
Reviver source contexts are unsupported.
A reviver that takes a rest parameter or reads arguments is refused with SC2020, because Node.js passes it the source context as a third argument.
A reviver that deletes an array element throws, because checked arrays cannot represent holes.
Callback values use checked storage.
Typed records and arrays retain identity and mutations; record fields use declaration order; typed-array views retain backing storage and brands.
Buffer.isBuffer preserves the Buffer brand through unknown.
JavaScript callbacks receive the holder as this; TypeScript callbacks that access dynamic this are unsupported.
Strings and sorting
Strings are stored as UTF-8, with lone surrogates kept as their own code units.
Length, string methods and relational comparisons such as < and > use UTF-16 semantics, including for lone surrogates.
split with a string separator and replace or replaceAll with a string pattern don't match a lone surrogate against half of a surrogate pair; regular-expression patterns do.
Output, file contents, and other encoded text write each lone surrogate as U+FFFD, as Node does.
File system paths and network host names that contain a lone surrogate reach the operating system unconverted.
One-argument localeCompare follows Node's default root-locale collation for Latin-script text (ASCII, Latin-1 Supplement, Latin Extended-A, combining diacritical marks, and U+2044 FRACTION SLASH): letters order before case and accents, so "a".localeCompare("B") is -1.
Strings containing other characters compare by code point, which can differ from Node's ICU collation; SC6003 reports such string literals.
The locales and options arguments are unsupported.
sort and toSorted use stable natural merge sort.
Default ordering supports string, number, and boolean arrays, comparing their string forms in UTF-16 order; for example, [2, 10, 1].sort() produces [1, 10, 2].
sort preserves holes at the end, while toSorted produces a fresh array with holes filled by undefined.
With an explicit comparator, consistent comparators produce the same sorted results as Node, but callback order and count can differ.
Typed-array sort and toSorted order numbers by default, with -0 before 0 and NaN last.
With a comparator, they call it in the same order as Node and write the sorted values back after the last call.
Published graphs
Graphs published with @scriptc/threads are immortal: scriptc never frees them, even after every thread has stopped using them.
Publish long-lived data, not per-request messages.
A receiving thread reads the sender's objects, so they keep their classes, methods, and identity across threads and across messages. Node.js delivers clones without prototypes, a new clone for every message.
Writes into published objects throw Node's frozen-object TypeErrors.
In Node.js, o.x = f() evaluates f() before the write fails, and scriptc does the same, except for writes to union-typed class fields and for Map, Set, and array mutator methods, where the write check runs before the arguments are evaluated.
Private fields (#x) of published objects cannot be written either, although Node.js allows writing private fields of frozen objects.
Dates and timezones
String constructors and Date.parse use V8's date-string grammar: ECMAScript date-time strings and the legacy forms Node.js accepts, such as RFC 1123 HTTP dates (Mon, 01 Jan 2024 00:00:00 GMT), Date#toString output, and Jan 2, 2024.
Strings without a timezone, and new Date(year, monthIndex, ...) fields, are local time.
Local calendar getters and local-time conversions use the operating system's timezone database. Historical results can differ from Node.js when timezone data differs. For valid extreme years outside a platform calendar API's range, scriptc uses a calendar-equivalent year in the 400-year Gregorian cycle to obtain the timezone rule.
toString, toTimeString, String(date) and template literals print the zone's long name after the GMT offset, as Node does (GMT-0500 (Central Daylight Time)). scriptc identifies the zone the way Node does, from TZ when it names a zone, else from /etc/localtime.
Outside Windows, a write to process.env.TZ changes the zone for later conversions and getters.
The names are the en-US names for the IANA zones; Node prints them in the language of the locale that LC_ALL, LC_MESSAGES or LANG selects, so with a non-English locale the name differs from Node's.
A TZ value that is a file path or a POSIX rule string (such as EST5EDT,M3.2.0,M11.1.0) gives offsets and names that differ from Node's, which ignores those forms.
On Windows, the name is the GMT+hh:mm form unless TZ names a zone.
On wasm32-wasi, local time is UTC and the name is Coordinated Universal Time.
Weak collections and memory
WeakMap and WeakSet accept checked native objects and arrays, functions, numeric typed arrays, ArrayBuffers, native weak collections, and typed records, arrays, tuples, and classes that preserve identity through checked storage.
A promise is a key too: the same promise is one key whether it is held through its typed binding, a wider promise type, or an untyped value.
Entries keyed by a promise are released some time after the promise is gone, when later promise keys are added.
Copied values, other native handles, and symbol keys are unsupported.
Constructor seeds support arrays; custom iterators and detached methods are unsupported.
Weak collections do not retain their keys, but values that refer back to a key can keep it alive until deletion or collection release.
FinalizationRegistry keeps its registrations: register and unregister check their arguments and answer as in Node.js.
Its cleanup callbacks never run, which the ECMAScript specification allows.
Program output matches Node.js, which runs cleanup callbacks only when its garbage collector decides to.
Memory that a package frees only from a cleanup callback is not reclaimed until the program exits.
For example, a wasm-bindgen package frees the WebAssembly memory behind a wrapper object from its cleanup callback, so a long-running server that drops such wrappers without calling their free() method keeps that memory.
Call free() on wrappers the program no longer needs.
Symbol targets and unregister tokens are unsupported.
WeakRef is unsupported.
Memory uses reference counting. Acyclic values are freed deterministically, and cycles are collected at defined collection points. Native checked objects, arrays, Sets, and captured closures participate in cycle collection. Cycles through opaque native capsules can remain allocated.
Foreign-thread callbacks
FFI format 5 accepts retained, context-bearing void callbacks invoked by library-owned threads.
The native callback copies arguments and queues work; the script closure runs on the event loop at least one turn later.
These callbacks are not suitable for real-time execution.
Value-returning callbacks and direct script execution on foreign threads are unsupported. Reference counting and exception state belong to the script thread, and waiting for the event loop can deadlock.
TLS ciphers
Before the handshake Node's tlsSocket.getCipher() returns undefined, and after close null.
Its declared result is the { name, standardName, version } record, so a typed read there throws a TypeError instead.
After the handshake the record matches Node, with OpenSSL's suite name in name.
The suite itself is the one the bundled mbedTLS negotiates, which can differ from OpenSSL's choice for the same peers.
TLS certificates
tlsSocket.getPeerCertificate(), getCertificate(), getPeerX509Certificate(), and getX509Certificate() follow Node, including the detailed issuer chain, on sockets whose type is known.
On a TLS socket held in an unknown or any value, or in an untyped JavaScript parameter, they throw an error that names the call as not supported.
Client certificates follow Node: tls.createServer, https.createServer, and new tls.TLSSocket take requestCert, rejectUnauthorized, and ca, and tls.connect and https.request take cert and key.
A server's authorized and authorizationError report the client certificate's verification as Node does, and a server, client, or tls.createSecureContext given a ca also sends the chain it completes, as OpenSSL's automatic chain does.
A server verifies client certificates against the ca of the context it serves, including contexts from addContext() and setSecureContext(): an empty ca (an empty Buffer or array) trusts no certificate, and an omitted ca trusts the default CAs.
The same holds for a client's ca in tls.connect, https.request, and http2.connect, where an empty string is no ca, as in Node.
In http2.connect, a ca held in an unknown or any value that is an empty string is refused.
requestCert beside a TLSSocket's secureContext or an SNICallback, client certificates on http2 secure servers, and, on a tls server without an SNICallback, a cert without a key (or the reverse) are refused.
An SNICallback may be the only certificate source: the server options may leave out the default cert/key pair, and each handshake is then served from the context the callback answers.
server.addContext() and server.setSecureContext() follow Node on tls and https servers, including wildcard names, which match one label without regard to case.
A name with regular-expression groups or alternation, or one outside ASCII, is refused, as are both methods on a server that is not a tls or https server.
The 'tlsClientError' event reports Node's error for a failed handshake: OpenSSL's code and reason, or socket hang up for a client that leaves.
OpenSSL's messages leave out the thread identifier Node prints before error: and the source location after the reason.
A failure whose OpenSSL reason the runtime does not know, such as a malformed client hello, is reported as an error with code SC2020 that says so.
The X509Certificate those accessors return has the same refusals as any other certificate (see Crypto), so in JavaScript narrow it, for example with if (cert), before reading its fields.
TLS sessions
TLS servers send no session tickets, so a connection to them cannot be resumed.
A client's 'session' event fires once per connection, when its handshake finishes and before secureConnect.
Node fires it for each ticket the server sends, after secureConnect, and OpenSSL servers send two.
Console and process streams
console.log, info, and debug write to stdout; error and warn write to stderr.
They accept unknown, printing strings verbatim and other values through native util.inspect.
Console methods never color their output on their own: where Node colors numbers, booleans and the values inside objects and arrays, on a color terminal or with FORCE_COLOR set, the executable prints them plain.
Direct calls support global console and node:console imports.
Console output, util.format, and util.formatWithOptions with a format string known only at run time, spread arguments, or an options object format their arguments at run time.
There, %s of a function or of a class instance whose class defines toString throws SC2020.
util.inspect with colors, with showHidden, with option values known only at run time, or in the inspect(value, showHidden, depth, colors) form renders the value's untyped view in the runtime with Node's styles.
Colored output of errors, promises, regular expressions, DataView, ArrayBuffer, weak collections, iterators, and other native objects throws SC2020.
Inspect options other than depth, colors, customInspect, showHidden, compact (a number or false), breakLength, maxArrayLength and maxStringLength (a non-negative integer or null), getters (a boolean, 'get' or 'set'), sorted (a boolean), and numericSeparator (a boolean) throw SC2020 when they are set to a value other than Node's default.
util.inspect calls [util.inspect.custom] methods of classes and objects with Node's depth, options, and util.inspect arguments, and console.dir and customInspect: false skip them.
A class instance with such a method that is held as an untyped value throws SC2020 when it is inspected, and a class whose subclasses declare the method without declaring it itself is refused.
Under showHidden — the option, the boolean second argument, and %o — arrays print their hidden [length] entry, typed arrays their [BYTES_PER_ELEMENT], [length], [byteLength], [byteOffset], and [buffer] entries, ArrayBuffer and DataView their hidden byte fields, and objects their non-enumerable and symbol keys.
Objects also list the properties they inherit from up to three user-defined prototype layers, nearest layer first.
Values this runtime has no hidden view of — functions, errors, RegExp, weak collections, and SharedArrayBuffer (and views over one) — throw SC2020 under showHidden, and console.dir renders the option through the value's checked-dynamic view, refusing the types that have no conversion to it.
console is one object and each of console.log, info, debug, warn, and error is one function, so both can be stored, passed, destructured, bound, compared, and called without a receiver.
A stored method formats the arguments it is called with at run time, as util.format does, including format specifiers.
A value the untyped inspector does not render, such as a RegExp or a promise, throws SC2020 when a stored method prints it.
console flows into a record type whose members it has, such as interface Logger { log(...args: unknown[]): void; error(...args: unknown[]): void }, and each member of the record is console's own function.
The record is a separate value, so comparing it with console is refused, and a record type that declares table, dir, time, trace, or another member outside the five output methods is refused.
{ ...console } copies console's own keys in Node's order.
In TypeScript, keeping a console member other than the five output methods as a value, such as const table = console.table, is refused; typeof console.table and a truthiness test compile.
Reached through an untyped value, those members answer a function whose call throws SC2020.
promise.catch(console.error) is refused by the rule for catch handlers; promise.then(undefined, console.error) compiles.
Replacing a console member, such as console.log = capture, is refused in TypeScript and throws SC2020 through an untyped value, because direct console calls never read the member.
console passed into a Node island is the island's own console; a console nested in an object that crosses into an island throws.
Members of custom Console instances as values are unsupported.
JavaScript and TypeScript can store process.stdin, stdout, and stderr, replace output write methods, and call saved methods with their stream receiver.
The replacement can be assigned through a stored stream as well, such as out.write = wrapper where out is a NodeJS.WriteStream parameter holding process.stdout.
write is the one member a process stream keeps: an assignment to another member, such as process.stdout.isTTY = true, compiles and throws an SC2020 error when the statement runs, where Node stores the value.
A program that holds process.stdout or process.stderr as a value shares the stream's write method with its Node islands: a replacement installed by either side sees the output of both, and either side can call or restore the method the other saved.
In the islands of such a program write is an own accessor property of the two streams, so Object.hasOwn(process.stdout, "write") is true before any replacement.
There, Object.defineProperty(process.stdout, "write", …) throws a TypeError, and delete process.stdout.write throws one in strict code and answers false otherwise, where Node would replace or remove the method.
Writes that island code makes through the shared method do not pass through the island stream's own state, so its writableLength, 'drain' event and 'error' listeners do not reflect them.
In any other program with islands, a write replacement that island code installs sees island output only.
A worker thread's output does not pass through a write method replaced on the main thread.
Input supports data/end/error/readable listeners, pause/resume, buffered reads with read(size) and readableLength, and TTY raw mode.
Output writes are synchronous, with successful callbacks on the next-tick queue; queued backpressure is not modeled.
An executable built with --stdout-buffering instead keeps stdout bytes in a 64 KiB buffer whenever stdout is not a terminal, so a pipe or file can receive a line later than the call that wrote it; the runtime settles the buffer when it fills, before a stderr write, when the event loop sleeps, before a blocking stdin read, before process.kill, on process.exit, on an uncaught error, and at exit, and output that a kill skips those paths for (such as SIGKILL) can be lost up to the buffer size.
A terminal keeps one write per call.
Because no write is ever queued, writableLength is 0, writableNeedDrain is false, writableHighWaterMark is 65536, and 'drain' never fires, so drain listeners register silently and events.once(process.stdout, "drain") stays pending, as it does in Node when no write returned false.
Stored streams do not support piping, encoding changes, arbitrary properties, or other events.
getColorDepth and hasColors exist on process.stdout and process.stderr only when the stream is a terminal, as in Node, so TypeScript refuses an assertion that the optional call answered, such as process.stdout.getColorDepth?.() as number or a trailing !, with SC2020; test the answer instead, as in process.stdout.getColorDepth?.() ?? 1.
A call of either method with an environment that is an array, a Map, a Set, or a function builds with warning SC6015 and throws an error that names SC2020 when it runs on a terminal, and so does a call whose environment is an object literal with the single variable TERM set to constructor or __proto__.
The build cannot see the same TERM value in the process's own environment or in an environment passed through a variable, so it prints no warning for it: the call throws the SC2020 error on a terminal, where Node answers a member of Object.prototype instead of a color depth.
A TypeScript NodeJS.WritableStream parameter that only receives process.stdout or process.stderr supports write(string).
When other streams flow into the same parameter, the process streams join them as Writable instances with the full writable surface.
process.stdout and process.stderr also flow into a record type that declares only methods, such as interface Sink { write(text: string): void }.
A call through the record runs the stream's current method with the stream as its receiver, so a program that replaces process.stdout.write reaches its replacement.
The record is a separate value: it is not identical to the stream, and it exposes only the methods it declares.
A record type that also declares a data member, such as isTTY, throws SC2002.
An instance of a stream class such as Writable throws SC2002 in a record type of methods as well.
For those, pass an object literal that wraps the stream: const sink: Sink = { write: (text: string) => { process.stdout.write(text); } }.
graceful-fs
The graceful-fs package compiles as node:fs.
Its imports and require("graceful-fs") calls resolve to the builtin module, so the package's JavaScript is not compiled, and gracefulify(fs) as a statement does nothing.
Programs behave as with the package except under file-descriptor exhaustion: graceful-fs queues operations that fail with EMFILE or ENFILE and retries them when a descriptor closes, while a compiled program reports the error to its caller, as fs does.
In a compiled program, require("graceful-fs") === require("fs") is true.
DNS lookup errors
After a failed dns.lookup or dns.lookupService, Node calls the callback with the error alone, so the address and family parameters are undefined.
A callback whose address parameter is typed string (as Node's own type declarations type it) receives "" and NaN there, or an empty array for all: true, because a typed string or number cannot hold undefined.
An untyped callback receives the error alone, as in Node.
The promise forms in node:dns/promises (also reached as dns.promises) reject with the error and are unaffected.
Server and socket errors
server.listen() on a server that is already listening ends the process with exit status 1 and reports Node's ERR_SERVER_ALREADY_LISTEN as an uncaught error.
Node throws that error at the call, where a try statement can catch it.
A server that has closed does not listen again: a later listen() call is ignored and its callback never runs.
After a server has closed, another close(callback) call runs the callback with ERR_SERVER_NOT_RUNNING, as in Node, but the server's 'close' listeners do not run a second time.
A write callback of a socket that is destroyed before it connects, or whose connection is refused, receives ERR_SOCKET_CLOSED_BEFORE_CONNECTION, as in Node.
A write callback of a connected socket that is destroyed while the write is pending runs without an error, and the callback of socket.end() does not run; Node passes both the error of the cancelled write.
Socket data encoding
After socket.setEncoding(), an inline 'data' listener receives strings, as in Node, whatever type its chunk parameter declares.
A listener passed by reference, such as a named function whose parameter is typed Buffer, keeps its Buffer parameter, so a string chunk throws TypeError: expected Uint8Array at $[0], got string.
Declare that parameter as string or string | Buffer, or pass an inline function.
UDP socket options
socket.addMembership() and socket.dropMembership() on a dgram socket that is not bound yet throw SC2020; Node binds such a socket to an ephemeral port first, so bind the socket before joining a group.
The SystemError that the buffer size methods throw (ERR_SOCKET_BUFFER_SIZE, for example from getRecvBufferSize() before bind()) has Node's message, code, errno and syscall, but no info object.
In JavaScript, socket.send() also accepts lists of buffers, sends on a connected socket, and takes a completion callback, which receives null and the byte count, or the send's failure instead of an 'error' event.
The callback runs after the socket's pending events, where Node runs it on the next tick.
In TypeScript, send() with a callback, a list, or on a connected socket fails to compile with SC2020.
JavaScript can read a socket's on, once, addListener, removeListener, off, emit, send, close, bind, connect, disconnect, address, ref, and unref as function values, for example socket.emit.bind(socket); reading other members as values is refused with SC1090.
Listeners registered that way, or with untyped parameters, take only the message, error, close, listening, and connect events.
When a socket closes, listeners registered from TypeScript are released, so an emit() from JavaScript after 'close' reaches only listeners registered from JavaScript.
A datagram socket's 'error' event, for example for an address in use, has Node's message, code, errno and syscall, but not the address and port properties Node also sets; the error a send() callback receives has all of them.
Unix domain sockets and request options
server.listen(path) and the socketPath option of http.request() and https.request() use Unix domain sockets on Linux and macOS.
On Windows, where Node maps these paths to named pipes, they fail with ENOTSUP.
server.address() on a server listening on a Unix socket returns the socket path, as in Node, when the result is typed string | AddressInfo | null (the @types/node declaration).
Where it is typed as the { address, family, port } record alone, which cannot hold the path, the call throws an error for such a server.
A backlog argument to server.listen(), as in listen(port, host, backlog, callback) or listen(path, backlog, callback), is refused at compile time; leave it out.
The listen queue length is Node's default, 511.
When the options of http.request() come from a variable, or from an object literal that spreads one, they are read at run time with Node's validation errors.
The auth, createConnection, family, hints, insecureHTTPParser, joinDuplicateHeaders, localAddress, localPort, lookup and uniqueHeaders options then throw a runtime error when they hold a value, and so do setHost: false and setDefaultHeaders: false.
Process arguments and errors
process.argv[0] is "scriptc", process.argv[1] is the binary's path, and program arguments begin at index 2.
In programs that use node:test, a leading --test-update-snapshots argument is Node's snapshot update flag, and leading --test-reporter=spec and --test-reporter-destination=... arguments are Node's reporter options: each is kept out of process.argv and appears in process.execArgv, in the order given, which is otherwise [].
process.version and process.versions.node report the Node.js release the runtime is verified against.
The process.features object cannot be changed: under Node nine of its flags are writable and a program may add keys, but a compiled binary reads a flag as a constant, so a write to the object throws the TypeError of a frozen object and Object.isFrozen(process.features) is true.
Uncaught exceptions print Uncaught <value> to stderr instead of Node.js's source excerpt and stack-trace block; thrown strings and numbers print their value.
An uncaught Error and an unhandled rejection with an Error reason also print the stack frames the Error carries, one at line each under that first line.
A release build keeps stack frames only in programs that read an error's stack; in every other program its report is the first line alone.
A build with --optimization dev and without --strip keeps a frame in every function that can raise an error, and each frame names the file, line, and column of the statement that was running: at decode (/app/src/user.ts:8:3).
A function that only computes, and so could fail in no other way than by exhausting the stack, keeps no frame in either build: a stack overflow in it is reported at the statement that called it.
A build with --sanitize keeps the frames of a release build.
A frame takes 16 bytes of stack per call, so the deepest recursion of the functions that keep one is slightly lower in a dev build.
The position is the start of the statement, where Node.js reports the call or new expression inside it.
Such a build also lists constructors, methods, and accessors (at new Shape, at Shape.area, at Shape.get sides) and the top-level code of a module (at /app/src/main.ts:12:1), which a release build leaves out.
The frames of an async function or a generator end at that function: the functions awaiting or iterating it are not listed.
On Linux and macOS, a 64-bit dev executable that aborts, for example on an array index that a non-null assertion wrongly promised was in range, prints the same frame lines under the runtime's message.
Exit codes and output written before the exception are preserved.
Runtime errors expose message and Node's code as typed members.
The other own properties Node gives them, such as a system error's errno, syscall, and path, a child process error's status, stdout, and stderr, or an assertion error's actual and expected, are readable through an untyped view of the error (for example a cast of a caught value) and appear in util.inspect output.
Errors carry stack frames that name the function and the source file, without Node.js's internal frames; file:line:column positions appear only in the dev builds described above.
An error's stack text therefore differs between a dev build and a release build of one program, and so does what console.log prints for an Error: a dev build shows its frames where a release build of a program that reads no stack prints [Error: message].
A function passed to Error.captureStackTrace as the frame to stop at keeps a frame without a position.
A class constructor that passes this.constructor, new.target, or its own class to Error.captureStackTrace keeps no frame, and neither do the constructors of its subclasses, so the trace starts at the function that ran new.
console.log, util.format, and util.inspect print an Error from its stack the way Node.js does: the frames under the name: message heading, brackets when the stack has no frame line, and a subclass's header named after its class (for example Bailable [Error]: message).
Only the frames themselves diverge, so the output agrees with Node.js when Error.stackTraceLimit is 0.
Module path globals
__dirname and __filename are compile-time constants: the absolute path of the module's source directory and file at build time, the same strings as import.meta.dirname and import.meta.filename.
A .ts or .tsx file keeps them even when it uses import syntax, which Node.js would load as an ES module without these globals, because TypeScript projects are commonly shipped as CommonJS bundles where they exist.
In such a file typeof __dirname is "string", where Node.js running the source directly reports "undefined".
JavaScript ES modules (.mjs, or .js in a "type": "module" package) do not have them, as in Node.js.
Defined environment variables
A --define value replaces what the executable's environment holds for the variable, so the program and its child processes see the defined value whatever the executable is started with.
The if statements of JavaScript files that the value decides are resolved at build time, so assigning or deleting a defined variable is a build error, and a change made another way, such as a write through a name computed at run time or Object.assign(process.env, ...), doesn't change which branch runs.
The other conditions the value decides (the if statements of TypeScript files, conditional expressions, and the right operands of && and ||) are resolved at build time too, except in a program that writes or deletes an environment variable through a name computed at run time, and in a program with code that runs in a Node island, which shares the environment and can change the variable.
In those programs they are evaluated when the program runs.
Named imports of a CommonJS module that picks its exports this way see the names the selected module exports.
Node.js takes those names from the module that the last such module.exports = require() assigns, whatever the condition, so the two differ when the modules export different names.
Runtime code evaluation
A compiled program embeds no JavaScript engine, so it cannot run JavaScript source at runtime.
eval, indirect eval, new Function, and Function behave as they do under node --disallow-code-generation-from-strings, a deliberate difference from default Node.js: every call throws a catchable EvalError with the message Code generation from strings disallowed for this context.
The arguments are evaluated first, and the Function constructor converts them to strings before it throws, as Node.js does.
Packages that test for code generation before using it, such as zod 4, take their interpreted path.
Code that needs to evaluate source at runtime must be rewritten; to compute a value from code at build time, use comptime.
The vm module is refused for the same reason.
See npm Dependencies for which packages compile.
Build-time evaluation
comptime(() => ...) runs its callback while the program compiles, in an evaluator process based on QuickJS, and embeds the returned value as a constant.
The callback must be written inline in the call, must not be async or a generator, and must not refer to bindings outside itself, to console, or to another comptime call.
It sees the ECMAScript built-ins and nothing of the compiler or the machine: process, require, module loading, timers, file and network access, Intl and WebAssembly do not exist there, and using one is a build error.
The evaluator is a separate process that holds no object of the compiler, and only source text goes in and only the result's data comes back.
It is not a hardened sandbox: its protection rests on the JavaScript engine having no memory-safety bugs, so build only code you would run.
Each callback has 2 seconds and 256 MB, and exceeding either is a build error that names the limit.
Promise reactions never run, so a callback that leaves one pending, or leaves a rejected promise unhandled, is a build error.
The result must be a finite number, a string, a boolean, or arrays, records and unions with null or undefined of those, and its type must not contain itself.
Only a result's own enumerable properties are read, and an array hole reads as undefined.
A result that contains itself, is nested more than 512 levels deep, has an array of more than 1,000,000 elements, or is larger than 64 MB is a build error.
Two places in a result that hold the same object become two separate constants.
Math members give the values Node.js computes.
Members whose Node.js result depends on locale data throw at build time: toLocaleString, localeCompare, toLocaleLowerCase, toLocaleUpperCase, and toString, toTimeString, toLocaleDateString and toLocaleTimeString of a Date.
Number.prototype.toString with a radix other than 10 throws at build time unless the number is a safe integer.
Date.now(), Math.random() and the local time zone are the build machine's at build time.
The message of an error the engine itself throws, such as the TypeError for reading a property of undefined, is QuickJS's wording, not Node.js's.
Process events
Static signal listeners resolve names on the target platform, including SIGWINCH on POSIX.
on, once, off, and removeListener accept computed signal names and deliver the signal name and number.
Computed names for other event families and chained registrations are unsupported.
Windows registration is limited to CRT signals; WASI has no OS signals.
Literal uncaughtException and uncaughtExceptionMonitor registrations compile.
Handled exceptions resume queued native work; monitors alone do not suppress failure.
Error objects and primitive exceptions can reach listeners, while arbitrary native objects remain subject to exception-value restrictions.
Exception capture callbacks are unsupported.
NODE_NO_WARNINGS=1 leaves out the default report of a process warning on stderr once the program has called process.emitWarning or registered a 'warning' listener; listeners still run.
Before that, and in a program that does neither, the runtime's own warnings (the listener-leak warning of EventEmitter and EventTarget, the timer duration warnings, the dgram deprecation) are still printed.
The variable is read when a warning is reported, so an assignment to process.env.NODE_NO_WARNINGS changes later reports, where Node reads it once at startup.
Native addons
Node-API (N-API) and V8 .node addons depend on Node.js itself, so compiled programs can't load them.
Direct createRequire calls to local addons are rejected at compile time.
A package that requires an addon needs a JavaScript implementation that compiles, or a replacement through native FFI.
A package that looks for an optional addon at run time compiles with --npm-static.
In JavaScript dependencies, a createRequire require call with a computed specifier, and require.resolve called with a computed request or read as a value, resolve the specifier with the Node.js algorithm when the program runs.
A createRequire loader held as a value, stored in an object or passed to a function, in TypeScript or JavaScript, is a function that resolves its request the same way when it is called.
It has none of the properties that the Node.js require function carries: in TypeScript, a statement that reads resolve, cache, main, or extensions through a held loader builds with warning SC6015 and throws an error that names SC2020 when it runs.
require.resolve returns the path Node.js returns.
When nothing resolves, both throw the MODULE_NOT_FOUND error that Node.js throws, so a package that probes for a missing addon takes the same branch as in Node.js.
When the specifier of a require call resolves to a native addon, a builtin, or a file that is not part of the compiled program, the program prints an SC2020 error that names it and exits with status 1, because Node.js would load that module.
A catch clause around the call does not run in that case.
Resolution steps that the runtime does not reproduce, such as package imports specifiers, require.resolve options, and subpaths that a package does not export, end the program the same way.
Coverage lists these calls as deferred to runtime.
Other computed uses compile when they are inside a try block: a require call with spread arguments, a require.resolve call with another argument count, and require.resolve.paths called with a computed request evaluate their arguments and then throw an error, and require.resolve.paths read as a value is a function that throws when called.
Coverage lists these as deferred to runtime as well, and the package's catch clause then runs as it does in Node.js when the addon is missing.
Outside a try block, these uses keep the package refused.
This applies until compiled programs can load addons through Node.js.
Use Native FFI to call a plain C ABI function linked from an object or static archive. The guide includes a replacement for a small Node-API helper.
WebAssembly modules
scriptc translates WebAssembly modules to native code when it builds the program; there is no interpreter or JIT in the executable.
A build translates every module whose bytes it can see: files at paths the compiler resolves (require.resolve, createRequire(...).resolve, import.meta.resolve, new URL("./x.wasm", import.meta.url), path.join(__dirname, ...)), including .so WebAssembly shared libraries such as quickjs-wasi's extensions, modules inlined as base64 or byte-array literals, .wasm files shipped by packages whose code uses WebAssembly, and files listed in a scriptc.wasm array in package.json.
At run time WebAssembly.compile, instantiate, validate and new WebAssembly.Module find the translated module by the SHA-256 of the bytes they are given.
Bytes the build did not see, including bytes produced at run time, reject with a CompileError that says the module was not translated, and WebAssembly.validate answers false for them.
scriptc coverage lists the modules a build finds, with their size, whether they validate, and the WebAssembly proposals they use.
Translated modules can use the WebAssembly 2.0 feature set: the MVP plus sign-extension operators, non-trapping float-to-int conversions, bulk memory, multi-value, mutable globals, reference types, and extended constant expressions.
Modules that use SIMD, threads, exception handling, tail calls, typed function references or GC, memory64, or multiple memories are not translated, so loading them rejects with a CompileError that names the proposal the module uses, and WebAssembly.validate answers false for them; packages that fall back to a scalar build when that happens, such as undici and es-module-lexer, take their fallback.
Invalid modules the build finds reject with a CompileError that includes the validation error.
Supported: WebAssembly.compile, instantiate (with bytes or a Module), validate, new WebAssembly.Module, new WebAssembly.Instance, new WebAssembly.Memory, new WebAssembly.Table, new WebAssembly.Global, WebAssembly.Module.imports, exports and customSections, and instanceof for every class; the error classes CompileError, LinkError and RuntimeError, constructed with or without new; globalThis.WebAssembly and its compile, instantiate and validate functions as values.
Instances expose exported functions, memories (buffer, grow), tables (get, set, grow, length) and globals (value, valueOf).
Imports can be functions, numbers or BigInts for immutable globals, and memories, tables and globals that the program constructs or other instances export; their limits, types and mutability are checked with Node.js's LinkError messages.
Function references from a table or global reach JavaScript as callable functions, and exported functions can be stored in tables and globals, which is what dynamic linkers such as quickjs-wasi's extension loader do.
Traps throw WebAssembly.RuntimeError with Node.js's messages, unbounded recursion throws RangeError, and an exception thrown by an imported function propagates through the WebAssembly frames unchanged.
A WebAssembly.Module can be sent to a worker through workerData or postMessage.
Not supported yet: the Tag and Exception constructors, shared memories (new WebAssembly.Memory({ shared: true, ... }) throws a TypeError), compileStreaming and instantiateStreaming, and the classes used as values other than with new, instanceof and WebAssembly.Module's static functions.
TypeScript sources fail to build with SC2020 at each such use, and JavaScript sources throw that diagnostic when the statement runs.
Programs built for wasm32-wasi can't use the WebAssembly API.
Differences from Node.js:
- Growing a memory, from JavaScript or inside the module, does not detach the previous
ArrayBuffer. The memory never moves, so views created before the growth stay valid but keep their old length; code that readsmemory.bufferagain after growing, as WebAssembly glue code does, behaves as in Node.js. valueOf()answers aWebAssembly.Global's value only when the receiver's static type isWebAssembly.Global; through an untyped value it answers the object, and converting aGlobalto a primitive uses the object rather than its value.- Instances are never freed, together with their memories, imports and exports.
- A load whose result the module never uses may be removed instead of trapping when its address is out of bounds. Loads whose result is dropped explicitly still trap.
- NaN payloads may differ, for example when a signaling NaN passes through arithmetic or a JavaScript number.
WebAssembly.compileandinstantiatewith bytes settle after the current microtasks, as in Node.js, but can settle aftersetImmediatecallbacks that Node.js would run later.- The executable reads
.wasmfiles at run time from the paths they had when it was built.
WASI target
The wasm32-wasi executable target supports async/await, promises, generators, timers, portable event-loop work, stdin/readline, filesystem callbacks and promises.
WASI Preview 1 does not provide sockets, process spawning, OS signals, network interfaces, or filesystem notifications.
Networking/fetch, child processes, signal APIs, os.networkInterfaces(), the os host facts without a WASI equivalent (cpus(), hostname(), freemem(), loadavg(), uptime(), getPriority()), and fs.watch are rejected before linking with SC3002.
--sanitize and native FFI are unavailable.
Library mode emits an async-free Wasm reactor with named host imports.
Native runtime localization and thread instances are unsupported.
Each Wasm instance owns independent state.
Filesystem access is limited to directories opened by the host; scriptc run exposes the current working directory and /tmp.
See Platform Support for build and run details.
Tooling and native FFI
scriptc run does not forward extra CLI arguments to the program.
Build an executable and invoke it directly to pass arguments.
Native FFI links C functions declared in a manifest. Formats 2–5 support call-scoped callbacks, copied string/byte callback parameters, explicitly released retained callbacks, and asynchronous foreign-thread delivery. Format 6 adds single-precision floats, signed 8-bit and signed/unsigned 16-bit integers, and borrowed writable byte spans. Variadic calls, structs by value, owned pointer/string/byte returns, runtime dynamic-library loading, and library-mode builds are unsupported. See Native FFI.
Numbers follow JavaScript's double-precision semantics.
Browser embedding
Wasm reactors require a host-provided WASI Preview 1 adapter. A reactor can run supported three.js CPU operations and send animated geometry, material state, and resource lifecycle notifications to an external web application through declared imports. The application supplies DOM, graphics, media, audio, and decoder bindings, including the renderer.
Library mode excludes promises, async functions, timers. See WebAssembly Modules for the embedding contract.
Native debugging
Executable builds with --optimization=dev support source breakpoints and native stack frames for compiled TypeScript and JavaScript.
LLVM builds include source names and lexical scopes for locals, parameters, captured bindings, and module globals.
Release builds and builds with --strip omit these source mappings.
On macOS, executable builds produce an adjacent .dSYM bundle using the Command Line Tools' dsymutil.
Debugger values use native representations.
Numbers and booleans display directly.
Strings expose their ScrStr layout, including UTF-8 data and byte len; tagged unions expose their tag and slot fields.
Other heap values and scalar bindings captured before initialization can appear as opaque pointers.
Debuggers can't evaluate TypeScript expressions or format values as JavaScript objects.