News Score: Score the News, Sort the News, Rewrite the Headlines

Python-style kwargs in TypeScript

My TypeScript function signatures always start small. There's usually an optional argument or two, but the call sites are easy to reason about:const greet = (name: string, prefix = "Hello") => `${prefix}, ${name}.`; greet("Alice"); // "Hello, Alice." greet("Bob", "!"); // "Hello, Bob!"But as these functions grow, it's cumbersome to specify the last optional argument while using defaults for the rest:const greet = ( name: string, prefix = "Hello", ending = ".", extraNames: string[] | undefined = ...

Read more at xavd.id

© News Score  score the news, sort the news, rewrite the headlines