mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-28 06:53:42 +08:00
A generic factory declared to return a constructor type (`Struct<S> =
(abstract new () => S) & { decode }`) whose every return gives back one of
its own local classes (`return Base as Struct<S>`) is now that local
class's factory: each instance has its own class, the result maps to the
class value while the instance lowers and at its calls, and `class X
extends struct(...)` extends it like a factory returning the class
directly. Before, the result type mapped to nothing (SC2008) and the
extends clause refused as a computed expression.
Static methods of a function-local class in a TypeScript file now lower as
the class value's runtime statics, as they already do in JavaScript files:
they read the enclosing function's bindings, call each other through
`this`, and inherit into a subclass. Before, they refused with SC1090.
Static fields and static blocks of such classes keep the fence.
Fixes #1372
Co-authored-by: blurname <50226652+blurname@users.noreply.github.com>