Skip to content
Typing Summit

TypeScript typing practice

Type real TypeScript: interfaces, generics, union types and a React component. TypeScript adds colons, angle brackets and pipes on top of JavaScript, so this page drills exactly those.

4 snippets · key symbols: : < > | ? { } =>

Types and generics · TypeScript
Press Enter at the end of each line. Indentation is filled in for you.
type Result<T> = { ok: true; data: T } | { ok: false; error: string };↵↵function parse<T>(json: string): Result<T> {↵ try {↵ return { ok: true, data: JSON.parse(json) as T };↵ } catch (e) {↵ return { ok: false, error: String(e) };↵ }↵}
Guide

How to type TypeScript faster

TypeScript has its own set of symbols and patterns. Typing them in real code, with Enter and auto-indent like your editor, builds speed where it matters.

  1. 01

    Type annotations

    Every parameter and return type adds a colon and a type name. Typing them smoothly keeps type safety from feeling like a slowdown.
  2. 02

    Generics and unions

    Angle brackets for generics and the pipe for union types are awkward reaches for most people. Short snippets let you repeat them until they are automatic.
  3. 03

    JSX

    The React snippet mixes TypeScript with JSX tags and curly braces, the most symbol-dense code most front end developers write.

Questions people ask

2 answers

Is TypeScript harder to type than JavaScript?

+

A little. It adds colons, angle brackets, pipes and question marks. With practice they become as quick as letters.

Which keys should TypeScript developers practise?

+

The shift-row symbols: colon, angle brackets, pipe, question mark and curly braces.