Files
scriptc/packages
Malte UblandClaude Opus 5.5 6255c9351b Keep the global object in type assertions of globalThis
`globalThis as { [KEY]?: State }` is the usual way for several modules
to share process-wide state. globalThis lowers to a checked-dynamic
value, and asserting a checked-dynamic value to a record or array type
took the checked conversion, which builds a new native value. A write
through the asserted value went to that copy, so other modules never
saw it; string-keyed and index-signature views threw "expected object".

- An assertion of the global object (globalThis, global, also through
  `as unknown as`) keeps the checked-dynamic value when the conversion
  would copy, so member reads and writes reach the global object.
- File-scope and local bindings of such an assertion hold the global
  object (collectGlobals, lowerVarDecl), so an exported
  `const state = globalThis as ...` works across modules.
- The divergence scan no longer reports these assertions as SC6001
  width copies.
- Runtime: one global-object box per thread (scr_global_object), which
  globalThis, global and globalThis.globalThis all answer, and direct
  `globalThis[symbol]` accesses use that box's symbol-keyed properties,
  so every spelling of the global object sees one property.

Other checked-dynamic values keep the checked conversion: a native
value held as unknown unwraps by identity there, and a checked-dynamic
tree is copied at the documented boundary.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 15:52:52 -07:00
..
2026-10-17 13:47:41 -05:00
2026-10-17 13:47:41 -05:00
2026-10-17 13:47:41 -05:00
2026-10-17 13:47:41 -05:00
2026-10-17 13:47:41 -05:00
2026-10-17 13:47:41 -05:00
2026-10-17 13:47:41 -05:00
2026-10-17 13:47:41 -05:00
2026-10-18 09:55:59 -05:00
2026-10-17 13:47:41 -05:00
2026-10-17 13:47:41 -05:00
2026-10-17 13:47:41 -05:00
2026-10-17 13:47:41 -05:00
2026-10-17 13:47:41 -05:00
2026-10-17 13:47:41 -05:00
2026-10-17 13:47:41 -05:00
2026-10-17 13:47:41 -05:00
2026-10-19 03:15:05 -05:00
2026-10-17 13:47:41 -05:00
2026-10-17 13:47:41 -05:00
2026-10-17 13:47:41 -05:00
2026-10-17 13:47:41 -05:00
2026-10-17 13:47:41 -05:00
2026-10-17 13:47:41 -05:00
2026-10-17 13:47:41 -05:00
2026-10-19 03:15:05 -05:00
2026-10-17 13:47:41 -05:00
2026-10-17 13:47:41 -05:00
2026-10-17 13:47:41 -05:00