Skip to content

Instantly share code, notes, and snippets.

View zachlysobey's full-sized avatar

Zachary Lysobey zachlysobey

View GitHub Profile
@laughinghan
laughinghan / Every possible TypeScript type.md
Last active March 31, 2024 04:40
Diagram of every possible TypeScript type

Hasse diagram of every possible TypeScript type

  • any: magic, ill-behaved type that acts like a combination of never (the proper [bottom type]) and unknown (the proper [top type])
    • Anything except never is assignable to any, and any is assignable to anything at all.
    • Identities: any & AnyTypeExpression = any, any | AnyTypeExpression = any
    • Key TypeScript feature that allows for [gradual typing].
  • unknown: proper, well-behaved [top type]
    • Anything at all is assignable to unknown. unknown is only assignable to itself (unknown) and any.
    • Identities: unknown & AnyTypeExpression = AnyTypeExpression, unknown | AnyTypeExpression = unknown
  • Prefer over any whenever possible. Anywhere in well-typed code you're tempted to use any, you probably want unknown.
@ProLoser
ProLoser / focusOn.js
Created November 24, 2015 01:19
Focuses on input/element
/**
* focusOn - Focuses an input on scope event
*
* @example
* <input focus-on="someEventName">
* or
* <input focus-on="focus-row-{{$index}}">
* or
* <p focus-on="anotherEvent"></p>
* ...