Tasty
TypeScript!

It's pretty good!

Hi, I'm
Wes Bos

Hamilton, On 🇨🇦

@wesbos Tweet, tok and gram

Trice Weekly!

What is TypeScript?

TypeScript is JavaScript with a Type system added on top.

It's not really a new language, it's just JavaScript plus some descriptions about what your data looks like.

They really should have called it DescriptiveJavaScript!

First, What are Types?

Types describe the type of data in your application.

Wes, you just used the word to describe the word.

An array of strings, not really that complex 😆

But why?
What good is this extra typing?

TypeScript
Benefits

TypeScript has two main benefits:

  1. code authoring experience
    (more fun!)
  2. More resiliant codebase(less bugs!)

Let's break these down into some real world examples

Benefit #1

Amazing Autocomplete & Developer Productivity

Benefit #2

Error Detection

Benefit #3

Library
Typing

npm i @types/react

Benefit #4

Database
Typing

Benefit #5

Refactoring
is a breeze

Benefit #6

Edge case detection

Some important Concepts in TS

any vs unknown

Implicit vs Explict

Kind of important to know

Lots of things in TypeScript don't need to be typed.

They can be implied.

Tooling

Type Checking
and
Compiling to JS

TSC

Type Checks ✅

Compiles to JS ✅

SWC

Type Checks ❌

Compiles to JS ✅

Rust Based

Fast as heck

esbuild

Type Checks ❌

Compiles to JS ✅

Go Based

Fast as heck

vite

uses esbuild

Does everything

dev server, live reloader, bundler, css, frameworks..

parcel

uses swc

Does everything

dev server, live reloader, bundler, css, frameworks..

What to use?

For most projects, use vite or parcel

Tooling is SO GOOD right now

serverside

Node

tsx uses esbuild

ts-node uses tsc. Also has a --swc

Do we even need TypeScript?

JSDoc

Neat, eh?

Thanks