Senior Typescript Features You don't Know About - clean-code

Поділитися
Вставка
  • Опубліковано 10 січ 2025

КОМЕНТАРІ • 43

  • @mattpocockuk
    @mattpocockuk Рік тому +14

    Nice explanations!

    • @CoderOne
      @CoderOne  Рік тому +2

      Thanks Matt! I enjoy your Typescript content

  • @ExoMemphiz
    @ExoMemphiz Рік тому +60

    Nothing really senior about this, tbh. Was thinking maybe you'd go through recursive types, but "readonly" as a built-in utility type, together with the other types, type branding and type guarding are definitely not senior-level stuff.

    • @theLowestPointInMyLife
      @theLowestPointInMyLife Рік тому +1

      So what is senior then

    • @Lewboskii
      @Lewboskii Рік тому

      I think it's more of Senior level best practices rather than senior level features, since anyways as a typescript senior you are not going to be doing recursive types, decorators or weird typescript shit everyday

    • @dinoscheidt
      @dinoscheidt Рік тому

      @OP what you mention is rather „principal“ level stuff. If you need the features that you mentioned you either have a very very very messy and poorly structured codebase or build something so advanced, it almost needs meta programming capabilities.

  • @twothreeoneoneseventwoonefour5
    @twothreeoneoneseventwoonefour5 Рік тому +16

    Not a typescript feature, but a javascript one, but I found that surprisingly not many people know about/use "??" and "??=" operators. They are very useful for dealing with default values when something can be undefined(you run into this situation frequently). People tend to use || and explicit =, but it isn't really recommended. || is going to trigger any falsy value, so even if it is 0 or "", it will short circuit to the right value, when ?? is only for undefined and null - which is exactly what you would want in 99% of cases.
    I knew about this feature from a long time ago, but it actually made most sense when I wrote some dart(flutter) code. There, the || and && operators are used only for actual boolean values and there is no concept of "truthy and falsy values", so you need to use ?? operator there, which made perfect sense to me. Since then, I no longer use || and && for dealing with undefined values. Except in some jsx where I still use && though(but that is different).

    • @linkfang9300
      @linkfang9300 Рік тому +1

      I didn't know this operators and it is AWESOME! Thanks for sharing!!!

    • @sivuyilemagutywa5286
      @sivuyilemagutywa5286 Рік тому

      for me for objects, and strings I use ||, because {}, "", undefined, and null I treat the same, but for numbers, I use ??, because of 0, I learned about || and ?? the hard way.

    • @twothreeoneoneseventwoonefour5
      @twothreeoneoneseventwoonefour5 Рік тому

      @@sivuyilemagutywa5286 then you have crap data or code in the first place. You should never have a {} or "" in your external data. You also should never create a {} or "" in your own code. It is always either null, [](empty array), rarerly undefined, or, actual usable data.

    • @eqprog
      @eqprog 11 місяців тому

      {} is not a falsey value????

    • @twothreeoneoneseventwoonefour5
      @twothreeoneoneseventwoonefour5 11 місяців тому

      @@eqprog actually {} is a truthy value apparently. 0 and "" for example are falsy. I edited my comment to fix it.

  • @abolfazljalildoost766
    @abolfazljalildoost766 Рік тому

    Dude awesome. loved every minute of it

  • @Vetal-dc8ir
    @Vetal-dc8ir Рік тому

    Really cool video, I am going to rewatch minimum once for push all this information to my brain 🧠 branch 😅 Right now I am watching your another video with same theme - cool job ‼️

  • @nikkodelossantos6116
    @nikkodelossantos6116 Рік тому +2

    Awesome tutorial!!!! Liked and Subscribed!

  • @macr76
    @macr76 Рік тому +32

    Those are definitely not "senior" typescript features - those are a little bit more advanced, but still basic features (still very useful, especially discriminating unions).

    • @CuriousSpy
      @CuriousSpy Рік тому

      I made kirka for those unions 😊

    • @ya4dang1
      @ya4dang1 Рік тому +1

      I would say those are intermediate stuff. Maybe customizing tsconfig for various project is a bit more challenging. And also let's not forget decorators

  • @kirolosmahfouz9173
    @kirolosmahfouz9173 Рік тому

    Great video keep upload this kind of videos

  • @lasindunuwanga5292
    @lasindunuwanga5292 Рік тому

    When I saw the senior thing in the title I knew it is gonna be junior thing
    Senior or junior don’t reinvent the wheel
    Just google what you want to do, there is probably some way to do your 10 lines code in one line unless you are doing some rare thing no one has done before
    For typescript, there is something called utility types. Check them. They are pretty handy

  • @rockNbrain
    @rockNbrain Рік тому

    NICE JOB! TKS

  • @joelinman6455
    @joelinman6455 Рік тому

    in your 'Advanced Types' section at the beginning. Are the props converted from string types into read-only types? as that is what it suggested when you hovered over 'props.title'.
    or do they stay as strings that extend the read-only type. I'm wondering if there are any issues that could be come across by setting a strings type to readonly other than trying to edit the string itself.

  • @ThanHtutZaw3
    @ThanHtutZaw3 Рік тому +2

    Just a tips for beginners . when passing props with typescript , I use vs code tools that can fix infer types automatically .
    After passing props , I don't destructure it and I only write export default function App(props) . So I can click the props and ctrl + . vs code can fix type issue .
    Not exactly but I like to use it because I don't have to write prop types manually. Then we can adjust type what we want.

    • @fouadchahd2969
      @fouadchahd2969 Рік тому

      Can you please explain more or link me

    • @ThanHtutZaw3
      @ThanHtutZaw3 Рік тому

      @@fouadchahd2969 drive.google.com/file/d/1dvErD6uDq3jlnLo3PgzW0Rc-Lc_vHbZp/view?usp=share_link

    • @tbkswagg
      @tbkswagg Рік тому

      Dude youre talking about adding any everywhere if you dont have correct typing anyways if yes then if will add the shape instead of the type itself. So it is useful if you dont have a sperate named type for your object

    • @ThanHtutZaw3
      @ThanHtutZaw3 Рік тому

      ​@@tbkswagg Yes It is only shortcut way for adding type structure . not the real type . I prefer this way because you only have to edit any type with actual types. You don't think it is fast way to type ?

  • @Muhammed-nani964
    @Muhammed-nani964 Рік тому

    Long time no seen , wlc , or maybe it’s me

  • @lucaslevandoski2946
    @lucaslevandoski2946 Рік тому

    Hey man, that is really nice, why don't you do a PR to add the readonly thing to actual typescript repo instead ?

    • @lucaslevandoski2946
      @lucaslevandoski2946 Рік тому

      @@carlosmagno326 nice, didn't know it, that type declaration from the video is kinda useless then

    • @carlosmagno326
      @carlosmagno326 Рік тому

      @@lucaslevandoski2946 its good to know how to do it by yourself, case you want that readonly to do something else... but yeah, kinda useless

  • @dwikurniawan1376
    @dwikurniawan1376 Рік тому

    amazing

  • @ChimbzZ
    @ChimbzZ Рік тому

    I love your tutorials 🫶! But to be fair, the title is misleading. These aren’t “senior” features. I’d say beginner to intermediate.

  • @LarsRyeJeppesen
    @LarsRyeJeppesen Рік тому

    It's a pity you're a React-only channel, otherwise great channel

  • @noNullMoments
    @noNullMoments 9 місяців тому

    😅 the variables called a generic captain

  • @rishiraj2548
    @rishiraj2548 Рік тому

    🙏👍

  • @JEsterCW
    @JEsterCW Рік тому +5

    I'm sorry, but the first example only showcase how you don't realize that you don't really need that generic at all, lol....no offense buddy, but it sounds funny cause it's totally clickbait thing at this point, since its bad, not senior-like. Maybe senior over there where youre worknig at is at this level, but definitely not worldwide, but from what i have seen you never ever worked at any serious company and you only do freelance stufff, so ye lol.
    Really good video tho, kinda WebDevCody vibes :)

  • @bhumit070
    @bhumit070 Рік тому

    1) It won't work for deeply nested objects. and I am leaving the video.

  • @Tarabass
    @Tarabass Рік тому

    Saying that the switch statement is part of a senior solution is very strange in mine opinion. Switch statements are code smell and should be avoided if possible..

  • @iamworstgamer
    @iamworstgamer Рік тому

    to be honest first one looks ugly,