mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-23 06:10:02 +08:00
- T[K] resolves against record bindings, Object.hasOwn/assign lower over records and the DOM, fixed shapes take runtime-keyed writes with the miss trap, and string|RegExp unions narrow by instanceof - the width family gains the checked NARROW lift and the tuple-arm literal route (the option-table shapes) - island literals complete: get accessors, plain spreads, tagged templates with .raw, jsval ??, and call-time fence deferral for unlowerable members (lambda poisons defer too) - JS variadic rests under --dynamic bind the engine arguments array and re-invoke through apply; dyn values marshal into the island as the deep copy - corpus 2470-2476 pin every landing against the Node oracle on both backends
42 lines
1.4 KiB
JavaScript
42 lines
1.4 KiB
JavaScript
// The option-table shapes: a union-typed source field narrowing into a
|
|
// plain slot through the width copy (the checked-arm extraction), an
|
|
// undefined-armed choices array whose element literals width-lift, and a
|
|
// `default` union holding its tuple arm built from a literal
|
|
// (`[{ value: [] }]` — the array-family arm route).
|
|
/**
|
|
* @typedef {Object} ChoiceInfo
|
|
* @property {boolean | string} value
|
|
* @property {string} description
|
|
* @property {string} [deprecated]
|
|
*
|
|
* @typedef {number | boolean | string | []} OptionValue
|
|
* @typedef {OptionValue | [{ value: OptionValue }]} OptionValueInfo
|
|
*/
|
|
/** @type {{ [name: string]: { type: string, default?: OptionValueInfo, choices?: ChoiceInfo[] } }} */
|
|
const options = {
|
|
endOfLine: {
|
|
type: "choice",
|
|
default: "lf",
|
|
choices: [
|
|
{ value: "lf", description: "Line Feed only" },
|
|
{ value: "crlf", description: "CR + LF" },
|
|
],
|
|
},
|
|
plugins: {
|
|
type: "path",
|
|
default: [{ value: [] }],
|
|
},
|
|
};
|
|
|
|
/** @type {{ description: string, value: string }[]} */
|
|
const narrowed = [
|
|
{ value: "lf", description: "Line Feed only" },
|
|
{ value: "crlf", description: "CR + LF" },
|
|
];
|
|
console.log(narrowed[1].value, narrowed[1].description);
|
|
|
|
console.log(options.endOfLine.type, options.endOfLine.default);
|
|
console.log(JSON.stringify(options.endOfLine.choices));
|
|
console.log(options.plugins.type, JSON.stringify(options.plugins.default));
|
|
console.log("done");
|