Playing: 324: TypeScript Fundamentals
Sep 9th, 2022
Supper Club × The Primeagan - Vim, Streaming, Rust, all Around Interesting Guy
Sep 7th, 2022
Potluck - How to Pick a Tech Stack × useEffect × setTimeout × Staying Focused
Aug 17th, 2022
Job Types Agency, Tech, Startup, Entrepreneur VS Tech company VS In House
Jul 15th, 2022
Supper Club × 70,000 Serverless Functions with Kristi Perreault of Liberty Mutual
May 9th, 2022
TypeScript Fundamentals × Narrowing, Discriminating Unions, and Type Guards
Apr 20th, 2022
Potluck - Working on a Team × Dealing with Imposter Syndrome × Animating on the Web × Icon Libraries × Demanding Clients
Apr 13th, 2022
Potluck - Multi Tenant Apps, JS Sprinkles, Kids Coding, Server Error Handling
Apr 6th, 2022
Making Content × What is our Process? Youtube, Blog Posts, Courses, Conference Talks, and Podcasts
Mar 16th, 2022
Potluck - Handling Auth × Are Web Dev Real Developers? × Handling Git Conflicts × Converting PNG to Box-Shadow × Bad Docs vs No Docs × Making Shopify Headless
Feb 16th, 2022
Potluck - Selling Themes × Which Browser Should Devs Use? × Where Do You Keep 2FA Codes? × Remix vs Svelte Kit × Getting Unstuck from Tutorial Hell
Dec 8th, 2021
Nov 17th, 2021
Potluck — Copilot × Glasses × Databases × Dealing with Stress × Employment vs Self-Employment × Auth in GraphQL × Headless CMS × More!
Nov 10th, 2021
Web Containers, StackBlitz, and Node.js in the Browser with Tomek Sulkowski
Oct 20th, 2021
Potluck — Coding for Kids × MongoDB Hosting × NoMoreFoo × Best Cities for Dev Jobs × GraphQL Resolvers × Package Security × Prototypes and Portfolios × More!
Oct 6th, 2021
Potluck — Corn Shucking × Self-Hosting Images × WordPress × Getting Scammed × Portfolios
Sep 8th, 2021
Potluck - Sass × Houdini × No JS? × Solid Project × First Dev Job Tips × Bartering × DRM × Dev Laptops × Databases × Frontity × More!
Aug 18th, 2021
Potluck - Moist code × Memoization × Ready for full-time? × Deadlines × Design ethics × React components × Video hosting × Local fonts × More!
Aug 4th, 2021
Potluck - WordPress × 3rd-Party Cloud Services × Backend Hosting × Drupal × Getting Clients × GPS vs BEM × More!
Aug 2nd, 2021
Hasty Treat - Git the Latest - New Things In Tech - CoPilot, Petite Vue, Stackblitz, Web3 + More!
Jul 21st, 2021
Potluck - Svelte × Bleeding-Edge Tech × Git Process × Screencasts × Government Jobs × Permissions-Based APIs × Rescript × More!
Jul 5th, 2021
Jun 28th, 2021
Jun 23rd, 2021
Potluck - Web components × Gear × Docker × Web Dev Frameworks × Golden Handcuffs × Browser Testing × SSR React × Code Prediction × More!
Jun 9th, 2021
Potluck - Immutability × Turning Off Your Brain × Types vs Interfaces × Hooks vs Components × Making the Most of Your First Job × Confidence in Svelte × More!
May 12th, 2021
Potluck — Freelancing × Leveraging your experience × Component size × Dealing with mediocrity × How to spend "extra time" × Rust vs Node × Free hosting? × More!
May 5th, 2021
Potluck — Is it worth it to still learn WordPress? × Is Safari the new IE11? × Mobile website testing × Pirated content × Styled components × SSGs × Transitioning to full-time freelance × More!
Apr 7th, 2021
Potluck — Video Hosting × Fake Names? × Portfolio Projects × Monorepos × APIs × TLDs × Recording Tips × More!
Mar 10th, 2021
Potluck — VSCode × Vercel vs Netlify × Models × Mutations × Multi-Vendor Platforms × Websites vs Web Apps × More!
Feb 17th, 2021
Potluck — Do titles matter? × Should clients pay for plugins? × Can I debug my baby? × How we prepare for Syntax × Deno × Learning things quickly × More!
Jan 20th, 2021
Potluck — $100k Dev Jobs × Sponsored Blog Posts × How To Keep Your Skills Up To Date × Libraries vs Custom × Dev Tools × More!
Jan 4th, 2021
Hasty Treat - Hyper Productivity with Keyboard Shortcuts + Window Management
Dec 23rd, 2020
Potluck — New Macs × Podcast Statistics × E-commerce Testing × WordPress × Charging More × Learning Web Dev × More!
Nov 25th, 2020
Potluck - Frameworks vs Libraries × Debugging × CSS Modules vs Styled Components × Resumes × Stress Management × More!
Oct 7th, 2020
Potluck - Is Angular good? × Stencil.js × Self XSS × SVGs in React × Social Platforms for Devs × Project Handoff × Cleaning Knives × More!
Sep 21st, 2020
Hasty Treat - Our First Bucks Made From Web Dev, Teaching, YouTube and Tutorials
Sep 9th, 2020
Tales from Webdev Past - Clearfix × Floats × Cufon × Guestbooks × PNG Fix × More!
Sep 2nd, 2020
Potluck - RIP Firefox? × Safari × Changing Careers × Regression Testing × Google Analytics Alternatives × Malicious Github Users? × Mac vs Windows × More!
Aug 26th, 2020
Potluck - MDX × Portfolio Projects × Code Commenting × CSS Properties × Reusable Components × More!
Aug 19th, 2020
Potluck - Subscriptions × ES Modules in Node × Chicken Thigh × Being a Good Dad × Refactoring × More!
Jul 27th, 2020
Hasty Treat - Target=_blank security issue? What's the deal with noopener and noreferrer?
Jul 22nd, 2020
Potluck - Beating Procrastination × Rollup vs Webpack × Leadership × Code Planning × Styled Components × More!
Jul 6th, 2020
Hasty Treat - Forms, Captchas, Honeypots, Dealing With Malicious Users and the Sad State of Contact Forms
Jun 24th, 2020
Potluck - Libraries vs Frameworks × Firefox × Career Advice For Teenagers × Who Would Win a Thumb War? × More!
Jun 17th, 2020
The Fundamentals Leftovers - Terminal, Shortcuts, View Source, Github + More!
May 27th, 2020
Potluck - Courses for Kids × Sub-Components × Recursion × DB Hosting × Frameworks × Data Structures & Algorithms × More!
Apr 29th, 2020
Potluck Part 2 - Magic GQLess × Are classes dead? × Custom Hooks × Staying Up To Date × CSS × More!
Apr 22nd, 2020
Potluck - Mobile First × Arrow Functions × Deno × JSON APIs × Refactoring Tips × More!
Apr 1st, 2020
Mental Health and Dev ft Dr. Courtney Tolinski - Depression, Anxiety, Imposter Syndrome, Focus, Motivation, Burnout
Mar 25th, 2020
Potluck - Bootcamps × Career Change × Figma × Gatsby × AMP × Mongoose × More!
Feb 26th, 2020
Potluck - Next vs Gatsby × Headless CMS × Vue.js × Is Ruby on Rails still good? × More!
Jan 29th, 2020
Potluck - Dev Culture Fit × Slack Communities × Vanilla JS × Backpacks × Raspberry Pi × More!
Jan 27th, 2020
Hasty Treat - Building A Community Slack, Discord, Spectrum, Discourse, Forums
Jan 20th, 2020
Hasty Treat - Picking the Stack for uses.tech - Gatsby, React, Context, Styled Components
Jan 1st, 2020
Potluck - Fonts × Frameworks × Teas × Coding Subscriptions × Client Work × More!
Dec 4th, 2019
Potluck - Tabs are better? × Coding Music × SEO × Is Angular good? × Biggie Smalls × Soy Sauce × More!
Nov 6th, 2019
Potluck - Gatsby vs Next × Is Google Home spying on you? × Flat File CMS × CSS Frameworks × Hosting Client Sites × More!
Oct 9th, 2019
Potluck - Terminal Configs × CSS Reset × Flexbox × Freelancing × NPM Dependencies × Project Hand-off × More!
Sep 18th, 2019
Potluck - Why Webpack? × Serverless × Agencies × Recruiters × CSS Grid × MQ in Styled Components
Aug 21st, 2019
Potluck - Deploying Applications × Typescript × Live Coding with Twitch × Fullstack Architecture × More!
Jul 31st, 2019
Potluck - What is "State"? × Web Sockets × Remote Working × Firefox × Machines Taking Our Jobs × More!
Jun 26th, 2019
Potluck - Career Switch at 33 × Cover Letters × Kids × Learning Quickly × More!
May 29th, 2019
Potluck - CSS × Angular × Dev job preparation × Svelte × File organization × Gear × More!
May 1st, 2019
Potluck - Media Queries × NPM Vulnerabilities × Fullstack JS vs JAMstack × Web VR/AR × Switching Jobs × More!
Apr 3rd, 2019
Potluck - Interview Qs × Headless CMS × React Hooks × Resume Design × Redux vs Context × More!
Mar 6th, 2019
Potluck - Are classes dead? × Tutorials vs Real Life × CRA vs Next × Scraping × More
Mar 4th, 2019
Hasty Treat - Authentication - LocalStorage vs Cookies vs Sessions vs Tokens
Feb 27th, 2019
How We Manage Our Lives — Notion, Todos, Notes, Focusing, Calendars, Goal tracking, and more!
Feb 6th, 2019
Potluck - Changing careers × Repo organization × CSS Grid × Certifications × Freelancing × Spammers × More
Jan 10th, 2019
Potluck - Where to start with JS × Freelancing × Cron jobs × Split testing × Frameworks in 2019 × More
Dec 19th, 2018
Potluck - Typescript × E-commerce platforms × Job-hopping × Working for agencies × more
Dec 17th, 2018
Hasty Treat - Where are they now?! Gulp, Grunt, Bower, Backbone and Compass
Nov 21st, 2018
Potluck - $100/hr × Redux Replacements × Full Stack Designers × JWT × VS Code Tips × More
Oct 26th, 2018
Potluck - Working with designers × Is WordPress Crap? × When to stop working × More
Aug 29th, 2018
Potluck - Programming Languages × Soft Skills × PHP vs JS × Breakdancing x Spice Blends
Aug 1st, 2018
Potluck - Editor Fonts × Portfolios × Meetup Tips × Switching to Windows × Freelancing Sources
Jul 24th, 2018
The Undocumented Web - scraping, private APIs, proxies and “alternative solutions”
Jul 18th, 2018
Advice For Beginners - Tech Skills, Applying for Jobs, Focus, Imposter Syndrome + More
Jul 4th, 2018
Potluck EP × Remote Work × Headless WordPress × Good Client Questions × Alternate Careers × React API Credentials
May 9th, 2018
Potluck EP × Is Redux Dead × Learning Quickly × Developing Solo × Specialist vs Generalist × Funnest Projects × Wes’ BBQ Course
Apr 18th, 2018
Potluck EP × Vue.js × Headless WP × Typescript & Flow × Productivity × Server Side Rendering × Yeoman
Feb 7th, 2018
Wes and Scott's Lives - Breakdancing, BBQ, Wives, Work/Life Balance, Problem Solving, YouTube Subscriptions
Jan 31st, 2018
Snack Pack — CSS Frameworks, React HOC, Render Props, Coding Designers, Early Career Advice and a sound board!
Jan 24th, 2018
Hosting & Servers — Heroku, Now, Galaxy, Digital Ocean, Linode, Docker, Netlify and more!
Nov 29th, 2017
What's New in CSS? Variables, Scoping, New Selectors and Color Functions
Nov 1st, 2017
22 Buzz Words Explained — Mutations, Pure Functions , Serverless, Hoisting, MVC + More
Oct 18th, 2017
Tasty Treats — Rems VS Ems, Remote Work, Making Money, Getting good at Design + more! 🍬
Feb 3rd, 2021
TypeScript Fundamentals👇 Download Show✏️ Edit Show Notes
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.
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
- 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
- We only have numbers in TS, no floats/ints
- We do have BigInt though, but not something most people will use
- Will be a list of another type
- This type will be one of the possible options
- String of DRAFT PUBLISHED or ARCHIVED
- An intersection type combines multiple types into one
- These are custom types where each property is its own type
- Explicit any
- Implicit any
- Language types
- These things are technically just Objects, but they have their own types
- DOM Elements / Nodes
- When a function returns nothing — usually used with side effects like click handlers
- 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
- A set of named constants
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
- 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
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
××× SIIIIICK ××× PIIIICKS ×××
- Scott: ESM & Snowpack - Sign up for the year and save 25%!
- Wes: All Courses - Use the coupon code 'Syntax' for $10 off!