Builder13 min readBadge: Type Checker

TypeScript basics: types and reading the errors

What types are, the handful of TypeScript you'll see in AI-built apps, and how to read the type errors that stop a deploy.

Why TypeScript

TypeScript is JavaScript with types: labels that say what kind of value something holds. A type checker reads your code before it runs and flags mistakes like a misspelled field or text where a number belongs.

Browsers run plain JavaScript, so TypeScript is checked and then turned into JavaScript during the build. Most AI app builders write TypeScript (files ending in .ts and .tsx) because the checks catch the AI's slips too. When a deploy fails with 'Type error', this is what's talking.

The types you'll see most

  • Basic types: string (text), number, boolean (true or false), and arrays like string[] (a list of text).
  • Object shapes: type User = { name: string; email: string; age?: number }. The ? means optional: age may be missing, so it can be undefined.
  • Unions: type Status = "draft" | "sent" | "paid" allows only those three values, and string | null means 'some text, or nothing'.
  • Functions: function total(prices: number[]): number says what goes in (a list of numbers) and what comes out (a number).
  • any switches checking off for a value. AI tools sometimes add it to make an error go away. Treat it as a warning sign, not a fix.

Reading a type error

A type error names the file and line, then the mismatch. Read it as 'you gave X, but Y was expected'.

Type 'string' is not assignable to type 'number' means a value is text where the type says number, often a form field: convert it with Number(). Property 'titel' does not exist on type 'Post' usually means a typo, or a field the type doesn't define. Object is possibly 'undefined' means the value might not exist yet: check it first with if (user), or read it safely with user?.name and give a fallback with ??, as in user?.name ?? 'Guest'.

Fixing type errors with AI

  • Run the type check before you push (your build, or npx tsc --noEmit) so the deploy doesn't fail in front of everyone.
  • Paste the full error and the code around it. Ask for the cause first, then the smallest fix.
  • Be suspicious of fixes that add any, as unknown as, or // @ts-ignore. They hide the problem instead of solving it.
  • If a type and the database disagree, fix the source of truth (the type or the column), not just the line that errors.

Key terms

TypeScript
JavaScript with types that catch mistakes before the code runs.
Type (TypeScript)
A label for the kind of value something holds, like string, number or a User object.
Union type
A type that allows one of several options, like "draft" | "sent" | "paid", or string | null.
Optional chaining (?.)
Reads a property only if the thing before it exists; otherwise gives undefined instead of crashing.
any (TypeScript)
A type that switches checking off for a value. In AI-written code it often hides a real mistake.
JavaScript
The programming language that makes web pages interactive.
Deploy
Publish a version of your app to a host.
Debugging
Finding and fixing bugs, often by reading the exact error message.
See the full glossary

Try it

Fix three type errors

  1. Ask an AI for a tiny TypeScript file with a User type (name, email, optional age) and a function that greets a user.
  2. Paste it into the TypeScript Playground (typescriptlang.org/play) and hover over names to see their types.
  3. Make three mistakes on purpose: misspell a field, pass a number as text, and read age without checking it.
  4. Read each error out loud as 'you gave X, but Y was expected', then fix each one without using any.

Ask an AI tutor about this guide

Copy a prompt into ChatGPT, Claude or Gemini to go deeper. Check what it tells you against the guide.

Study with an AI tutor: copy this whole guide with tutoring instructions, then paste it into your AI assistant.
  • Explain it like I'm 12
  • Quiz me (5 questions, one at a time)
  • Show me a real example for my situation
  • What do beginners get wrong?

Knowledge check

Five questions. Get 4 right to earn the Type Checker badge. You can retake it as often as you like.

Question 1 of 5

What does TypeScript add to JavaScript?

Finished the How software works guides? Take the How software works track test for ten mixed questions.

My notes

Write what clicked, what confused you, and what you want to try. Saved in this browser only.

Learn it live

Digital Builders University runs small live workshops where you build something real with an instructor beside you, starting with Vibe Coding 101.

See workshops

Practise it

Last reviewed November 25, 2026. AI tools change fast; check each tool’s own site for current features, plans and prices.