Writing React with TypeScript

skurfuerst

Sebastian Kurfürst

Posted on January 2, 2019

Writing React with TypeScript

Just a quick note today as I stumbled over a a nice GitHub repo:

We've made good experiences writing React Applications with TypeScript -- and I just now stumbled across a good cheat sheet which summarizes many of the lessons learned:

GitHub logo typescript-cheatsheets / react-typescript-cheatsheet

Cheatsheets for experienced React developers getting started with TypeScript

React+TypeScript Cheatsheets

react + ts logo

Cheatsheets for experienced React developers getting started with TypeScript

Web docs | 中文翻译 | Español | Contribute! | Ask!


👋 This repo is maintained by @swyx, @ferdaber, @eps1lon, @IslamAttrash, and @jsjoeio, we're so happy you want to try out TypeScript with React! If you see anything wrong or missing, please file an issue! 👍


All Contributors

All React + TypeScript Cheatsheets

  • The Basic Cheatsheet (/README.md) is focused on helping React devs just start using TS in React apps
    • Focus on opinionated best practices, copy+pastable examples.
    • Explains some basic TS types usage and setup along the way.
    • Answers the most Frequently Asked Questions.
    • Does not cover generic type logic in detail. Instead we prefer to teach simple troubleshooting techniques for newbies.
    • The goal is to get effective with TS without learning too much TS.
  • The Advanced Cheatsheet (/ADVANCED.md) helps show and…

We've summarized our own best practices at sandstorm in a GitHub boilerplate (created by my great colleague Robert Baruck), with the best practices summarized in a GitBook:

GitHub logo sandstorm / typescript-react-app-kickstart-guide

Kickstart guide for React Redux Apps written in TypeScript

React TypeScript kickstart

This the source for a guide for kickstarting a new React project with preconfigured Redux, TypeScript, Storybook and testing - all powered by docusaurus. If you find errors, inconsistencies or want to contribute: Feel free to submit issues & pull requests.

Prerequisites

These tools are needed to start developing.

# node version management
brew install nvm

# node (latest lts version)
nvm install --lts

# yarn
brew install yarn --without-node

Editor

We recommend to use VSCode as editor. Install the following Extensions:

  • TSLint -> linting support directly in editor (marketplace)
  • Type safe React & Redux Snippets in TypeScript -> Snippets for boilerplate code as shown in Cookbook (marketplace)

Cookbook

In the cookbook you will find skeletons for important modules. These skeletons are also available for VSCode as snippets in the VSCode marketplace.

Example (Component with defaultProps)

Look, Ma' - Intellisense!

component with defaultProps example




We've also published [a VSCode Snippet Extension(https://marketplace.visualstudio.com/items?itemName=Sandstorm.vscode-awesome-ts-react-redux-snippets) which helps to write TypeScript/React with little boilerplate.

What are your experiences writing React + TypeScript?

All the best,
Sebastian

💖 💪 🙅 🚩
skurfuerst
Sebastian Kurfürst

Posted on January 2, 2019

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Writing React with TypeScript
react Writing React with TypeScript

January 2, 2019