Get the latest tech news

Python-Style Kwargs in TypeScript


A pain-free way to write expressive, readable typed option bags in TypeScript.

Those floating undefined s are also impossible to reason about unless your development environment can show you the underlying argument names. Python's solution is to let callers specify the names of arguments (which is why they're called k ey w ord args, since they're specified by their keyword): Typed option bags lke this are one of my favorite TypeScript patterns, but I don't feel like I see it often.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of TypeScript

TypeScript

Photo of Style Kwargs

Style Kwargs

Related news:

News photo

Building a better online editor for TypeScript

News photo

Ripple – A TypeScript UI framework that takes the best of React, Solid, Svelte

News photo

Show HN: Regolith – Regex library that prevents ReDoS CVEs in TypeScript