#1643·arktype

Suggestion: Use InternalScope.scope instead of this.scope in static field arrow functions for Turbopack compatibility

Author: imsyfCreated Jul 27, 2026Updated Jul 27, 2026

Suggestion

scope.js:100-101 uses arrow functions in static class fields that reference this:

javascript
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):

javascript
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: https://github.com/vercel/next.js/issues/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