Skip to content

Instantly share code, notes, and snippets.

View David-Else's full-sized avatar

David Else David-Else

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.
@Raekkeri
Raekkeri / vimrc-git
Last active April 2, 2021 21:17
Lightweight Git shortcuts for Vim
" Lightweight alternative to vim-fugitive:
" The following `:Git` command looks up the Git repository of the current file,
" and launches `git` in the root directory of that repository. This way, you can
" launch vim anywhere outside the Git repository, and, e.g. have open files from
" multiple Git repositories, and `:Git <args>` command always points to the
" right repository.
" One thing to note, however, is that "%" doesn't necessarily point to a correct
" path (so for example `:Git commit %` might not work), but in this case "%:p"
" should be one way to work around the issue.