Skip to content

Instantly share code, notes, and snippets.

View sohamsshah's full-sized avatar
🎯
Focusing

Soham Shah sohamsshah

🎯
Focusing
View GitHub Profile
@sohamsshah
sohamsshah / react_custom_vscode_snippets.json
Last active March 1, 2023 06:54
Custom React Code Snippet for VSCode
{
"reactArrowFunctionComponentWithDisplayName": {
"prefix": "rafcd",
"body": [
"export const ${1:${TM_FILENAME_BASE}} = () => {",
" return (",
" <div>${1:first}</div>",
" )",
"}",
"",
@laughinghan
laughinghan / Every possible TypeScript type.md
Last active June 19, 2024 10:18
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.