meta_pixel
Tapesearch Logo
Log in
Syntax - Tasty Web Development Treats

TypeScript Fundamentals

Syntax - Tasty Web Development Treats

Wes Bos

Tech News, Technology, News

4.91.2K Ratings

🗓️ 3 February 2021

⏱️ 59 minutes

🧾️ Download transcript

Summary

In this episode of Syntax, Scott and Wes talk about TypeScript fundamentals — what it is, how you use it, why people love it so much, and more! Sanity - Sponsor Sanity.io is a real-time headless CMS with a fully customizable Content Studio built in React. Get a Sanity powered site up and running in minutes at sanity.io/create. Get an awesome supercharged free developer plan on sanity.io/syntax. LogRocket - Sponsor LogRocket lets you replay what users do on your site, helping you reproduce bugs and fix issues faster. It’s an exception tracker, a session re-player and a performance monitor. Get 14 days free at logrocket.com/syntax. Cloudinary - Sponsor Cloudinary is the best way to manage images and videos in the cloud. Edit and transform for any use case, from performance to personalization, using Cloudinary’s APIs, SDKs, widgets, and integrations. Show Notes What is TypeScript? 03:12 - Types? What are types and why should you care? JS is a typed language, it’s just not strongly typed JS does not care about reassignment of a variable to a new type Does not care about your types, but they do exist 06:34 - The Fundamentals You write your JavaScript code, but each time you create a variable, function, parameter, you “type it” — which means you describe what that data will look like. Create a variable: Will it be a string? A number? A custom type of show? Create a function: What params does it take? What type are they? What does it return? Types allow your code to know if there are type errors that would present themselves to the user silently. These are small errors that can be compounded and go unnoticed. This can allow you to prevent shipping code that has these errors by checking your code. Some of the biggest benefits here come via errors in your text editor 13:30 - Explaining the types You can create your own types Strings Numbers We only have numbers in TS, no floats/ints We do have BigInt though, but not something most people will use Arrays Will be a list of another type Unions This type will be one of the possible options String of DRAFT PUBLISHED or ARCHIVED Intersections An intersection type combines multiple types into one Objects These are custom types where each property is its own type Any Explicit any Implicit any Language types These things are technically just Objects, but they have their own types Dates Timeouts DOM Elements / Nodes Void When a function returns nothing — usually used with side effects like click handlers Enum A set of named constants Used when you have a select amount of values — I like to think of these as the select lists of TS String unions are also used for this same thing 30:28 - Inference Automatic detection of types Typescript will try to infer your types based on their definition Not every type can be inferred, leading to implicit anys and the need for explicit types 33:25 - Getting types Most popular packages already have types — you install them like npm i @types/whatever If a package doesn’t have types, you have to create them yourself, which can be annoying MakeTypes Console log a JSON.stringify(obj), and pipe it in Node has types Vanilla JS has types, for the language and all of the DOM - HTMLInputElement React has types Typing Node modules that don’t have types Overall benefits 40:39 - Type hinting With TS and your editor (VSCode) you’ll get more information about your code as you type it — allowing you to know exactly what things expect This seems like a small deal but in practice leads to being much more efficient 42:50 - Refactoring Rename a function, type, or variable and it will be updated everywhere in the project! Moving a function to a new file is actually part of TypeScript Drag + Drop file, update imports 48:10 - Compiling TSC vs Babel / Esbuild Only TSC type checks Compiling TS with babel will not allow you to break the build on type errors, you’ll need to run TSC in coordination or in the CI/CD Links Snipcart GraphQL Snowpack ××× SIIIIICK ××× PIIIICKS ××× Scott: 1: LumiPets 2: LumiPets Bear Wes: Phomemo Label Printer Shameless Plugs Scott: ESM & Snowpack - Sign up for the year and save 25%! Wes: All Courses - Use the coupon code ‘Syntax’ for $10 off! Tweet us your tasty treats! Scott’s Instagram LevelUpTutorials Instagram Wes’ Instagram Wes’ Twitter Wes’ Facebook Scott’s Twitter Make sure to include @SyntaxFM in your tweets

Transcript

Click on a timestamp to play from that location

0:00.0

You're listening to syntax the podcast with the tastiest web development treats out there strap yourself in and get ready

0:07.7

Here is Scott to Lensky and West boss. Welcome to syntax. This is the podcast with the tastiest type-safe treats out there

0:18.0

Today we've got a long time coming show and is TypeScript fundamental

0:23.3

So this is the first of many TypeScript shows that we will have probably over the course of the year

0:28.7

And this one will sort of get you up to speed with what it is

0:32.4

What are the different parts? What are the benefits? Why do people love it so much?

0:36.8

Well, how do you use it things like that? And then we'll have future episodes that dive into some of the

0:41.6

The more nitty-gritty more complex topics of it

0:44.8

Today we are sponsored by

0:47.1

Three awesome companies. First one is sanity structured content

0:50.5

CMS second one is log rocket

0:53.1

JavaScript session replay and third one is cloudinary image hosting processing

0:59.3

resizing resampling

1:01.2

Requalifying everything around images. We'll talk about them partway through the episode. How you doing today? Scott

1:08.0

Hey, I'm doing good. I'm getting into a lot of code stuff

1:12.1

just

1:13.2

Working on the the next build of level up tutorials.com

1:16.1

Which is is been a significant project because we're using a lot of like really neat future tech in it

1:21.3

So I've just been really really heads down in that and we recently decided to rip just and react testing library

1:29.0

Out of the the code base for the front-end tests entirely

1:32.6

Not because of any problem with let's say react testing library

1:35.9

But I think I just got so sick of just garbage on the UI

...

Please login to see the full transcript.

Disclaimer: The podcast and artwork embedded on this page are from Wes Bos, and are the property of its owner and not affiliated with or endorsed by Tapesearch.

Generated transcripts are the property of Wes Bos and are distributed freely under the Fair Use doctrine. Transcripts generated by Tapesearch are not guaranteed to be accurate.

Copyright © Tapesearch 2026.