Fireship · @fireship

TypeScript - The Basics

Uploaded November 29, 2018 · Length 12:01

TypeScript - The Basics

Summary

Learn the basics of TypeScript, a superset of JavaScript, and its benefits for productivity and code quality.

  • typescript basics
  • javascript superset
  • typescript benefits
  • productivity with typescript
  • typescript for web development

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    I can pretty easily say that the one

  2. 0:08

    tool that's had the biggest impact on my

  3. 0:09

    productivity as a web developer is

  4. 0:11

    typescript and that's pretty amazing

  5. 0:13

    considering a few years ago I had no

  6. 0:14

    interest in learning it and was only

  7. 0:16

    exposed to it because I had a client

  8. 0:17

    that required an angular app in today's

  9. 0:19

    video I'm gonna show you all the basic

  10. 0:20

    concepts needed to be successful with

  11. 0:22

    typescript and I'll throw in a few pro

  12. 0:24

    tips here and there that I find

  13. 0:25

    especially useful if you're new here

  14. 0:27

    like and subscribe and there will be a

  15. 0:28

    t-shirt giveaway with this video all you

  16. 0:30

    have to do is leave a comment below and

  17. 0:31

    we'll pick a random winner next week I

  18. 0:33

    want to start with a shout-out to

  19. 0:35

    basarat Syed who is the author of the

  20. 0:37

    typescript deep dive book it's my go-to

  21. 0:39

    resource for advanced concepts and it's

  22. 0:41

    free and open source so originally I was

  23. 0:43

    resistant to even learn typescript

  24. 0:45

    because I wasn't super comfortable with

  25. 0:46

    strong typed languages and I really

  26. 0:48

    tried to avoid writing any more code

  27. 0:49

    than I have to but this is the situation

  28. 0:51

    where writing a little more code upfront

  29. 0:52

    will pay big dividends as your project

  30. 0:54

    grows the biggest benefit is actually

  31. 0:56

    just tooling what you get in your IDE

  32. 0:58

    like vs code when you use type

  33. 1:00

    annotations or work with libraries that

  34. 1:02

    are strong typed your code will be

  35. 1:03

    automatically documented in the IDE so

  36. 1:05

    you really have to refer back to online

  37. 1:07

    documentation for the libraries that you

  38. 1:09

    use in addition that compiler can catch

  39. 1:11

    bugs in advance which is a far more

  40. 1:12

    efficient way to refactor code

  41. 1:14

    I think this reddit post says it best

  42. 1:16

    would you rather have silly errors

  43. 1:17

    during development or insanity inducing

  44. 1:19

    errors in production another cool

  45. 1:21

    benefit of typescript is that there's

  46. 1:23

    virtually no learning curve if you know

  47. 1:24

    JavaScript that's because it's a

  48. 1:26

    superset of JavaScript so any valid jsk

  49. 1:29

    is also valid in typescript so you can

  50. 1:31

    learn it incrementally as you go and it

  51. 1:33

    also allows us to write our code with

  52. 1:35

    future JavaScript features without

  53. 1:36

    having to worry about whether or not

  54. 1:38

    this code will be supported in our

  55. 1:39

    environment because we can transpile it

  56. 1:41

    to multiple JavaScript flavors

  57. 1:43

    now that you know typescript is awesome

  58. 1:44

    let's go ahead and get started the first

  59. 1:46

    thing you want to do is install

  60. 1:47

    typescript globally with NPM doing this

  61. 1:50

    will give you access to the TSC command

  62. 1:52

    which will run the typescript compiler

  63. 1:54

    at the time of this video I'm running

  64. 1:57

    version 3.1 so the first thing we'll do

  65. 1:59

    is create an indexed ES file and