Suggestion
scope.js:100-101 uses arrow functions in static class fields that reference this:
static scope = ((def, config = {}) => new InternalScope(def, config));
static module = ((def, config = {}) => this.scope(def, config).export());
Under Turbopack (Next.js 16 dev mode), the arrow function's lexical this binding is lost during transpilation, producing a module-level _this = void 0 and crashing with TypeError: Cannot read properties of undefined (reading 'scope').
Suggested fix — Convert to static method declarations (or use InternalScope.scope explicitly):
static scope(def, config = {}) {
return new InternalScope(def, config);
}
static module(def, config = {}) {
return InternalScope.scope(def, config).export();
}
This is a defensive workaround for a Turbopack dev-mode transpilation bug tracked at: vercel/next.js#96254
This is not a bug in arktype — the code is valid ES2022. Instance field arrow functions (lines 1795–1848) are transpiled correctly because Turbopack wraps them in IIFEs with proper _this capture. Only static field arrows are affected by the Turbopack issue.
Minimal reproduction
https://github.com/imsyf/arktype-turbopack-repro
Suggestion
scope.js:100-101uses arrow functions in static class fields that referencethis:Under Turbopack (Next.js 16 dev mode), the arrow function's lexical
thisbinding is lost during transpilation, producing a module-level_this = void 0and crashing withTypeError: Cannot read properties of undefined (reading 'scope').Suggested fix — Convert to static method declarations (or use
InternalScope.scopeexplicitly):This is a defensive workaround for a Turbopack dev-mode transpilation bug tracked at: vercel/next.js#96254
This is not a bug in arktype — the code is valid ES2022. Instance field arrow functions (lines 1795–1848) are transpiled correctly because Turbopack wraps them in IIFEs with proper
_thiscapture. Only static field arrows are affected by the Turbopack issue.Minimal reproduction
https://github.com/imsyf/arktype-turbopack-repro