TypeScript

Generic parameter defaults: any[] = []

Consider a function that creates a new HTMLElement, calling it with no arguments generates a Div; you can optionally pass a list of children as well. Previously you would have to define it as:

  1. declare function create(): Container<HTMLDivElement, HTMLDivElement[]>;
  2. declare function create<T extends HTMLElement>(element: T): Container<T, T[]>;
  3. declare function create<T extends HTMLElement, U extends HTMLElement>(
  4. element: T,
  5. children: U[]
  6. ): Container<T, U[]>;

With generic parameter defaults we can reduce it to:

  1. declare function create<T extends HTMLElement = HTMLDivElement, U = T[]>(
  2. element?: T,
  3. children?: U
  4. ): Container<T, U>;

Git

global ignore

git config —global core.excludesfile ~/.gitignore_global
echo .DS_Store >> ~/.gitignore_global