Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0001-core FR-006
Objects made for exactOptionalPropertyTypes (0001-coreFR-006): compact builds an object from fields some of which may be undefined, leaving those out, and its type says so exactly, so that a caller writes compact({ a, b: maybe }) instead of { a, ...(maybe === undefined ? {} : { b: maybe }) } once for each optional field.
import { compact } from"./objects.ts";
consttimeout:number|undefined=undefined;
constoptions=compact({ url: "https://example.com", timeout }); // { url: string; timeout?: number }, and no `timeout` key
The object with its fields that are undefined left out (FR-064), typed exactly by Compact. Keys are kept in their order; a key named __proto__ is kept as an own field, never as the prototype.
T with each field whose type admits undefined made optional without undefined, and every other field kept as it is (readonly kept): the type of compact(value) under exactOptionalPropertyTypes.