language Introduced in L3

TypeScript

JavaScript with a type system. The language most production codebases use, even ones that look like JavaScript.

Mindmap

hover · click to navigate
this tech depends on / used by alternative Shipyard anchor
What it is

The plain-English version

TypeScript is a language that compiles down to JavaScript and adds a static type system. You write function add(a: number, b: number): number instead of function add(a, b). The compiler catches type errors before they ship. The output is plain JS that runs anywhere JS does.

Why it exists

The problem it solves

JavaScript's loose typing is a gift in small scripts and a liability in big codebases. TypeScript catches a class of bugs before runtime, makes refactoring safer, and gives editors real autocomplete. By 2024 it's the default in most production codebases — and most modern AI agents use it by default unless told otherwise.

What it competes with

Alternatives

AlternativeTypeWhen it wins
Node.jsruntimeJavaScript outside the browser. The runtime that powers most modern web backends, build tooling, and AI agent CLIs.
PythonlanguageThe default language of data, ML, and quick scripts. Increasingly the second language even in JS-first stacks.
Where it shows up in Shipyard

Deep links

Vocabulary

The words you'll hear

Type
A description of what shape a value has. string, number, {name: string}.
Interface
A named type for an object shape. interface Task { id: string; title: string }.
Generic
A type parameter. function first<T>(arr: T[]): T — a function whose type depends on its input.
Union / intersection
string | number (either) and A & B (both).
Type guard
A check at runtime that narrows a type. if (typeof x === "string") {...}.
strict
Compiler flag. Turns on null checks, no-implicit-any, etc. Always start strict.
Prompting

Bad vs. good prompt for TypeScript

✕ Bad prompt
Add types to this
✓ Good prompt
Add TypeScript types to this React component. Use strict mode (no `any`). Define a Task interface in src/types/Task.ts and import it. Mark optional fields with `?`. Use union types for status ("todo" | "doing" | "done"). Add JSDoc comments to exported functions.

Why it works: Specifies strict, says where shared types live, names the union, asks for documentation. Prevents the agent from peppering the file with any.

Pitfalls

What bites real teams

⚠ Reaching for any

any opts out of the type system. Use unknown instead — it forces you to narrow before using the value.

⚠ Type vs runtime

TypeScript types vanish at runtime. typeof, instanceof, schema libraries (Zod, Valibot) bring type-safety to data crossing the boundary.

⚠ Over-typing

Don't write a generic when a simple type works. Don't write conditional types when a union works. Read the existing code's style.

References

Official docs only