41: Be Super with TypeScript and Jared Palmer. On the when, where, what, why, and how much of TypeScript in React.
TypeScript. What is it? How does it help you write better code? Will it help you sleep better at night?
Jared is a lead engineer at The Palmer Group, a strategy, design, and engineering firm.
There he uses TypeScript every day to keep code sturdy and maintainable.
Chantastic asks Jared what we need to know to get a little TypeScript into our apps.
They discuss the joys and pains of TypeScript in 2019 and how it compares to languages like Reason, OCaml, Fable, and Elm.
Featuring
Links
- Jared Palmer — Consultancy
- TypeScript
- Moving To React Suspense - Jared Palmer - React Conf 2018
- npm and the future of JavaScript - Laurie Voss - JSConf US 2018
- The State of the Octoverse: top programming languages of 2018
- flow
- Build Your Own Formik Using React Hooks with Jared Palmer (*egghead membership required)
- @babel/preset-typescript
- Realytics/fork-ts-checker-webpack-plugin
- Adding TypeScript to Create React App
- TypeStrong/ts-loader
- s-panferov/awesome-typescript-loader
- rollup-plugin-typescript2
- [RFC] Migrate Jest to TypeScript
- tsdx — Zero-config TypeScript package development
- Deno — A secure runtime for JavaScript and TypeScript built with V8, Rust, and Tokio
- Reason — Reason lets you write simple, fast and quality type safe code while leveraging both the JavaScript & OCaml ecosystems.
- OCaml — OCaml is an industrial strength programming language supporting functional, imperative and object-oriented styles
- Fable — The compiler that emits JavaScript you can be proud of!
- Elm — A delightful language for reliable webapps. Generate JavaScript with great performance and no runtime exceptions.
- Swagger
- Swagger Codegen
- Palantir Technologies — All the TypeScript projects
- Shopify Polaris — Our design system helps us work together to build a great experience for all of Shopify’s merchants.
Sponsors
Linode
Instantly deploy and manage an SSD server in the Linode Cloud, with your choice of Linux distro, resources and location. linode.com/react
Transcript
[00:00:00] Michael Chan: This is React Podcast. I'm Jantastic. This week on React Podcast, we're tackling the questions: what is TypeScript? Why should I be using it? And how can I start? To help me out, I have friend of the show Jared Palmer to talk about how he's using TypeScript and all the things that he's learned in the last 2 and a half years trying to do that in React. We reference a ton of TypeScript projects in this episode, so if you need links to those, visit reactpodcast.com. This is episode 41. Thanks to our sponsor this week, Linode. Instantly deploy and manage an SSD server in the Linode cloud. Get a server running in seconds with your choice of Linux distro, resources, and node location. Now offering dedicated CPU instances designed for consistent, high-performance computing needs like video encoding, game servers, and busy application servers. Now, one thing that's great about Linode is that they have 9 data centers worldwide. When you're in the business of delivering content to users, you know how important it is that you actually have that content on a server as physically close to that person as possible, and Linode helps you do that. Now, in 2019, they're actually adding 2 new data centers, one in Canada and one in India. Featuring native SSD storage and a 40-gigabit network, they can help you serve your customers as fast as possible. Visit linode.com/react and get a $20 credit when you use the promo REACT2019. Jared, welcome back to the show. Uh, I'm so excited that you decided to join us again. I honestly don't remember what episode yours was, but we we do a whole thing where we talk about Suspense and we talk about you a little bit more. Um, so, uh, I'll I'll put a link and like people can uh can hear more about you. But today, we're mostly talking about TypeScript.
[00:02:02] Jared Palmer: Yes. My fave.
[00:02:05] Michael Chan: So, um before we jump into that, uh I just we hadn't had a chance to talk about how great your React Conf talk was.
[00:02:13] Jared Palmer: Well, thank you, thank you, thank you. You are very kind.
[00:02:16] Michael Chan: But it was it was really stellar. And uh you gave a very pragmatic, kind of step-by-step approach to kind of migrating some of your data needs to Suspense in a React app. How did you feel that that went?
[00:02:31] Jared Palmer: Well, like I blacked out during it, so I have no idea. But no, but in all seriousness, it was great. It was fun. The looking back on it, like it was definitely one of the best experiences. Definitely one of the best talks I've given, I think. So, I was happy with it. I hope other people saw the- like, were pacified, or I don't know if pacified is the right word, but just like were comforted by the, okay, this is what I do on Monday approach.
[00:02:58] Michael Chan: Yeah.
[00:02:58] Jared Palmer: And because it was a lot of stuff just at React Conf between hooks and Suspense. Um, and the urge to just, you know, use the shiniest, newest thing is very strong. Mm-hmm. And so, um, hopefully, um, it was like a step-by-step, um, sort of evergreen, like, this is how you're gonna do it. Get started, approach, I don't know, talk. So, um, it was fun. It was uh it was very very there was a lot of pressure, we'll say. I remember I remember you you you you were you were awesome because you found me the day before like a nervous wreck and uh you're you gave me the pointers for all for the listeners out there. So Michael found me like in some back corner of the of of the conference um area just like talking to myself, muttering. And um I showed him the showed him the deck, uh sorry, the presentation and and the app, the the Spotify clone that I built. And uh he helped me out with some pointers and calmed me down a little bit and helped me with the the blur animation a little bit. So definitely am much, much, much appreciative of that. Um can't so basically thank you. I mean, your con your conference talk, not really mine. Um so it was good.
[00:04:05] Michael Chan: Well, I I had a tiny little tiny little role in in helping you, but I was I'm glad that I was able to like find you in that moment and be like, dude, you got this, you got this.
[00:04:15] Jared Palmer: Yeah, exactly.
[00:04:16] Michael Chan: Um, it's gotta feel fun, though, to have like the talk on Suspense.
[00:04:21] Jared Palmer: Uh, it was quite the honor. I was the— you know, it was interesting, uh, when I give talks, the the most— I haven't done like a, uh, like a management talk or yet, but I I very much plan to. Most of my talks have been like very technical. So far. Um, and this was an interesting one because usually uh I end up talking about something that I've written, which is a interesting challenge, right? So those kinds of talks are like, I've been thinking about this for months or years.
[00:04:48] Michael Chan: Yeah.
[00:04:48] Jared Palmer: Uh, personally, in my like in my head or in the shower or whatever. And now I need to condense this thing that I've thought through so deeply into, you know, a short period of time. Uh, the talk about Suspense at React Conf was interesting because it was mostly like someone else's work that I that wasn't you know released yet that I needed to honor and do right by.
[00:05:09] Michael Chan: Yeah.
[00:05:09] Jared Palmer: Um and then condense down into something also that was digestible and interesting and actionable um without any documentation. Um so that was interesting.
[00:05:19] Michael Chan: Well, and it was changing moment to moment, like even while you were doing the talk.
[00:05:23] Jared Palmer: Yes, it was changing quite rapidly. Um I definitely committed Node modules to Git during the during my preparations. Um but the the the the the preparation— there were there were some— this was not a talk that I just prepared the night before. It was definitely structured and reviewed. And the Andrew Clark from Facebook was very, very, very helpful. Um actually, like Sophie and Dan and a lot of people were very helpful in in practicing. So definitely the most practiced talk I've ever given.
[00:05:51] Michael Chan: That's awesome. Well, it was amazing. And I uh I look forward to kind of sharing it all over the place when we when our teams are able to move into into Suspense. Because it's just so pragmatic and so just like, hey, this is this is how this new technology affects your life in the apps that you already have. Not these imaginary greenfield apps that you want to build in your spare time. But like the thing that you're doing right now, this is how it affects it.
[00:06:18] Jared Palmer: Yeah.
[00:06:18] Michael Chan: So, that's actually why I wanted to get you on the line and talk about TypeScript. TypeScript is like all over the place right now. I don't know what- who was writing about it or who was talking about it, but it seems to have just blown up.
[00:06:31] Jared Palmer: There was a day, I don't remember which day it was, but it was like one day where I think, yeah, I actually asked- I was texting a couple of friends about like this, like about what was the tipping point? And I don't know, but I think the big like catalyst moves were a couple of series of tweets, I think from like James Kyle, uh Kent Dodds, and I think I guess, Sebastian Markbage. There's like within the same week, there was a quote, there was this like Jamie who like obviously was instrumental in Flow.
[00:06:57] Michael Chan: Yeah.
[00:06:58] Jared Palmer: Was just like, don't use Flow. Or and then I think there was like a comment from Sebastian about like prop types and instead of using just like use TypeScript because that's like the convention now. And then like Kent Dodds also was like, yeah, I guess we're moving to TypeScript. And so I think that those like I don't know if it was like one week or like a couple of weeks. Anyways, there was an explosion. It hit a tipping point and boom, the whole world's moving to TypeScript. Um, and if that sounds like an exaggeration, it probably is, but it probably also like might not be like,
[00:07:27] Michael Chan: yeah.
[00:07:27] Jared Palmer: Um, as we're about to get into, like it's, it's definitely the future for at least the next year or two.
[00:07:33] Michael Chan: It definitely feels like, regardless of how true it is, it definitely feels like all of a sudden there was a point where now TypeScript is the, is the hotness. I feel like there was another um part of that conversation, too, where Laurie Voss had been giving this talk kind of in the second half of the year. He was talking about npm and the future of JavaScript. And he was just talking about how crazy it is how much people love TypeScript. And I think that maybe up to that point, people didn't realize how much um TypeScript was like being put onto npm and all that. I don't know if you've heard that talk.
[00:08:08] Jared Palmer: Yeah, yeah, there was there was I I actually haven't watched the entire talk, but I saw the stat in the slide. Uh, it's, you know, some, I think it was like 43%, I don't know, 40-something percent of NPM modules are like TypeScript or NPM downloads. I forgot the stat is, there's a 40 and a percent in there and it's important and it's big. The other thing that's in my, in my book that's also very interesting is you look at GitHub's developer survey or like their like state of the Octoverse, um, whatever they call it. TypeScript has just been climbing year after year. Yeah. Okay. And the other thing too is if you look at like state of JS, like the developer satisfaction rating and like favorite tools. It usually wins. Crazy. From a like passion perspective. Or would use again or would recommend. It just like crushes everything. Um and so, you know, a lot of that is not just the language itself, which is great. Also, VS Code is just kicking ass.
[00:08:54] Michael Chan: Yes. Yes.
[00:08:55] Jared Palmer: And so, there's one, you know, VS Code is purpose-built, in my opinion, for like one thing, one thing alone, and that's TypeScript development. And it is so good. And it's got this like Apple, in my opinion, it's like an Apple-like um approach where it's like, you know, Apple's like the software and the hardware, right? So it's got, similarly with TypeScript, it's the editor and the language. And so it just can do things that, you know, Atom really can't do. And that's now Microsoft owns Atom because it owns GitHub. And so I don't know how, I don't know the future of that. But, you know, anyways, um, it's the editor integration is phenomenal. Um, the whole thing, it definitely hit some sort of tipping point. Um, but it's kind of been going that way. And I I don't know if it hit a tipping point or it was just like a realization that just like Flow is being neglect- like, is this like being neglected or I don't know, like what the- just like a realization that Flow is not really ever gonna gain the popularity it needs outside of Facebook to be viable. So I don't know, or maybe both, right? Maybe a little of both, right? It's just stagnation in in Flow and and and acceleration in TypeScript. And maybe those two things combined sort of led to it that one week or, you know, where everybody was like, oh, here it is, here's what we're doing.
[00:10:00] Michael Chan: Well, I know for me, like we both kind of got into TypeScript. I mean, we're relative newbies to TypeScript. Mm-hmm. I mean, I started about like a year and a half or two ago. I just moved like one module over to TypeScript. But it really was a result of what you were talking about. How I'd been using VS Code and it was kind of providing me all of this information about my code. And I was like, I wonder what would happen if I just changed this one this one JSX file to a TSX file. And that was like just the the gateway for me. Like, oh my gosh, like all this stuff is so well integrated. It tells me that all this stuff's super fast. And that was an experience that I never got with Flow where it just seemed like in order to use Flow, I was using these plugins that just totally shattered performance on my machine.
[00:10:45] Jared Palmer: And in the editor too, right?
[00:10:47] Michael Chan: Yes.
[00:10:48] Jared Palmer: So Nuclyde, for whatever, like Nuclyde and the Flow experience for me, I didn't love- it didn't seem like an integrated thing. It seemed like bolted on.
[00:10:57] Michael Chan: Yeah.
[00:10:57] Jared Palmer: Just like tooling-wise, you have to run it as a separate task. And yeah, now you can't really trust- by the way, you can't really trust your- there's one command that I run every single day, probably 17 or 18 times, and that's restart ts-server.
[00:11:09] Michael Chan: Okay.
[00:11:09] Jared Palmer: Right. So I like when, you know, you make some type change and VS Code's just like a little far behind, so I end up restarting the ts-server all the time. Um, but that being said, like, it was- it's still much better than like the flow, you know, that at least from You know, my my my my my opinion, the the Flow developer experience never really could come close to the TypeScript integration with VS Code. And so I think that was like thing one. And then thing two uh was Flow is very powerful. And it is really, really powerful. And the people working on it are really, really smart. And it, to me, it does too much. Or tries a little too hard. In particular, in particular, it does too much type inferencing for my taste. And what that means, type inferencing is basically where it can guess the type, uh the static type of of of a piece of JavaScript. Um or a function or a variable or an object, like anything, it can just guess it. So you don't have to actually like manually add the type annotation. Um and what TypeScript is like beautifully dumb about this. So, I read an article once that like TypeScript, you end up writing like 2.2x the amount of code, like lines, and Flow is like 1.8. But the thing is, is that like, I don't know if that numbers are true, but that's what people usually say because of this, again, you can just more inferencing in Flow. The thing is that TypeScript kind of saves you from yourself because if you do something wrong, it just like tells you exactly where the error basically is. Now you may still have some difficulty understanding what that error is, but it's co-look, it's like very much like the underlined red warning is where the problem site is, right? Now, when you have like a lot of inferencing, I've found that with like with Flow, you may have made that mistake last week and it may be in another file. Mm-hmm. Or, you know, and you may have been per- like it may have been perpetuating this or proliferating this error for like a week and you didn't realize it until you went to go like make do something special or new or different. And so your error message in Flow was also cryptic, but like not even close to where the actual problem site actually is. And that gets expensive and really brutal. Sure. So that's like my experience. And then also, when we- we- so let me back up. We switched to TypeScript in 2017, um, and now live in a universe where every single project we write and every file we write is in TypeScript. And it's a beautiful paradise. But um it really is. Uh and I'll get to that in a little bit a little bit later. But we moved from Flow. And it we I moved about like 300,000 or 400,000 lines of code. Um it was about 300,000 lines of code um over the course of a about a year. But like in the first like in the first burst, we did like 80,000 lines of code in 2 weeks.
[00:14:01] Michael Chan: Whoa.
[00:14:02] Jared Palmer: Um and We had a very specific strategy to do that and we moved from Flow. But the biggest like booyah moment was we had been writing custom Flow types and trying to- because Flow is just not as popular because it doesn't have the backing of the Angular community and Google. Um, and so there's just so many more types available from the community. So immediately when the first day we started switching, we found that we had like 85% of our third-party modules were just covered already with types. That were previously supported versus like 20%, maybe.
[00:14:36] Michael Chan: So, so that percentage of code that you're not writing in the difference between like whatever the 2.2 and the 1.8% that you mentioned earlier, um you actually have to write less types in TypeScript because there's a huge community around there writing those types that you can just-
[00:14:51] Jared Palmer: Right. So, the most expensive part of TypeScript is, well, I would say the most expensive part aside from tooling is the pain of having to type a third-party module that doesn't have types. Now, I have gotten pretty good because of the past- again, I've been doing this for like 2 years now. And so now I've got my like type foo, third-party type foo is stronger than it used to be. But I remember this used to be really hard and there used to be like not great documentation on it either. Um, and if you've ever had to type- having typed successfully finally like a Redux middleware in TypeScript, like that is some crazy stuff. But, you know, at the end of the day, like my my my barometer for like, okay, or this should just be any or unknown now, even better, this new type. Um, you know, there there's definitely that. And of course, you don't need to go all the way and type every single thing. And TypeScript now works with JavaScript. In fact, it's really great to just compile JavaScript too. Like it's a really quick way to just do that. Um, so anyways, um, there are a whole host of things that sort of led me to down this path. But uh and my team. But I guess like the the the big ones were the community support, right? And that's where that's where things really hit a tipping point. Um and this had happened in 2017, really. It was like not even close between Flow and and TypeScript. And then, yeah, the editor integration just sort of picked up. And so, those were like the two big things. And I guess, you know, we hit some sort of tipping point in the in the last week or so. But um yeah, it was— uh we we've been in this typed universe for a while. I don't know if you've experienced this. I feel more confident when I write TypeScript. Like I-
[00:16:20] Michael Chan: Oh, absolutely.
[00:16:22] Jared Palmer: I did a webinar the other day. For Egghead, and I wrote a lot of- I actually like rewrote, like I basically built like Formic 2 in front of people. Mm-hmm. And I used JavaScript, and I just had like 4 or 5, 6 errors that were just typos that I didn't catch. And I was so used to just leaning on- I've like outsourced my type, like spelling and and stuff like that to TypeScript and just focus on other things. Um, but wow, going back to party mode, as I like to call like normal JavaScript, um, is is quite a challenge.
[00:16:51] Michael Chan: It is interesting, especially with that really quick feedback loop in the editor. It feels kind of like pair programming where someone is noticing your mistakes as you write them and just being like, oh, hey, you forgot this. Or oh, you didn't type that right. Or you misspelled this.
[00:17:06] Jared Palmer: Oh, that's a great way of putting it. That is- yes. Yeah, TypeScript is like the the that cool kid in science class that also is good at- the person you want to like do your lab with, basically, right? Like that person's not gonna miss anything.
[00:17:19] Michael Chan: Yep, totally.
[00:17:21] Jared Palmer: So, that's that's a great way of putting it. I like that. Um, it's great. It builds confidence. There are also like things, when I when I hear, I think there's like sort of two camps to this, right? There's the people that got, well, there are people that just write JavaScript and they're like, JavaScript is dynamic and the browser's dynamic and and and I don't need I don't need static typing. And Then there's some folks sometimes that are like got burned by CoffeeScript and think that it's like the same kind of thing. Um, and there's that. That's a common response. And then there's the people who are on Flow, right? Um, that also are just sad. And yeah, I feel like those are the most of the conversations points people come from. Obviously, like if someone's using like an Elm or something, they're already in the type grind, so whatever. But basically the the the realization is that You're right, JavaScript is a dynamic language. And but you don't but it's not you don't really use the dynamic parts like all the time. You use them like 10% of the time, maybe. Um and-
[00:18:21] Michael Chan: And so you can opt out when you when you need them.
[00:18:23] Jared Palmer: Yeah. And and and what's cool about it is you can be explicit when you're doing stuff that's crazy. Right? So like if I see an any, like visually, uh an any type for those who haven't used TypeScript before is basically a you can do whatever you want. Like let's go back to regular crazy JavaScript. Um and if you turn on the best part of TypeScript, which is this no implicit any flag, which basically basically warns or fails the build if there's any sort of implicit dynamic- implicit dynamicism. I guess that's the way to put it. But anyway, dynamic variables or or or or JavaScript. And if it's not properly annotated that way, um or like typed, then it will throw an error, um a build time error. But basically that little like colon any is like, hey, some crazy stuff is about to go down. Right? And even now, even better, there's a new type called unknown, which basically is way more- it's just like a stronger version of any in the sense that it basically says you have to assign types to this.
[00:19:21] Michael Chan: Yeah.
[00:19:22] Jared Palmer: So it won't just like pass type safety for forever. You have to like actually add the types yourself and defensively program this. So anyways, that is- so basically the the the realization is that you really want static types most of the time. And when you do want to have a party and you do want dynamic types, That's great. Just annotate it that way. And then you can just move so much faster when it comes to maintenance. And I think what people find, and if you're having- if you try find TypeScript to be like, and you're coming from just regular JavaScript, it's gonna be slower for day 1. But on like day 30 and like day 500, it is so much faster to be writing in TypeScript on your project. So if you are building something and you're not- you're gonna come back to it like next month. Or 2 months or 3 months from now, like, you just have can have so much more confidence coming back and maintaining something. And also, like, but that being said, if you're just like doing a demo, like, no, TypeScript's probably way slower. Mm-hmm. And, you know, I I think uh Guillermo and I, Guillermo Rauch, uh you know, the CEO of Zeit, founder of Zeit, um we had a conversation once, uh back and forth about about TypeScript. And his point, which I think is, you know, well taken, is types are about like communication. And sharing an understanding of um the concept of of something in your application. Yep. And there's not as much of a benefit if it's just you working on it, right? Because you can keep all this stuff in your head. Um there's some benefit, obviously, like typos and stuff like that. But I have to say, like, having onboarded a couple team members who didn't who came from, you know, non-typed experiences or untyped um JavaScript land, um we have like much deeper conversations about our applications because everybody knows what a user is in a very, very, very specific way. Um, and we know all the fields of a user. And if you forget, you can just like right-click and look at it, right? Um, and all the CRUD models in the application, like everyone just has a much stronger, deeper understanding of that, um, from like out of the get-go. And that's really powerful.
[00:21:20] Michael Chan: Yeah.
[00:21:20] Jared Palmer: Um, and so there's a lot of benefit there. Um, and so the other thing I guess that's uh really, really beneficial too is the confidence when we make changes to those models and or you make changes. You can be drunk and fix type errors if you get good enough at TypeScript. You just make the red stuff go away, right? You just like make those problems go away and you can make massive sweeping changes across an entire application.
[00:21:44] Michael Chan: With a lot of confidence.
[00:21:45] Jared Palmer: Oh yeah. Like there are moves we've made in the past that I would never have attempted. Like like maybe 3 to 5 of these, like maybe 20,000 like line change pull requests that, you know, cross touch, you know, hundreds of files. No, like I trust it. It's just, I mean, I don't think you'd ever attempt things like that without, I don't know, without much more testing or much more time. So sort of been been on that grind.
[00:22:12] Michael Chan: So I want to shift gears here a little bit and kind of go back for anyone who is totally unfamiliar with TypeScript. You've mentioned the difference between uh TypeScript and JavaScript a couple of times now. Uh, to to just ask like the really kind of basic question, what is TypeScript and how does it relate to JavaScript?
[00:22:31] Jared Palmer: It's a great question. And the term they use is uh TypeScript is a superset of JavaScript. And so, it is a language. It has a type- it is a type system. It can compile to JavaScript, um, in a bunch of different flavors. And you can configure it to do a whole host of awesome stuff. Uh, but it's a superset, which means all JavaScript is valid TypeScript. Now, but the thing is, what is JavaScript is a great question, right? Because JavaScript is kind of a moving target these days. So, I actually forget which direction the the Babel the the TC39 proposal is going. I can never remember which one it is.
[00:23:09] Michael Chan: I think 0 is the is the most unstable and then 4 is like it's in the next release of JavaScript.
[00:23:15] Jared Palmer: So, I think I think it's once it hits 3. They implement it in TypeScript.
[00:23:18] Michael Chan: Oh, okay. Um,
[00:23:20] Jared Palmer: and so, you know what is gonna- like, those are like guaranteed language features. There are a couple features that, um- so there's a TypeScript compiler, which is cool because it's actually written in TypeScript, so it self-compiles itself. Uh, TypeScript is open source, it's available on GitHub, it's like one of the most pop- one of Microsoft's most popular projects. Um, it is deeply integrated into VS Code, uh, the editor. Uh, which is great. Um, there are all sorts of plugins and stuff. And basically, um, what I mean by superset of type uh of JavaScript is it's like JavaScript, but it in addition to like your regular JavaScript syntax, you can add annotations. And these are little, um, I guess strings or different like pieces of text you lay out over your normal JavaScript that describe um the type signature. Of your code. It's very inspired by Java and it's really, really useful. So what it does is basically you you add these annotations. Um, this is a string, this is a function, this is- but not just like function, that's actually like not even permanent. This is like a function that accepts this object of this type and returns this type of this other thing. And you can describe all these things in interfaces and types. Mm-hmm. Um, and it can be- you can really, really express all aspects of your code, um, statically. And then what it does is it will look at your uh annotations, and if there are type errors, as in like your types are either not aligned or you do something uh out of bounds basically, or not allowed, it will fail your build. Mm-hmm. Um, and what this means is you catch a lot more bugs, um, earlier on before they actually get to production. Now, it's not like runtime static type checking. Like, it's not a static language like the way that like Java is, where you can like use the type- you can leverage the type system at runtime. It's just a build-time static type checker. So, you're still gonna end up running dynamic JavaScript when it gets to the browser, obviously. Mm-hmm. Um, and but like while you're developing your application, you write in this different syntax or slightly different syntax and you get all these benefits of static typing. Or close to all the benefits of a statically typed language. Now, there are like degrees of TypeScript, okay? You do not need to write your- you don't need to like from day one change your entire application to use this new syntax. Um, it actually can compile JavaScript. Um, so like Babel, um, there it's a little different than Babel. It doesn't have the plugin architecture that like there and modules that Babel does, but it's still actually compiles your JavaScript. In fact, when I build like CLIs and little things like that, it's a great way to like really quickly get like consistent like like latest ES6 features and not need to like go, you know, install 3 Babel things and whatever.
[00:26:09] Michael Chan: So, so if I'm understanding correctly, it it is a language. Yes. But then also it has like uh CLI tools and whatnot that allow you to compile. Um, so it kind of also plays that role of Babel. Right. Uh in compiling that code to JavaScript.
[00:26:25] Jared Palmer: Sure, exactly. Um, there are some— yeah, that is That is that is a great that is a great summary. There uh confusingly, there is also a Babel plugin for TypeScript.
[00:26:34] Michael Chan: Okay.
[00:26:34] Jared Palmer: There is nuance there are nuances between the Babel TypeScript plugin and the TypeScript compiler. There are features of real TypeScript that are not available to the Babel plugin. There are two big ones. And the reason for that is they're not really valid JavaScript. This is where I mentioned it before. It was a superset. This is the super part of the superset.
[00:26:50] Michael Chan: It's too super.
[00:26:52] Jared Palmer: It's too super. And they're actually really useful. One is called a namespace. And I don't need to get into the technical definition, but you can just look it up. Another one is a constant enum. So TypeScript has a very powerful primitive called enum. And this is really great for autocomplete. And they evaluate to uh numbers by default. Um they're like enums in other languages. But you can also assign them to values. And they can be constants, so they compile down to strings. Very, very useful for like, okay, you have some sort of- you have two types of- something has like a status, active and inactive, right? Yeah. That's just an awesome way of describing that. Um, and really great if you do like code generation with your API to make sure that like these like letters are consistent throughout the entire- your strings are consistent all over your application. And again, there's amazing autocomplete for enums. So, the Babel plugin for TypeScript, Babel plugin TypeScript, doesn't have support for constant enums and namespaces. Um, but it also doesn't uh do the actual type checking for you. That's a little confusing. It will do the compilation, but it will not like throw a type error in the— um or syntax error in in your terminal. It doesn't care.
[00:28:09] Michael Chan: So, you would be dependent on the editor then?
[00:28:12] Jared Palmer: No. Well, you should never Pro tip, never trust the editor. It's just like a guide. You should always be running a comp- like an actual like TSC process. Uh and so, what you should do then if you're using the Babel plugin is if you're using Webpack, you'll need to like add- the one I like is fork-ts-webpack-plugin. No, fork-ts-checker- I forget what it is. Fork-ts-checker-webpack-plugin. And what this does is in another process or multiple processes, it can actually um spawn a bunch of like parallel workers to go do your type checking so that you can basically- and I actually, we actually use this with our regular webpack, um, the regular TypeScript plugin. Mm-hmm. Again, this is a little confusing, but for the Babel one, you should always use that. That's built into uh create-react-app, so you don't have to worry about it. So if you use create-react-app, you're gonna get this out of the box. If you're not using create-react-app and you do want to use the Babel plugin, you um basically need to add a webpack-checker plugin, basically. Um, and then the other sort of another confusing wrinkle is the built the default ts-loader, the TypeScript loader. Uh there are two TypeScript loaders um for webpack that actually use the the real TypeScript compiler. One's called awesome-typescript-loader and the other one is called ts-loader. And there's some blog posts um about how to optimize ts-loader, but you actually do something very similar to the what Babel does, where you actually should set it up to- only do the transpilation and not the type checking, because the type checking happens in a synchronous fashion and just gets really slow as your application grows. So you end up using the fork-ts-checker plugin no matter what. So yeah, so that's how like the tooling of it works. There's a rollup plugin if you're building a library. And that's like a lot of, I guess, people's challenge with TypeScript is that it is- there's like a lot of configuration to get it working. It's not as seamless as a bootstrapping experience. And but it's very flexible. So you can target ES modules, you can target the browser, you can target Node, you can target whatever flavor of JavaScript you're writing. Um, it's not as flexible by default, uh the TypeScript compiler, as let's say Babel. But if you again, if you're in Babel land, you can use other Babel stuff too, right? So you could do like all this other things. And then the other thing that's even more confusing is you can actually run the two things together. You can actually run Babel and TypeScript with like Webpack at the same time. And this is real- it's actually- I- we do this a lot for Formic. Um, we first actually compile with TypeScript and then we compile with Babel because Babel is gonna do some other optimizations that TypeScript can't do. Mm-hmm. Um, so yeah, it's just- it's the whole rabbit hole you can go down of tooling. Um, but the big thing with TypeScript is that it's really flexible. And again, it can- it's just a spectrum of how strong of a typed universe you want to live in. Uh, one of the big knocks against it was that you had to go all in on it, but that's not the case anymore. You can like just write JavaScript and compile with TypeScript, um, which is great. Um, you can also add JSDoc comments in a new way that like-
[00:31:10] Michael Chan: Oh, wow.
[00:31:10] Jared Palmer: Um, it will evaluate a .js file and use the the the comments, um, with using JSDoc to basically do static analysis, which is kind of cool too. Um, I know that all of the webpack source code has those types of comments in it. So if you want to see that in action, go to the webpack source code and somebody over a long period of time, added JSDoc comments to like every single aspect of, or a lot of webpack code. And now they type check it with TypeScript.
[00:31:35] Michael Chan: God bless those people, man.
[00:31:37] Jared Palmer: Yeah, I don't know. Not for me.
[00:31:39] Michael Chan: I don't have that kind of patience.
[00:31:40] Jared Palmer: Yeah, that's what TypeScript is. Um, it's, it was invented at Microsoft. Um, Google then adopted it for, to be like the default de facto thing for Angular a couple years ago. And that's, you know, and it sort of exploded after that.
[00:31:57] Michael Chan: So where are some places that are using it that um that we might know about, uh be it frameworks, companies, et cetera?
[00:32:03] Jared Palmer: Sure, so um Microsoft, we mentioned, Google, uh Airbnb just started the move or finished the move or is moving, uh Palantir, uh Shopify, uh GitHub. I think Pinterest is still on Flow. Uh, Uber is still on Flow, but there's some apps here and there that- or there's some projects on GitHub that are sort of in between that are in TypeScript. Facebook, um, has published a couple of projects recently in TypeScript, but I believe that the way that Facebook's structured, that like any team can choose any tool. So.
[00:32:37] Michael Chan: Sure. So they they use all kinds of stuff. I mean, I feel like at Facebook, they're announcing new languages or even languages that they used internally that they aren't using anymore and just decided to open source like all the time. Their language development teams over there are very active.
[00:32:54] Jared Palmer: Yeah, yeah, yeah, exactly. Um, and so, those are like the the big companies that like come off the top of my head. I'm sure I'm forgetting some that use it. Um, and the— as for like other frameworks, obviously I mentioned Angular, but Vue is also gonna be written in TypeScript if it's not already. Um, the next version is-
[00:33:14] Michael Chan: Ember, I think, did a TypeScript rewrite a couple years ago.
[00:33:17] Jared Palmer: I think so. Um, I haven't read through that in a while. Uh, but Um, so, yeah, React's just, you know, just writing. And then they just- oh, so Jest, not really, Jest, the test runner, is being, um, just was or is going to be rewritten in TypeScript. Or-
[00:33:34] Michael Chan: Wow.
[00:33:35] Jared Palmer: So that's pretty big. Um,
[00:33:37] Michael Chan: crazy. A lot of big projects.
[00:33:38] Jared Palmer: Yeah, yeah. Um, it's really good for big projects. Like it's it's it's pretty great.
[00:33:42] Michael Chan: Yeah. I wanted to go back to um to the tooling real quick. You had mentioned a couple of different different paths. And I just wanted to clarify some of that. I know that- so you mentioned Babel and Webpack. So if you're already in Babel and Webpack, there's kind of a path there for you with the Awesome TS loader and also the Babel TypeScript plugin. But you'd also mentioned that you can use- there's a rollup plugin if you were doing a library.
[00:34:13] Jared Palmer: Right. So I'm actually going to be releasing a thing called TSDX. That's the working title, um which is basically the ultimate TypeScript package development like experience. Um it's based on Rollup. And so this will abstract away all this configuration. But um kind of like Babel, it actually has TypeScript has a a CLI that can just like transpile um and and remove the types. Um but it won't do the bundling. So if you're like trying to do or as as many optimizations as let's say Rollup could. So, there's a Rollup plugin TypeScript. And so, there's that. And then, again, if you're just doing like a Node app, um, or you're running like a Node server, you're running an Express server, there, Microsoft has a great starter project for like, type, um, like Microsoft TypeScript Node starter. And uh, it shows like how to just use the regular TSC is the is the is the CLI name, uh, the TSC command to do the transpilation. Because obviously in Node, you don't need you don't need to like bundle your app for the browser. It's just gonna run. You just need to change the syntax out so it can run. And then there's Deno, which is cool. Uh, so Deno is like, um, an entire like TypeScript-focused runtime for Node, but it's based in Go.
[00:35:29] Michael Chan: Oh, wow.
[00:35:29] Jared Palmer: And uh, it was announced, um, yeah, it's was, let me pull it up. Uh, I don't wanna get this wrong.
[00:35:35] Michael Chan: That's like Ryan, as far as I understand, that's like Ryan Dahl's like second attempt at Node to-
[00:35:40] Jared Palmer: Right, right. So he gave this talk that was called like My Regrets About Node.js, basically, which is crazy. Basically, Deno is a very interesting like runtime that's based on TypeScript. And there's some other things that are like really interesting. Like there's, you have to, um, you have to uh explicitly write file file name endings and you can also like install things from like unpackaged.
[00:36:02] Michael Chan: Okay.
[00:36:03] Jared Palmer: And it works a little bit more like Go in the sense where, well, it has like a cache. It's almost like Um, you're like Yarn PMP, like the plug and play thing. It has like a similar kind of cache built into its entire runtime. So like once it downloads a um a uh a package uh from anywhere, it will just like cache that.
[00:36:20] Michael Chan: Awesome.
[00:36:21] Jared Palmer: So that's kind of cool. And also you can have multiple versions of the same package in a single application, which is like one of the things that npm is somewhat flawed at right now. And also there's no package.json, which is also interesting.
[00:36:32] Michael Chan: Okay. But you can use TypeScript in Deno.
[00:36:34] Jared Palmer: Yes. Yeah, it's built on top of- I forget which TypeScript version, but it is, um, uh, I think it's like 2.8 or something. It's kind of cool.
[00:36:42] Michael Chan: That's wild. So, speaking of versions, um, how often are they updating this language?
[00:36:47] Jared Palmer: Okay. So, it's very aggressive. But it's usually- I won't say it's always backwards compatible, but it's basically- the changes are tend to be minor. But they have a regular, like, uh, I think it's like quarterly release, basically. Maybe it's month to month at this point. Um, but you can go on the roadmap. Um, they are pretty aggressive and they add new features. And again, whenever something hits stage, uh, what do we say, 3? Um, it just gets added to the language. So yeah, it's it's it's pretty great to see. They're adding variadic types. They're adding a lot of stuff that like more harder core type languages, uh, like Reason or OCaml like can do. Um, and they're gonna get there, which is really impressive. Um, they added conditional types this past year and Uh, if that pattern matching proposal ever gets to stage 3, uh, there's a pattern, TC39 pattern matching proposal, they will implement pattern matching in TypeScript.
[00:37:36] Michael Chan: Oh man, that'd be amazing.
[00:37:37] Jared Palmer: That would be pretty tight. Um, so there's some just like cool features there. It's an interesting approach. You know, TypeScript is, it comes at it from the, the, I think the right direction. Um, that, that like lowers the engineering overhead and, um. Of like the benefits of static types. Um and so, it's it's impressive to see how how how far they can push that.
[00:38:00] Michael Chan: So, you mentioned uh other languages like uh like like Reason. And I know that there's been some effort around um another language called Fable, I think, around F# sharp and compiling that to JavaScript. Um what are some of the the advantages that you think of of having a language that ties so closely to JavaScript and kind of developing from that side versus kind of starting over with another language that has types already baked in.
[00:38:29] Jared Palmer: So, I have a- I get, albeit like controversial, opinion about this. But that's because I'm like- I run an agency. And so, I'm about optimizing for like cost. Okay? And so, the cost of training is real. To me.
[00:38:47] Michael Chan: Yeah.
[00:38:48] Jared Palmer: And the cost of maintenance is real, and picking the wrong technology has a real cost to it. And also you have to get client buy-in oftentimes if we're building something on behalf of someone else. So when you get to a language like um Reason, it's a little too early to go- it's just not there yet. It doesn't have the popularity. It's only being used at Facebook. Uh that's not fair. There are some other companies using Reason. But there is no major tier 1 tech company outside of Facebook using Reason. Now, there are a bunch of really, really smart people using OCaml. Mm-hmm. You know, Jane Street and Bloomberg use OCaml, but it's not a relative to like, it's not a top 5 programming language. Um, it's uh, and so that being said, like for the types of problems they're solving and the types of businesses that those companies are running, they can afford to do that. Yeah. And that's totally cool. I personally can't. Um, and so that's, so for me, I would need to see a lot more adoption outside of, this has nothing to do with the language, by the way. It has to do with the adoption. It doesn't like the language, like actual functionality. Um, this has to do with like the community around it. It's just, I don't see like those communities being, uh, sorry, the clients, our clients basically are, are not interested in, in, in having those kinds of um, app or maintaining applications built this way. They may one day.
[00:40:11] Michael Chan: But it's a big risk for them now.
[00:40:12] Jared Palmer: Of course, right? Let's take this bleeding edge thing, and even if it is supposedly better, like, just 'cause something is better doesn't mean that it's going to, like, ultimately win, um, in the world that we live in. Um, you could be right, but at the wrong time. Happens all the time. So for me, like, that those languages are very powerful. The people working on them are very, very smart. In a perfect world, You know, I would definitely love to use Reason on some projects. Um, you need to strike a balance, uh, between, you know, everything is is trade-offs, right? So, when you have something like Reason, it's more expressive. Its type system is stronger. It can do more stuff. Um, sure. And it's got great error messages and it's got a great developer experience. But it's oh, but it is like a lot more to learn. Um, and the ecosystem is smaller. Um, and so to me, I don't think it's there yet. When another- I've said this publicly, like, when another large company, a large tier 1 tech company, adopts Reason as their primary language, or when the React docs are written in Reason- not like Reason React, I mean like the React docs-
[00:41:18] Michael Chan: Yeah.
[00:41:19] Jared Palmer: I'm gonna then reevaluate. But for the time being, TypeScript solves maybe like 75% of our type issues. Mm-hmm. And I'm just not so not certain that the marginal benefit of the language of of these other languages like Reason or um Reason BuckleScript or like Elm um like benefit our use case as an agency. Um you know if we were doing other stuff, maybe it would. But for right now, we're doing we're doing just fine. TypeScript, and I think a lot of people find this, is that it strikes kind of a happy balance between type safety and productivity. And at a learning curve that is like intuitive and approachable. And the documentation definitely does could could be improved, but there's so much there's so much TypeScript out there that you can learn. And uh again, like the community around it and the resources there are um a bit more uh developed in certain in certain situations. Not that there aren't vibrant communities around OCaml. It just- Totally. It seems like there's like massive energy towards TypeScript and um adoption. Uh so, you know, there's that. And so for me, you know, this is a thing that it's a very, you know, it's a contentious topic because you talk to people who work on these languages and they're very passionate about it and they have great, you know, you know, feature for feature, they will beat TypeScript. But they're not as popular. So-
[00:42:44] Michael Chan: Yeah. Well, it sounds to me like as someone who is employing a team to do your agency work, uh you need to find people who are- it's easier to find capable JavaScript developers and say, hey, here are a couple other things that we do on top of this to make our apps more robust.
[00:43:03] Jared Palmer: Pretty much.
[00:43:03] Michael Chan: Versus trying to find, you know, the needle in the haystack, you know, developer who has all this experience in a language that isn't- doesn't have the advantage of 11 years of documentation and people writing blog posts and articles about it.
[00:43:17] Jared Palmer: Right, right. Yeah. And and and and look, the someone will say, well, you can learn, you know, XYZ in a weekend. It's like, yeah, I could, or I don't need to. Right. And um, there's that, right. And there's something to be said for lowering, keeping your keeping your costs low, keeping like use boring technologies. TypeScript is becoming a boring technology for all intents and purposes. Um, at least to to us. And um, some other things are a little too bleeding edge. Like you're not gonna— for for us, when we go to to a client and we say, you know, we had this conversation with a very large media company here in the city. Um, and they were like, we were we were building this uh component, we were gonna build this component library for them. And we were they were like not yet sold on TypeScript. And we're like, well, we may deliver it to you in JavaScript, but we're gonna use TypeScript internally to build it. And but even that was kind of a stretch. So the idea of using like OCaml or um or or Reason for for for front-end stuff is- now I'm not talking about Reason or OCaml like on the back-end. Like I have no- I've I sure, like I I just don't have those problems. So I'm not doing like systems engineering. Um and if you if your company is deeply rooted in like systems engineering, like Jane Street is, like it makes, you know, they're they're they're a quantitative trading firm. So like they write their back-end stuff in OCaml. It's like one language to rule them all. Awesome, that makes total sense to me. You can transfer um engineers from the front end to the back end, right? That makes total sense. Um I'm not doing that, so not for me. But the uh but like I said, I guess like the the TypeScript like sell is is still is a lot easier. Um and the learning curve is just a lot— like you can pick up TypeScript in an afternoon.
[00:44:58] Michael Chan: Yeah.
[00:44:58] Jared Palmer: Um and it looks like JavaScript and there's something to that, right?
[00:45:02] Michael Chan: Yeah. So, what are some of the pain points that teams might be feeling that are leading them to TypeScript?
[00:45:10] Jared Palmer: That's a great question. So, if you find yourself defensively programming a lot, if you find it challenging to make large changes across your codebases, if you are rapidly iterating, um, if you're maintaining legacy code, or you think that you're gonna maintain something for a long time.
[00:45:32] Michael Chan: Yeah.
[00:45:32] Jared Palmer: And or if you're working with people that are at varying levels of their JavaScript foo, TypeScript can help a lot because it helps others sort of onboard and understand and understand code bases a lot. Like type, just types, you know, Flow too. Um, but uh and so there's just some benefits there. I think those are the big ones. Those are the big like- those are the big cases for me as to like why people are sort of like seeing the light. Um, and it just it scales so well.
[00:46:06] Michael Chan: Yeah.
[00:46:06] Jared Palmer: Um, and if you've ever had problems scaling large JavaScript applications, you know, it can be it can be daunting. Um, and so, anything to pacify the the the the little things. Um, and then also, the idea of like build time errors instead of runtime errors.
[00:46:21] Michael Chan: Yeah.
[00:46:22] Jared Palmer: A lot more fun. And so, you end up writing less tests too, right? Because you feel confident and safe over time in the type system itself. So, you're not like testing the same things necessarily. You will stop writing like defensive tests because you've got the type safety there.
[00:46:39] Michael Chan: It allows you to write the tests at a higher level, like closer to the user. If you don't have to be like, oh, I gave it this value, is it breaking or is it, you know, returning what I expect.
[00:46:51] Jared Palmer: Right. We actually do something a step uh further. So, with TypeScript, you can generate types. There are a couple different tools out there. Um, so, you can use any sort of static analysis to generate types. And we use uh a fork of ours, uh of of Swagger Codegen. So, our APIs, our back our REST APIs spit out perfect Swagger docs, almost perfect Swagger doc. Um, and we actually use this- we have a fork of Swagger Codegen that spits out all of our like REST types, um, for our for our REST API and also all of the data fetches, but based on Axios.
[00:47:26] Michael Chan: Oh, wow.
[00:47:27] Jared Palmer: So basically, we have an SDK or an application that's spit out. Um, so whenever we make changes in the backend, we just like pump out, run our like create SDK, and we Codegen 100% of our types and 100% of our data fetches. Wow. We don't test data fetching, like we're not mocking Like we're not we're like we're testing that it fired. We're not testing like it the actual we got like the string for the endpoint correct. Like that's all taken care of. And again, when we make sweeping changes, like oh, we change this, we change the name of this variable. Well, then we you know rerun the codegen and uh TypeScript will tell us where we got to go fix that you know name change. And again, as I mentioned in the beginning, you could literally be drunk and do this. Um you know you change something uh and you just go through the application and you fix it. Um, you could do something similar with GraphQL. GraphQL is an um Apollo codegen. They can like inspect your GraphQL schema and spit out types for all of your queries and mutations, uh which is cool. Um, so there's a lot of tooling that like can take you past the normal point of— um and changes the game when it comes to like what you're actually testing and your sort of safety and security and immutability in your um types themselves. Um. So, yeah, there's some there's some stuff you can do. Uh, and so, those are the big those are the big things that are like drawing people to TypeScript, I think.
[00:48:39] Michael Chan: You've mentioned it uh twice now, and and I love it. The the idea of being drunk and trying to fix something. Uh, one of my favorite developers, hero developers, is Sandy Metz. And she says that in your reviews, you should be striving to like make code pass the 2-beer test. Um, so, like if you're on call it's like a Friday night and you're 2 beers in or more, uh can can you make sense of the code in front of you? And it sounds like, you know, in this in this situation, TypeScript gets you a lot closer to that than JavaScript.
[00:49:13] Jared Palmer: Yeah. The other thing that I've found, and I guess I guess I have path dependency here, so I'm not sure that it's gonna be true for everybody, but I have found I got a lot better at JavaScript by writing TypeScript.
[00:49:24] Michael Chan: Oh, interesting.
[00:49:25] Jared Palmer: Now, this might just be- I can't say this for sure because I didn't- I wrote TypeScript for like the better part- I've been writing TypeScript for like the better part of 2 years now.
[00:49:32] Michael Chan: Yeah.
[00:49:32] Jared Palmer: So I wasn't writing just JavaScript. So I don't know the answer to this question, but I feel like I learned more. Um, so if I feel- so that's what's important, right? But um, I have a deeper understanding than I used to of how data flows through my application. Because when you write with TypeScript, you end up writing types first. Or I do at this point. Maybe when you're starting out, you might not. You might think like, I'm gonna write this piece of code, just JavaScript first, and then I'm gonna figure out how to type it later. And that's a very valid way to do to do it. Um eventually, you'll just get so used to typing things that they're doing the type annotations that like you'll just think types first. And when you start thinking types first, oh my goodness, like you just understand things before they happen. It's like you can, you describe, it's very React-like, right? Like you describe the the what, it takes care of the how. So that was an interesting sort of mental um transformation that I that I think TypeScript also helps you with. It really helps you understand and your team members understand like what is going on. Um you can look at a type- like when we look at a React component and we have snippets for how to you know set things up so it's always the same every time. You know we look at the props. Uh I know what happens in this component. I just the rest of it is implementation detail, right? Um and uh look at the props and now just look at the function itself, right? We don't even have necessarily any of the life cycles, but it's just like read top to bottom and this is what's coming in and that's what's coming and you get to the bottom of it and that's what comes out. And that's a beautiful thing. Um, there's no guessing. And uh, that I I feel has been a very, very positive— um, has impacted me in a positive way um over the course of just using TypeScript.
[00:51:08] Michael Chan: Well, I think that's interesting that uh, I really appreciate tools that improve your JavaScript. So, that's one thing I really loved about React is that, you know, I didn't feel like I was becoming a better- like for the sake of example, like Ember developer or Angular developer by learning React.
[00:51:27] Jared Palmer: Or HTML developer.
[00:51:28] Michael Chan: Exactly. I felt like, oh, I'm learning JavaScript better.
[00:51:32] Jared Palmer: Right.
[00:51:33] Michael Chan: And I think that that's incredibly value- as valuable as someone who wants to continue their JavaScript development to know that you know, when you learn TypeScript, it's something that's- it's just a little bit bigger than than JavaScript. And but effectively, it's it's putting JavaScript in front of you in the same way that something like React is. Um and you're not going to get- you're not gonna be a worse JavaScript developer because you learn TypeScript.
[00:52:00] Jared Palmer: Yeah, you're going to be objectively better at JavaScript because you write TypeScript. Um and it's like, yeah, I I would agree with that. That's a that's a val- that yeah, the you know React is interesting. It it is now more than ever, unabashedly JavaScript, right? It's just JS, for better or worse. Um, and, you know, especially with hooks now, right? Like it's it's literally just, you know, f of something is UI, right?
[00:52:24] Michael Chan: Yeah, yeah.
[00:52:25] Jared Palmer: Um, and that's super cool. What's interesting about TypeScript is you can, you know, it's it's Vue is also in TypeScript too. Like anywhere you can JavaScript, you can TypeScript basically. Um, and so, yeah, I would agree. If you if you haven't tried it, like it will just make you a better JavaScript developer. Um, and maybe even teach you a couple things about the language you didn't know.
[00:52:43] Michael Chan: Yeah.
[00:52:44] Jared Palmer: Uh, and make you understand what was happening. Or just like, you knew, it's interesting, I knew how my code worked. I just didn't have the names for things.
[00:52:52] Michael Chan: Oh, interesting.
[00:52:53] Jared Palmer: Um, and maybe that's just 'cause I like taught myself mostly. Yeah. But I just didn't, hadn't articulated it. And it was like, okay, I I remember this pattern or or that pattern, or I should do this when I see that, or this is like closure and and and that's how I should do it. But I wasn't thinking like exactly what I- I don't know. I wasn't thinking in as as as a nuanced way about types first. And that that that I seem- maybe this is a growth thing, but it sort of simultaneously happened. So, I think that's interesting too.
[00:53:19] Michael Chan: Well, it seems like typing your code gives you a higher lens into like what your code is doing. Because you're actually like saying like this is the interface for this thing. Like think of that as a black box. I'm giving it this and I'm expecting this out.
[00:53:33] Jared Palmer: Yes, yes. And it's like, you, when your types are right, you don't need to, you don't need to necessarily like jump into implementations all the time. Mm-hmm. Um, and that, that's, that's, that's exactly right. The, uh, it's a contract and if you fulfill it and then it's the contract, you don't need to read the, the, the fine print all the time. Totally. Only when there's an issue. And so there's that too, that's kind of nice. Um, so yeah, there's, there's, there's sort of, you know, we're jumping around here, but there's, there are just so many benefits that I see that are clear um and have been instrumental in our team's success and and speed um over time. And again, like day 500 TypeScript pays off. Oh, my goodness.
[00:54:12] Michael Chan: Cool. Well, I want to uh to respect your time and uh kind of wrap this up. But what are— I guess twofold question. Um what's the best way for someone to just kind of dip their toe in the water with TypeScript? And then also, where are some of the best places um to get information about TypeScript and how to start that journey?
[00:54:34] Jared Palmer: I wish I had an awesome answer for this. The TypeScript docs are quite interesting. I've had the process- I've had the thought like, wow, I should make these more beginner friendly and I'm gonna go re- I'm gonna make the best beginner TypeScript guide. And then I get started and I got started this- I've done this like 2 or 3 times and it's been frustrating because I was like, uh, wow. Uh, I go to the docs and I was like, actually, when you read every word of that, it actually is
[00:54:58] Michael Chan: It's actually
[00:54:59] Jared Palmer: pretty good. It's actually right. It's just kind of daunting.
[00:55:01] Michael Chan: Yeah.
[00:55:02] Jared Palmer: Um, and so, that's what's one of some of the intimidating things about it is that the docs itself, the docs themselves are a little daunting. And they're packed with information. Every line is very dense. Um, and you may need to read things several times to like really understand them. And like, it's gonna take a second to- uh, for me, at least, I had to I mean, I've read the advanced types um article like 20, 35, 40 times at this point. Um and I still go back to it occasionally because I was like, what does this do? Um so, you want to you know hit the docs. There's a cool there's a there's a Git book um that's like an introduction to TypeScript. Um it's pretty great. Um there's uh if you want to learn how to use it with React, um there's some guides about TypeScript and React. What's not really there. And then I think Sean um swyx has a has a good one, uh a good TypeScript cheat sheet. There are a couple of them on GitHub. If you just search like TypeScript and React. Uh really the best way to learn TypeScript and React is to go read the source code of like some of the better, more popular TypeScript um and React like libraries.
[00:56:11] Michael Chan: And what would some of those be?
[00:56:12] Jared Palmer: Uh well-
[00:56:14] Michael Chan: I mean, I know I know what you think some of those might be.
[00:56:17] Jared Palmer: No, no, no, no. Um so I would say like go read go read Palantir. It's Blueprint. Um, they write a very-
[00:56:23] Michael Chan: Formic.
[00:56:24] Jared Palmer: Okay, yeah, that too. Um, they write a they write a very, very- so Palantir uh writes a very like Java-like TypeScript. Um, you don't like I pers- if you were to look at the code, our code bases, they look a little different. Um, there are degrees to everything again. Um, you should- so again, you can see Palantir Blueprint. Uh, Shopify's uh Polaris uh design system component library is all TypeScript. That's a good one. Not not our style of React, but a good one if you're trying to get into it. Um, uh, so yeah, Formik. My my all most of my libraries are TypeScript at this point. Um, and React FNS is a good one uh of mine because it's uh if if you're looking at how to do like render props and stuff like that.
[00:57:09] Michael Chan: Yeah, yeah. And it's pretty it's smaller chunks.
[00:57:12] Jared Palmer: Yeah, they're smaller chunks. They're like smaller modules. So like it's not this like overwhelmingly inter- twined thing like Blueprint is. And there's Apollo too. Apollo is also written in TypeScript. So those are some ways to like just get your feet wet. And then, you know, there's CodeSandbox. So that's like the quickest, fastest way to get started with TypeScript in React.
[00:57:30] Michael Chan: Yeah, that's true. I always forget about that.
[00:57:31] Jared Palmer: So there's a sandbox for that. So, um, and that's pretty fun. And Create React App has TypeScript support, um, finally. So Create React App, if you go to the- you can like change the entry point to tsx and follow the instructions and Um, you can do, you know, TypeScript. That is using Babel under the hood. Um, so, that's like how you just can can get started. And then Microsoft also has some starter projects, too. Oh, cool. So, you can— like those are like boilerplates, basically. And there's one for Vue and there's one for React and there's one for Node. And yeah, those are those are like the better resources for that. And then as for like people to follow on Twitter, like follow like the TypeScript team, follow like Visual Studio Code because they're always publishing TypeScript integration stuff like that. You'll probably want to install um some plugins into your editor. If you're using VS Code, there's some TypeScript stuff um that just gets better. So just like Google that. Um and then, yeah, those are those are the big ones off the top of my head for for getting getting started. Yeah, those are them.
[00:58:30] Michael Chan: Yeah, I think that's a great place to start. I think that that gives a lot of people a lot of directions based on maybe kind of more of their interests, you know, whether that be, you know, frontend libraries or you know, uh in the case of Apollo, like data stuff or applications in terms of Microsoft and uh VS Code. Uh there's a lot of stuff there to see kind of like the the gamut of what people are using TypeScript for. That's great. Well, uh thank you so much, Jared, for taking time to chat with me today and uh the React Podcast audience and helping us kind of get a little bit closer to understanding what TypeScript is, where we might want to use it, And um yeah, just like how valuable it can be to our teams. Um so, where can people find out more information about you, the projects you're working on in TypeScript and all that?
[00:59:22] Jared Palmer: Uh yeah, so uh follow me on Twitter, @jaredpalmer. Uh jaredpalmer.com is my site. Palmer.net is the agency's site. Um @jaredpalmer on GitHub. Uh most of the libraries that I write now are in TypeScript. Um and then PalmerHQ is the is our agency's GitHub. Uh, so, yeah, those are the those are the uh places to follow me on the interwebs.
[00:59:43] Michael Chan: Nice. Nice. A good place to uh probably if you're interested in TypeScript code, uh follow Jared and Palmer Group on uh GitHub. Awesome. Thanks so much again for for your time today. Thank you.
[00:59:55] Jared Palmer: This is awesome. Always, always, always a fan. Always a pleasure.
[00:59:57] Michael Chan: Cool. Thanks, Jared.
[00:59:58] Jared Palmer: Thank you.
[00:59:59] Michael Chan: Hey, friends. I just wanted to say one last thing before you go. You're awesome. Maybe you're going into a really hard day, or you just left a really hard day in the office and are dreading doing it all again tomorrow. I have full confidence in you. I know that you're doing the best you can, and I respect you for it. This week's episode of React Podcast was edited by Mikael Delport and produced by Mikael Delport and Sarah Jackson at Spek FM. Spek is a podcast network designed to help you level up. Whether that be design or development, there are shows on this network for you. If you'd like to learn more, visit spec.fm and find another show that will help you level up. Thanks again to our sponsor, Linode. Get a $20 credit when you use the promo code REACT2019 by visiting linode.com/react. As always, reviews of this show on iTunes and pod catchers all around the internet are widely appreciated. They help us help you get the best interviews with the greatest React developers on the internet. If you like what you're hearing, you can follow us on Twitter @reactpodcast. I'm @chantastic. And see every time a new episode goes live. But it's every Thursday, so you can just know. You can join in on the Spectrum chat at spectrum.chat/specfm/reactpodcast. React Podcast. And that's all. Thanks for listening. We'll be in your ears again next week.
chantastic.fm