mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-31 07:23:06 +08:00
- Array patterns over strings split by code points via the string-iterator machinery: positions, holes, defaults, rest, nesting, and for-of heads - Destructured stdlib-global members bind their builtin identity tokens with Node-agreeing === identity; aliases register the twin - Surfaced-global members like Math.max fence eagerly by name — a token would quietly degrade them - Object patterns over strings bind length; wrapper-method extraction names the detached method # Conflicts: # packages/compiler/test/ts7/baselines/order-parity.json
31 lines
1.2 KiB
JavaScript
31 lines
1.2 KiB
JavaScript
'use strict';
|
|
// Destructuring a STDLIB GLOBAL in a JavaScript file binds member
|
|
// IDENTITY TOKENS (the identifier chokepoint's rule one member deep):
|
|
// one global, one member, one interned string, so identity and
|
|
// truthiness agree with Node across every spelling, while what a token
|
|
// cannot do meets per-site rules lazily at each use. This program pins
|
|
// the AGREEING operations — identity across destructures, identity with
|
|
// the property spelling, truthiness — under the Node oracle.
|
|
const { crypto: wc } = globalThis;
|
|
console.log(!!wc);
|
|
console.log(wc === globalThis.crypto);
|
|
|
|
const { subtle } = globalThis.crypto;
|
|
const { subtle: again } = globalThis.crypto;
|
|
console.log(subtle === again);
|
|
console.log(!!subtle);
|
|
|
|
// A member destructured from the aliased binding IS the same member.
|
|
const { subtle: viaAlias } = wc;
|
|
console.log(viaAlias === subtle);
|
|
|
|
const { Console } = console;
|
|
console.log(!!Console);
|
|
|
|
// A globalThis member with a REAL surface destructures as the global
|
|
// itself (the stdlibGlobalAliasDecl twin): receiver uses route through
|
|
// the same lowerings as the bare spelling.
|
|
const { Math: M } = globalThis;
|
|
console.log(M.max(1, 2));
|
|
console.log(M === globalThis.Math);
|