Data that can be serialised: plain data, as PlainValue, in which any
part may be an object that SerialisesItself.
Functions, undefined, symbols, bigint, Date, Map and other objects
with methods are not values, and do not compile where a Value is expected.
An interface is not a Value either, since TypeScript gives an interface no
index signature: AsValue checks one. A property with a symbol key
compiles, since an index signature does not look at it, and is refused when
it is given.
importassertfrom"node:assert/strict"; importtype { PlainValue, Value } from"itinera/value";
assert.equal(kind(1250), "number"); assert.equal(kind(["tea", newPayment(1250)]), "list"); assert.equal(kind({ order:"R-1", payment:newPayment(1250) }), "object"); // @ts-expect-error: a Date is not a value kind(newDate());
Data that can be serialised: plain data, as PlainValue, in which any part may be an object that SerialisesItself.
Functions,
undefined, symbols,bigint,Date,Mapand other objects with methods are not values, and do not compile where aValueis expected. An interface is not aValueeither, since TypeScript gives an interface no index signature: AsValue checks one. A property with a symbol key compiles, since an index signature does not look at it, and is refused when it is given.