tooling TypeScript maintained library

options-defaults

Strongly-typed merging of user options with default configuration, without losing type information.

Why

Every library I write accepts an options object with defaults. { ...defaults, ...userOptions } works until options are nested, or some default is a function, or the user passes undefined and you want the default instead of undefined.

options-defaults is a single function that handles nested merges, respects undefined, and preserves the TypeScript types of both sides so the result is typed as the union (not any).

Install

npm install options-defaults