Files
scriptc/tests/diagnostics/create-require.ts
T
Chris Tate 009a24b469 Field redeclares, class destructuring, unknown-field completion, node:module fence
- redeclaring an inherited field WITH an initializer lowers as the [[Define]]-equivalent assignment into the base slot at the subclass's field-init position (builtin Error prefix included — prettier's errors.js `name = "ConfigError"`); bare and type-changing redeclares keep sharpened fences (corpus 2428, diagnostics inheritance re-record)
- object destructuring of CLASS instances desugars to one member read per element, left to right: fields read slots, accessors call getters through the fieldGetExpr dispatch, renames/parameter patterns/defaults included (corpus 2429 — prettier's AstPath { previous, next })
- an object literal missing an 'unknown' field completes with the DOM undefined (the absent-property read's answer), at literal completion and in the record width relation (corpus 2430 — prettier's getFileInfo(file, {}))
- node:module joins the supported builtins prefix-only as an admit-then-fence surface: createRequire keeps a per-member fence that defers to a catchable runtime error in JS sources (diagnostics create-require pins the hint naming the pattern)
2026-07-22 23:48:01 -05:00

11 lines
563 B
TypeScript

// node:module ADMITS (the builtin import carries no evaluation), and every
// member keeps a per-site fence: createRequire loads CommonJS from disk at
// RUNTIME (prettier's config/plugin loading), which a compiled program —
// whose modules are fixed at build time — cannot do. In TS sources the
// fence is this compile-time diagnostic; in JS sources the same call
// defers to a catchable runtime error naming the member.
import { createRequire } from "node:module";
const req = createRequire("/tmp/parent.js");
console.log(String(req("./config.cjs")));