TypeScript Slows You Down - Here’s Why

Поделиться
HTML-код
  • Опубликовано: 3 дек 2024

Комментарии • 131

  • @samuelgunter
    @samuelgunter Год назад +184

    tsc = the slow compiler

    • @omri9325
      @omri9325 Год назад +5

    • @danvilela
      @danvilela Год назад +2

      Imagine you using rust lol

    • @nivaldolemos5280
      @nivaldolemos5280 Год назад +1

      @@danvilela rust compiler is slow for different reasons. You cannot possibly make it dozens of times faster.

    • @CamaradaArdi
      @CamaradaArdi Год назад +1

      @@nivaldolemos5280 The rust compiler is really fast my experience. The first time you build sure, it's going to be slow but after that builds are really quick.

    • @angelcaru
      @angelcaru 8 месяцев назад

      ​@@nivaldolemos5280too true

  • @ThePrimeTimeagen
    @ThePrimeTimeagen Год назад +15

    ooof, the writing with type errors and then fix after got me on a strong no. that scares me :)

    • @KaiHenningsen
      @KaiHenningsen 11 дней назад

      I think that either your types are simple. Then it's simple to get them right, so why wait? Or they're complicated/hairy. Then it's likely your final code will depend on how your types look like, so getting the type right first avoids rewriting that code. Also, without the types, you don't have the Intellisense-style help in the editor, which is not good. Sounds to me like a bad optimization.

  • @лилпипка
    @лилпипка Год назад +36

    100% agree. Have tried TS multiple times, been making all those messy types and felt like I don't wanna use it when it blocked me. But then tried Prisma w/ automatic type generation and then I got it. You should treat it like JS with types rather than typical serious (Java) language w/ types. More fun, less seriousness you know

    • @masterdr1
      @masterdr1 Год назад +1

      I had the same problem, I want to prototype fast some code, not to waste 30 minutes writing types. Linter and TSC doesn't like it;

    • @MeonisRP
      @MeonisRP Год назад +4

      чупапи муняня

    • @BusinessWolf1
      @BusinessWolf1 Год назад

      Well sure, but why would I need type safety in Js? I learned to work around type coersion and even use it sometimes.

    • @yxngboypolo
      @yxngboypolo 5 месяцев назад

      @@BusinessWolf1”why do I need type safety” the most web developer question I’ve ever heard

  • @PaulSebastianM
    @PaulSebastianM Год назад +28

    I don't like this purely based on the fact that this is not how you work with other static typing systems.

    • @Shadowdoctor117
      @Shadowdoctor117 Год назад +15

      That just goes back to the point that JavaScript just a messy language.
      Typescript is honestly just a bandage. Maybe is pretty good bandage, but doesn't actually fully fix the underlying downsides of using JavaScript.

    • @rallokkcaz
      @rallokkcaz Год назад +3

      It's a really shitty bandage for people who don't use TS. And sometimes even for people using TS.

    • @JeyPeyy
      @JeyPeyy Год назад +13

      That's the issue, people treat typescript as if it was equivalent to other statically typed languages.

    • @unimatrixzero7745
      @unimatrixzero7745 Год назад +1

      Affirmative

    • @PaulSebastianM
      @PaulSebastianM Год назад +1

      @@Shadowdoctor117 Good type systems are in my opinion becoming increasingly important with modern software engineering. While TS dominates now, it can easily be replaced by other languages once WASM integrates fully with the web browser APIs. Just like JS was once top.

  • @mariansam_was_taken
    @mariansam_was_taken Год назад +8

    Theo: don't block on TypeScript while deploying on Vercel
    Me: trying to deploy create-t3-app on Vercel, getting blocked by TypeScript

  • @ThugLifeModafocah
    @ThugLifeModafocah Год назад +5

    I hate typescript. This you described happens to me everyday. I hate typescript.

  • @Novagenesis
    @Novagenesis Год назад +2

    I mostly agree, but want to point out one thing. I would never `fetch() as A`. It's input. I don't care if you just wrote the service and are running it behind a VPN, you need Zod in the middle of it.
    `x = fetch() as unknown; Schema.parse(x)`. All set. You can always start with your zod schema being analog to an "any" until you're ready to dial it down.
    (Also, to random readers, fetch() returns a response, and you need to call .text() or .json() on it and parse that)

  • @beancoffee
    @beancoffee Год назад +15

    paying too much attention on the typechecking and also unnecessarily using return types had slowed me down a lot. When I started getting rid of these, it made it so much faster to move and ironically, felt more typesafe.

  • @hamzakhiar3636
    @hamzakhiar3636 Год назад +2

    Angular/react does this tho when you build it blocks you until you fix all the type errors

    • @Shad0wL00p
      @Shad0wL00p 6 месяцев назад +1

      Yeah, it would be nice to see an example Angular/React application where this has been changed so that it's not blocking etc. I find that running the unit tests is very slow and I have a sneaky suspicion that is due to type checking also - wonder what the recommendation for type checking in unit test is? Presumably the same, type checking is not required for unit testing, linting and separate type checking can still cover it all.

  • @queerly__coded
    @queerly__coded Год назад +66

    I honestly gauge where I am in my web dev journey based on how much of these little talks I actually understand. Getting better.

  • @lucie_gamer_yt
    @lucie_gamer_yt Год назад +3

    Hey T3, thanks for this video.
    I was recently learning TypeScript using a complete Udemy course, and the instructor always uses `tsc` and even doesn't emit files build when there are errors.
    He is a great teacher, but I actually writed down your tips from your video in my notes to also take in mind.
    Be well.

  • @davidzechowy
    @davidzechowy Год назад +5

    While building a social media platform for an app contest, I remember spending almost a day creating a typesafe hook for my api calls, but I was too sleep deprived to realize how unproductive this was

  • @Quimmoo
    @Quimmoo Год назад +3

    FUCK YEA.
    I've been coding for an almost 15 years now, started to attend coding classes and contests in an age of 15 and back then I've been exclusively working with a statically-typed languages like C++ and even then I've been dealing with errors after I've laid my initial ideas and logic down. When I was first introduced do dynamic languages like PHP and JS - the ability to test your initial ideas without doing all this boilerplating - this what sold me on those technologies. It doesn't matter if my code is a set of data transformations, or a set of behavioural rules and relationships for entities, an algorithm is an algorithm, I wanna define a set of steps, test that all those steps are in a somewhat right order (sometimes with an unhealthy bunch of console logs, yeah) and move on to optimise and beautify my stuff, because it's very fucking hard (at least for me) to develop an idea further without having a sketch first. And for some twisted reason, it's not a 'normal' way of thinking anymore. People who were working within a dynamic JS environment suddenly are all about almost unhealthy boilerplating and writing a huge bunch of DTOs even before you figured out the business logic of a feature. Yeah, sometimes I wanna start by defining an interface or a data structure, but most of the time I just wanna test that my shit is following the order, defined by business logic and then move on.
    It's specially true while building an UI components, where you need to type the props before you can test if this type actually fits because if you don't type it - well, nothing is rendered and you can go fuck yourself.
    And people are actually seeing this as an upside. Incredible.
    Not gonna lie, I was very sceptical about you and your channel at first, but after watching a couple of videos, specially the 'Is OOP Evil??? Reacting to best YT video' I was very glad that I've finally found a content creator with a strong common sense. Thanks for your content fam, appreciate it very much!

    • @troooooper100
      @troooooper100 6 месяцев назад

      I don't use types because I don't even know how to do 95% stuff I've to do im literally operating at 150% of my brain capacity and ideas come and go in milliseconds.. I've to Implement them to even know what I was thinking.
      I was thinking the best way to go about types is to use them when product has matured and only when committing to main branch

  • @oscardasilva971
    @oscardasilva971 Год назад +1

    This opened my mind, thank you

  • @zayn8649
    @zayn8649 Год назад +2

    Woah I've been having my TS errors block my browser output. So many good tips, this video totally shifted how I'm going to be using TS

  • @honefone
    @honefone Год назад +1

    I didn't see this in the comments and I asked in the discord so in the next config:
    typescript: { ignoreBuildErrors: true }

  • @markclynch
    @markclynch Год назад +10

    TS = guard rails, not a brick wall!!!!

  • @untlsn
    @untlsn Год назад +3

    "Stop Letting TypeScript Block You". Some people take it too literally and put "any" everyware. like:
    const [value, setValue] = useState([]);
    const longAdvancedFunction = (arg1: any, arg2: any, arg3: any) => {
    ...
    }
    Unfortunately, I often meet such programmers and when I enter their code. I spend half of my time figuring out how it works

  • @benfrese3573
    @benfrese3573 10 месяцев назад

    Damn, that's such golden advice. Thanks mate!

  • @puddle.studios
    @puddle.studios 10 месяцев назад

    his eyebrows have a mind of their own, one of the most expressive faces iv seen in a while, good video 10/10

  •  Год назад +3

    You got me until the point you suggested to switch off type checking in CI. In my opinion, when the code comes to CI it should already compile correctly.
    CI failing the type check, has saved me several times. Mostly due to local TS caching and how TSC works.

    • @Zokiio
      @Zokiio Год назад +2

      Think you stopped early. He continues to say you can have it separate step and he also say that a preview build don’t have to be type safe but you should block main merge.

    •  Год назад

      @@Zokiio no I watched it all. I suppose there's a different way we previews. In my opinion - any previews built by the CI system should already have correct types.
      The types could be incorrect during local dev or maybe if you use CI for catching your local dev. But when we're talking about a PR, the types should be correct already. That's my take on it.

    •  Год назад +1

      That also brings me to the next point - if it is so difficult to get your types to be correct in the Ci - you're probably doing something wrong.

    • @Zokiio
      @Zokiio Год назад +1

      @ I kind of agree with you. I don't mind the types being off in a preview (still being developed) and kept in the developers own branch, but when it is up for a PR it should have already been fixed. I do not want to review a code that is not "complete"

    •  Год назад

      @@Zokiio exactly! And it allows to catch weird cache related typing issues during the PR. At least in my experience.

  • @hanes2
    @hanes2 Год назад +1

    Become a 10x typescript speed run engineer by using Any.

  • @m.ridwanriansyah2781
    @m.ridwanriansyah2781 Год назад

    thank you, this is indeed very helpful for me that recently switch to TS for my projects

  • @SayanMondal342
    @SayanMondal342 Год назад +2

    Agreed that types should be kept as close to the data definition as possible, I generally try to keep my interfaces enclosed in my controllers but I would also disagree slightly that this should be the general pactise, IMO an api directory makes things cleaner and it can be used to only document your APIs and entities and their 'shared' types (not all the types just the ones the API needs).

  • @YTCrazytieguy
    @YTCrazytieguy Год назад

    I think this is one of your most useful videos ever

  • @JT-mr3db
    @JT-mr3db Год назад +8

    You need Jainism levels of discipline to properly add types after the fact, especially on a non trivial feature or project where type safety requires more than basic interfaces.
    Fighting the compiler as you build definitely slows you down in the immediate, but it removes the risk of you feeling too comfortable with your code to add strict high quality typing at the end. Working mostly in compiled languages has definitely brain washed me to think like this, but it's better to insulate your house as you build the walls.

    • @asimpleguy2730
      @asimpleguy2730 Год назад +1

      Same thing that i thought, that's an approach that can be good in a highly competent team of good engineers.. Doesn't work anywhere else

    • @dinkle9664
      @dinkle9664 Год назад

      I think he's just saying you don't gotta flesh shit out in test, and you should push changes asap instead of holding onto your erroring code at the end of the day.
      erroring code can just be commented out, but leave your progress if someone wants to pick it up when you're away

  • @Mitsunee_
    @Mitsunee_ Год назад +1

    about the CI thing I recently changed tests to run after the lint step. I used to require typechecks to be done first, but testing is the slowest part of my CI, so I wanna start it as early as possible. I still lint first to make sure the code even has a valid syntax at all, makes no sense to open 3 more CI steps that'll just fail because one file is missing a closing parenthesis. I've previously disabled linting in nextjs builds as well (and moved to yarn install --production, so prettier and the linter aren't even installed in deployments anymore) but wasn't aware you could also disable typechecks. I assume you still need it installed for dependency reasons tho?

  • @mainendra
    @mainendra Год назад

    Yes, totally agree, most of the time I just want to deploy to test.

  • @muhamedkarajic
    @muhamedkarajic Год назад

    There you said it. Finally :)

  • @fnfal113
    @fnfal113 Год назад +1

    to be honest I have been tempted to use typescript but never actually tried it cuz of mix reactions from the community at the same time I like to typesafe my functions or variables with comments, never had any issues with maintainability unless I'm working in a company

  • @thomassynths
    @thomassynths Год назад

    Some nice practical tips. Less of issues with TS the language, but TS the ecosystem.

  • @null_spacex
    @null_spacex Год назад

    I just make typescript as strict as I can, then forget about it until it screams at me to fix something.

  • @daleryanaldover6545
    @daleryanaldover6545 Год назад

    As someone who is still not using Typescript, I agree.

  • @hakimbouabdellah3829
    @hakimbouabdellah3829 Год назад +1

    How many times have u changed the title?

    • @t3dotgg
      @t3dotgg  Год назад +2

      Like 7 lol. This video is bombing and I have no idea why because IMO it’s one of my most useful

  • @j0hannes5
    @j0hannes5 Год назад +1

    How do you not use TSC?
    And how do I prevent my browser from blocking blocking me with ts errors?
    My client originated from a CRA that was js only.

  • @AK-vx4dy
    @AK-vx4dy Год назад

    It is not often but i agree with you...this time:)

  • @dog4ik
    @dog4ik Год назад

    First thumbnail was masterpiece why???

  • @felixmildon690
    @felixmildon690 Год назад

    Loved the lint typescript/eslint pyramid diagram with your description. Keep doing your thang Theo F DA H8AZ

    • @felixmildon690
      @felixmildon690 Год назад

      Caught that you wanna do more JavaScript talks aswell at the end. That would be amazing for the TS newbies here

  • @aleksandr2245
    @aleksandr2245 Год назад +1

    what about common types?

  • @1OvOI
    @1OvOI Год назад

    not related to the content but the random sliding images don't seem to be adding much to the presentation. would like to know what others think

  • @peacefulexistence_
    @peacefulexistence_ 10 месяцев назад

    Me, a Haskell programmer: _sweats profusely on the type system abuse_

  • @gideonmaxmerling204
    @gideonmaxmerling204 Год назад

    I generally agree with the "keep type definitions close to usage" but in some cases, like modeling complex APIs with complex types that may rely on each other (i.e. one type containing arrays of another type, like Pokemon stats in a fight description), I find it much more comfortable to have one file with all the typedefs, as I won't have lines of code in the middle of complex type definitions

  • @ayushgogna9732
    @ayushgogna9732 Год назад

    not to use tsc then what is the alternative way to do things ? explanation was good but i dont know what to do next

  • @maurov6861
    @maurov6861 Год назад

    Ultimately, what is the benefit of using typescript? i am beginner and i still have a lot to learn about javascript. Is there a connection between css/tailwindcss and javascript/typescript?

    • @maurov6861
      @maurov6861 Год назад

      @@AustinCameron is required?

    • @ChillAutos
      @ChillAutos Год назад +6

      Typescript gives you the ability to go really fast once you learn how to actually use it. Don’t listen to the js fan team in this comment section, they never bothered to learn properly because you can cheat in typescript so anything past basic types they stumble and get mad at the compiler errors. Never met a single ts dev who knew their shit that would ever think about writing js for anything more than a quick personal project script.

    • @maurov6861
      @maurov6861 Год назад

      @@ChillAutos thanks Rick

    • @nivaldolemos5280
      @nivaldolemos5280 Год назад

      google: what's the advantage of static typing
      The advantage of typescript is the same of any typed language.
      Also, you get better autocompletion and IDE tooling.

  • @davidsanders4463
    @davidsanders4463 3 месяца назад

    I don't agree with the last one. I don't want non type safe code in my remote master. I get the speeding up the cli thing, but seems like it defeats the purpose of typescript.

  • @zcythe-z6u
    @zcythe-z6u Год назад

    does CRA run TSC in it's build command?

  • @rememberme2170
    @rememberme2170 Год назад +1

    Yes. And it's taking away the coding joy. I want to have fun in making stuff work, rather than have to constantly satisfy TS complaining at every step.

  • @user-qe2ps9vm9o
    @user-qe2ps9vm9o 10 месяцев назад

    Polymorphism in javascript was an intentional choice. This removed a huge barrier to entry for building web focused code. Untyped programming is the primary reason that the internet grew so rapidly. Your argument for typescript must address this or it will fail (which is happening).

  • @sam-kmn
    @sam-kmn Год назад

    I genuinely feel like devs in my country dgaf about innovations and improvements. It makes me sick when I ask recruiters if they are using Next, and they respond "Next what?"

  • @anasouardini
    @anasouardini Год назад

    vite still uses TSC though

  • @RA-xx4mz
    @RA-xx4mz Год назад

    So allow implicit any?

  • @kassios
    @kassios Год назад

    Preach!

  • @essenmitsosse
    @essenmitsosse Год назад +1

    TypeScript should just officially separate the two:
    - type checking
    - removing types to get out JavaScript
    Because there is 0 overlap in those two steps, and having them both in the official tooling is causing more confusion then it helps.

    • @nextorLeon
      @nextorLeon Год назад

      Javascript is Typescript without types. Why the complain?

    • @essenmitsosse
      @essenmitsosse Год назад +1

      The complaint is that tsc is doing both in one step (as pointed out in the video), which makes it hard to see they are two unrelated steps.

  • @naman_dw
    @naman_dw Год назад +1

    I was hesitant to adopt typescript, and I have to say it does take about 2-3 days of training. But once I got used to it it feels like I am flying. Thanks for introducing me to TS Theo

  • @jalaybeewala
    @jalaybeewala Год назад

    Adam scott???

  • @Brad_Script
    @Brad_Script 10 месяцев назад

    imagine using typescript when jsdoc does the same thing without a compilation step

  • @volshebnikozz
    @volshebnikozz Год назад +3

    Theo's putting these based takes so much that I want to work at Theo's company 😭😭😭

  • @trappedcat3615
    @trappedcat3615 Год назад

    I almost never use interface or type defs

  • @marcvanrenterghem5468
    @marcvanrenterghem5468 Год назад

    I would not ship code that have types error...

  • @cheechlabeech
    @cheechlabeech 2 месяца назад

    it does, but chatgpt to the rescue.

  • @gro967
    @gro967 10 месяцев назад

    As long as you don’t use JS anymore, it’s not important how you use TS.

  • @FlorianWendelborn
    @FlorianWendelborn Год назад +2

    When you said "don’t run TS in CI" I immediately disliked this video. You then clarified you’re only talking about CI deployments and not about merges, so I changed it back.

  • @ToddDunning
    @ToddDunning Год назад

    Ok so Zod for everything then?

  • @Pptruenoz
    @Pptruenoz Год назад

    Typescript has so many inconsistencies and weird behaviors, I hate it. However it's a necessary evil.

  • @greendsnow
    @greendsnow Год назад

    If you're not on a team, don't use TS.

  • @Dingsel
    @Dingsel 2 месяца назад

    or hear me out: JSDoc

  • @LostMekka
    @LostMekka 10 месяцев назад

    side note regarding types for api calls: in my workplace i convinced everyone to use openAPI for every project and this was a huuuge productivity boost for us. the api spec sits in a separate repo and CI builds versioned clients and server subs and publishes them to our npm and maven repositories. imho, writing api types and calls yourself is a potential source of integration bugs that can be skipped entirely by having one source of truth. but its still fine for small projects or rapid prototyping ofc

  • @johnnytestarossa
    @johnnytestarossa Год назад +3

    This totally sounds like you are one of those beings that sorts their lego bricks first and then tries to find a labeling system afterwards and wastes everyones time in a 2hr meeting explaining their thought process behind it instead of designing a system together first with a concise and logical plan and then sort the bricks in accordance so everyone knows how it works beforehand.

    • @lucastavares3518
      @lucastavares3518 Год назад

      Knowing how to use said tools literally fix all his complains

  • @SteinGauslaaStrindhaug
    @SteinGauslaaStrindhaug 10 месяцев назад

    I hate typescript (Admittedly TS is not something I've willingly chosen to use; it's been forced on me by others in the project) most of the time it doesn't do anything for me one way or the other except when it gets in my way and stops with some nonsensical error; and requires me to spend hours writing bizarre incantations just to convince the typescript engine that what I've written (that I know will work in JavaScrit) is what I want... Or I can just give up and use "unknown" or "any" everywhere just to get it to shut up. Which makes it all useless. I don't mind simple type definitions for function args or component props as long as they are optional; but I don't understand the point of adding types everywhere. And when you use libraries written in JS where you need to import a separate library (that tends to get out of sync with the library it's supposed to be for, because of course the type library doesnt have the exact same version numbers as the js library) to get the types, it's just hell.
    What do I really gain from having to convince the compiler I'm right just for it to discard all the type information when writing it as JavaScript anyway?
    At least PropTypes have runtime warnings when you feed a component props with a wrong type (though, even here 95% of the time; it's the code that is correct and just someone who has written the PropTypes definitions wrong or forgotten to update them. Or someone who has written boolean props as required, meaning they will essentially give warnings if you try to use them as intended and not set them when y).
    Type errors is _very_ rarely the cause of bugs in the code I write; with the one exception is when async fetches from servers I don't control return unexpected data, or malformed JSON; which a compile time check of "types" can do nothing about; everything fetched over HTTP is strings anyway and your code just has to assume it is a sensible JSON string and parse it as such. I normally write all code so that it tolerates unexpected null's and I will generally only trust that the type is already correct within a collection of functions in the same file; the function called from outside I will normally just parseInt any integers in case it's a string anyway; because if it comes from a browser event, you never know for sure if the browser will give the data as a string or a number etc. And TypeScript actually makes writing defensive code like this harder, because you then have to make type definitions that allow both integers (the desired type) and all sorts of invalid types, just so it will allow you to write parsing code to handle that.

  • @lucasstark
    @lucasstark Год назад

    Ship code that isn’t type safe.😅 That’s called JavaScript. More of us need to learn than that typescript is not a language, syntax sugar.

  • @Thomas-uy4vn
    @Thomas-uy4vn 5 месяцев назад

    Why use typescript when you can just use Joi on useful data with plain JS. Pointless

  • @alexanderkrist95
    @alexanderkrist95 Год назад +1

    It's always hard at the start with Typescript but by understading how to work with it you've got to at least 2x your dev output.

    • @ChillAutos
      @ChillAutos Год назад +1

      Ya, I swear he doesn’t even like typescript. Typescript has sped up my development significantly because I bothered to learn how to use it. Adding types take fuck all time, every now and again you get a few hairy ones but one you learn ts it still won’t take that long. I’ve never heard a dev who knows how to use ts properly say it’s slowing them down. It’s always the whiners who tried it for 5 minutes one time or those who use any everywhere and call themselves ts devs.

    • @alexanderkrist95
      @alexanderkrist95 Год назад

      @@ChillAutos totally! All my projects are ts only, gotta love it.

    • @ChillAutos
      @ChillAutos Год назад

      @@AustinCameron are you actually implying that modern IDEs can replace ts? If so… lol. If not then what is your argument. Neither of us said anything about what you just said. Nice straw man attempt though.

    • @ChillAutos
      @ChillAutos Год назад

      @@AustinCameron and yet not one either of us said lmao.

  • @gabrielcastilho4168
    @gabrielcastilho4168 Год назад

    Yeah, no, I can not agree with this. Sorry

  • @i_youtube_
    @i_youtube_ Год назад +1

    As a software developer, try machine learning then tell us if you enjoy it more than software development

    • @beancoffee
      @beancoffee Год назад +3

      machine learning is good and all, but it is so much OVERRATED and being implemented when not even necessary.

    • @i_youtube_
      @i_youtube_ Год назад

      @@beancoffee but you know there are problems hard to solve without ML.

    • @ishanksharma9051
      @ishanksharma9051 Год назад +4

      *sees a video not about AI/ML*, comment machine learning is enjoyable ,
      extra chromosomes?

    • @danvilela
      @danvilela Год назад

      Ml is just data science.. statistics and shit. Too boring

    • @i_youtube_
      @i_youtube_ Год назад

      @@danvilela why boring for you? What's your field of interest?

  • @PapaVikingCodes
    @PapaVikingCodes Год назад

    Typescript is KING. Love my stack. Slowing you down? Pffffft.

    • @nivaldolemos5280
      @nivaldolemos5280 Год назад

      video is not about avoiding TypeScript, but about using the compiler where it's not really needed.

    • @PapaVikingCodes
      @PapaVikingCodes Год назад

      @@nivaldolemos5280 yea I watched it dude. Commenting on a portion of what he was saying. Good for you on the compiler info.