Typescript Cheat Sheet 2020



Due to the great interest in previous Cheat Sheets and requests for another. Here you are, new cheat sheet, this time for React (finally!). Compressed overview for fundamental functionalities. Red Hat Developer cheat sheets 🌟 Browse through our collection of cheat sheets to help you develop with Red Hat products, which you can download for free as a Red Hat Developer member. You’ll find handy guides on a range of the latest developer tools and technologies, including Kubernetes, microservices, containers, and more. Spread the love Related Posts JavaScript Best Practices — Modern SyntaxThere are better ways to write JavaScript code than others. In this article, we’ll look JavaScript Best Practices — Basic SyntaxLike any kind of app, JavaScript apps also have to be written well. Otherwise, we JavaScript Best Practices — No Useless SyntaxTo make code easy to read and maintain, we should. Npm install -g expo-cli expo init AwesomeProject //choose a typescript template cd AwesomeProject expo start // If you want to use the bare workflow run expo eject b/ using React Native CLI. If you need to link specific native libraries not supported by expo you can start with React Native CLI or eject Expo.

← Go Back
Broken Post? → Let me know
2020

Introduction

A note to self lest I forget the resources I learned from.

As I was going thru Swyx's React TypeScript Cheatsheet, Props: Omit prop from a type, I had trouble understand the definition of Omit.

Could not wrap my heads around it so Googled and found Marius Schulz's blog posts.

Blog read order

I read these backwards initially but the posts in following order seems to make sense.

  1. keyof and Lookup Types in TypeScript - Learn about keyof used for Omit and Exclude
  2. Conditional Types in TypeScript - To understand Exclude
  3. The Omit Helper Type in TypeScript - To finally learn how Omit is implemented

References

Advaned utlity type document and sources for Peanut obsidian.

  1. Omit<Type, Keys>

    • Definition: Constructs a type by picking all properties from Type and then removing Keys.
    • Documentation: https://www.typescriptlang.org/docs/handbook/utility-types.html#omittype-keys
    • Source: https://github.com/microsoft/TypeScript/blob/master/lib/lib.es5.d.ts#L1504
  2. Pick<Type, Keys>

    • Definition: Constructs a type by picking the set of properties Keys from Type.
    • Documentation: https://www.typescriptlang.org/docs/handbook/utility-types.html#picktype-keys
    • Source: https://github.com/microsoft/TypeScript/blob/master/lib/lib.es5.d.ts#L1480
  3. Exclude<Type, ExcludedUnion>

    • Definition: Constructs a type by excluding from Type all union members that are assignable to ExcludedUnion.
    • Documentation: https://www.typescriptlang.org/docs/handbook/utility-types.html#excludetype-excludedunion
    • Source: https://github.com/microsoft/TypeScript/blob/master/lib/lib.es5.d.ts#L1494

Typescript Cheat Sheet 2020 Printable

Misc. Link

Need to watch Marius Schulz's Egghead course, Advanced Static Types in TypeScript.

Sheet

Typescript React Cheat Sheet

Image by Edward Lich from Pixabay

cuz, Donut's hole reminds me of Omit 😉

Webmentions

Loading counts..

Jsdoc Typescript Cheat Sheet

Fetching Replies..