Artwork

内容由Wes Bos and Scott Tolinski - Full Stack JavaScript Web Developers提供。所有播客内容(包括剧集、图形和播客描述)均由 Wes Bos and Scott Tolinski - Full Stack JavaScript Web Developers 或其播客平台合作伙伴直接上传和提供。如果您认为有人在未经您许可的情况下使用您的受版权保护的作品,您可以按照此处概述的流程进行操作https://zh.player.fm/legal
Player FM -播客应用
使用Player FM应用程序离线!

TypeScript Fundamentals — Getting a Bit Deeper

1:08:51
 
分享
 

Manage episode 291019752 series 1469447
内容由Wes Bos and Scott Tolinski - Full Stack JavaScript Web Developers提供。所有播客内容(包括剧集、图形和播客描述)均由 Wes Bos and Scott Tolinski - Full Stack JavaScript Web Developers 或其播客平台合作伙伴直接上传和提供。如果您认为有人在未经您许可的情况下使用您的受版权保护的作品,您可以按照此处概述的流程进行操作https://zh.player.fm/legal

In this episode of Syntax, Scott and Wes continue their discussion of TypeScript Fundamentals with a deeper diver into more advanced use cases.

Deque - Sponsor

Deque’s axe DevTools makes accessibility testing easy and doesn’t require special expertise. Find and fix issues while you code. Get started with a free trial of axe DevTools Pro at deque.com/syntax. No credit card needed.

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.

Mux - Sponsor

Mux Video is an API-first platform that makes it easy for any developer to build beautiful video. Powered by data and designed by video experts, your video will work perfectly on every device, every time. Mux Video handles storage, encoding, and delivery so you can focus on building your product. Live streaming is just as easy and Mux will scale with you as you grow, whether you’re serving a few dozen streams or a few million. Visit mux.com/syntax.

Show Notes Deep end stuff

03:30 - any vs unknown

06:20 - never

13:25 - Type generation

  • Can be generated from GraphQL, or Schemas, or from JSON Output

17:20 - TypeScript generics (variables)

  • Kind of like functions, they return something different based on what you pass it
  • makeFood
  • makeFood
  • This function makes food and shares lots of the same functionality between making a pizza and sandwich
    • If the only thing that differs is the type returned, we can use generics
    • You often see this as a single char T
    • It can be anything
    • Promise is a generic
    • querySelector uses generics

21:48 - Promises / Async + Await

  • Functions now return a Promise type, but with a generic
  • Promise
  • Promise
  • Promise, Request, Request
    • stringified
    • added headers

29:48 - Type assertion (type casting)

  • Type assertion is when you want to tell TypeScript “Hey I know better than you”.
  • Two ways:
    • as keyword (most popular)
      • someValue as HTMLParagraphElement
      • Tagged before
        • someValue

34:14 - TypeScript without TypeScript (JSDoc / TSDoc)

40:08 - Interfaces vs Types

How we write TypeScript

44:27 - Interface or Types

  • Scott - Types
  • Wes - Interfaces

44:50 - any vs unknown

  • Scott - any
  • Wes - unknown / any

46:52 - Any (No Implicit or Implicit Allowed)

  • Scott - No implicit any
  • Wes - No implicit any

48:31 - Return types (Implicit or Explicit)

  • Scott - Explicit always
  • Wes - Not always

50:49 - Compile (TSC, Strip TS)

  • Scott - Strip
  • Wes - Both

52:38 - Type Assertion (as or )

  • Scott - as
  • Wes - as

53:09 - Arrays (Dog[] or Array)

  • Scott - Dog[]
  • Wes - Dog[]

54:02 - Assert or Generic (if both work)

  • querySelector(’.thing’) as HTMLVideoElement; or querySelector(’.thing’);
  • Scott - querySelector(’.thing’);
  • Wes - querySelector(’.thing’);
Links ××× SIIIIICK ××× PIIIICKS ××× Shameless Plugs Tweet us your tasty treats!
  continue reading

760集单集

Artwork
icon分享
 
Manage episode 291019752 series 1469447
内容由Wes Bos and Scott Tolinski - Full Stack JavaScript Web Developers提供。所有播客内容(包括剧集、图形和播客描述)均由 Wes Bos and Scott Tolinski - Full Stack JavaScript Web Developers 或其播客平台合作伙伴直接上传和提供。如果您认为有人在未经您许可的情况下使用您的受版权保护的作品,您可以按照此处概述的流程进行操作https://zh.player.fm/legal

In this episode of Syntax, Scott and Wes continue their discussion of TypeScript Fundamentals with a deeper diver into more advanced use cases.

Deque - Sponsor

Deque’s axe DevTools makes accessibility testing easy and doesn’t require special expertise. Find and fix issues while you code. Get started with a free trial of axe DevTools Pro at deque.com/syntax. No credit card needed.

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.

Mux - Sponsor

Mux Video is an API-first platform that makes it easy for any developer to build beautiful video. Powered by data and designed by video experts, your video will work perfectly on every device, every time. Mux Video handles storage, encoding, and delivery so you can focus on building your product. Live streaming is just as easy and Mux will scale with you as you grow, whether you’re serving a few dozen streams or a few million. Visit mux.com/syntax.

Show Notes Deep end stuff

03:30 - any vs unknown

06:20 - never

13:25 - Type generation

  • Can be generated from GraphQL, or Schemas, or from JSON Output

17:20 - TypeScript generics (variables)

  • Kind of like functions, they return something different based on what you pass it
  • makeFood
  • makeFood
  • This function makes food and shares lots of the same functionality between making a pizza and sandwich
    • If the only thing that differs is the type returned, we can use generics
    • You often see this as a single char T
    • It can be anything
    • Promise is a generic
    • querySelector uses generics

21:48 - Promises / Async + Await

  • Functions now return a Promise type, but with a generic
  • Promise
  • Promise
  • Promise, Request, Request
    • stringified
    • added headers

29:48 - Type assertion (type casting)

  • Type assertion is when you want to tell TypeScript “Hey I know better than you”.
  • Two ways:
    • as keyword (most popular)
      • someValue as HTMLParagraphElement
      • Tagged before
        • someValue

34:14 - TypeScript without TypeScript (JSDoc / TSDoc)

40:08 - Interfaces vs Types

How we write TypeScript

44:27 - Interface or Types

  • Scott - Types
  • Wes - Interfaces

44:50 - any vs unknown

  • Scott - any
  • Wes - unknown / any

46:52 - Any (No Implicit or Implicit Allowed)

  • Scott - No implicit any
  • Wes - No implicit any

48:31 - Return types (Implicit or Explicit)

  • Scott - Explicit always
  • Wes - Not always

50:49 - Compile (TSC, Strip TS)

  • Scott - Strip
  • Wes - Both

52:38 - Type Assertion (as or )

  • Scott - as
  • Wes - as

53:09 - Arrays (Dog[] or Array)

  • Scott - Dog[]
  • Wes - Dog[]

54:02 - Assert or Generic (if both work)

  • querySelector(’.thing’) as HTMLVideoElement; or querySelector(’.thing’);
  • Scott - querySelector(’.thing’);
  • Wes - querySelector(’.thing’);
Links ××× SIIIIICK ××× PIIIICKS ××× Shameless Plugs Tweet us your tasty treats!
  continue reading

760集单集

Alla avsnitt

×
 
Loading …

欢迎使用Player FM

Player FM正在网上搜索高质量的播客,以便您现在享受。它是最好的播客应用程序,适用于安卓、iPhone和网络。注册以跨设备同步订阅。

 

快速参考指南