Packages
@strict-script/std
What compiled strict-script programs import as they run. It has no dependency and never imports the compiler.
A program in TypeScript that calls a compiled module reads its types from here:
import type { JsonError, Option, ParseError, Result, Thrown } from '@strict-script/std';
const read = parseInvoice(text); // Result<Invoice, JsonError | ParseError>
if (read.ok) read.value; else read.error; // narrowed by `ok`
An Option is { some: true, value } | { some: false } and a Result is { ok: true, value } | { ok: false, error }:
plain data, with no method. some, none, ok and err make them. They are described in
The standard library.
| File | What it holds |
|---|---|
src/types.ts | Option, Result, Thrown, ParseError, JsonError |
src/options.ts, src/collections.ts, src/numbers.ts | What the methods of the language become: mapOption, mapGet, sortedBy, toNumber… |
src/check.ts | The checks a type becomes, to read a value of unknown type against it |
src/unsafe/boundary.ts | The boundary: where exceptions are caught and rejections read |
src/unsafe/door.ts | The door of a compiled module: what reads each argument of an exported function, and what gives its result to the outside |
src/unsafe/stop.ts | What stops the program (panic), and what is remembered of it |
Apart from the types and their four makers, the exports are what the compiler calls in the JavaScript it writes; their names may change with it.
This package is not written in strict-script and is not under strict-ts: it is what is taken on trust at run time, and it is tested.