Common Mistakes and Advanced Typescript Techniques

Поделиться
HTML-код
  • Опубликовано: 5 июн 2024
  • My desk setup:
    💻 Macbook Air M2 8GB RAM, 512GB SSD: (US) amzn.to/4ckunuo | (UK) amzn.to/3PrjddH
    ⌨️ Apple Magic Keyboard: (US) amzn.to/3IGam3J | (UK) amzn.to/3TetzOQ
    🖱️ Apple Magic Mouse: (US) amzn.to/3J1Juf3 | (UK) amzn.to/48YZvfZ
    📱 Laptop stand: (US) amzn.to/49X0Ghu | (UK) amzn.to/3wZYwPy
    🖥️ Dell 27 inch Full HD Monitor: (US) amzn.to/3TFj0FX | (UK) amzn.to/49ZaIi4
    🔲 Dual Monitor Stand: (US) amzn.to/3vr0MyG | (UK) amzn.to/48XxRjK
    🎧 Beats Studio Pro: (US) amzn.to/3Tj3yy9 | (UK) amzn.to/3ViiaAr
    Are you transitioning from JavaScript to TypeScript but still encountering errors like "cannot read undefined of object"? In today's video, I'll share my insights after years of coding in both languages. Join me as we explore three common TypeScript mistakes and delve into three advanced typing techniques that will elevate your coding game.
    🚀 Quick Intro to TypeScript
    Let's kick things off with a quick overview of TypeScript. While JavaScript lacks built-in typing, TypeScript offers static typing capabilities, allowing developers to define types and interfaces for variables, functions, and classes. Now, let's dive deeper into the world of TypeScript.
    😬 3 Common Mistakes
    1. Assuming Types without Validation
    2. Using any
    3. Using Type Assertions Excessively
    🛠️ 3 Advanced Typing Techniques
    1. Utility Types
    2. keyof
    3. Mapped Types
    🔍 Closing Thoughts
    In conclusion, TypeScript offers a robust solution for writing JavaScript code with enhanced error-checking capabilities. By avoiding common mistakes and embracing advanced typing techniques, you'll unlock the full potential of TypeScript and streamline your development process.
    🔗 Useful Links:
    JavaScript vs TypeScript: The Key Differences: chat.openai.com/c/67389687-d8...
    Official TypeScript Documentation: Official TypeScript Documentation
    Stay tuned for more coding tips and tutorials. Happy coding, and I'll catch you in the next one! 🌟🚀👨‍💻
    Background song by:
    / dahjp

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

  • @SuperKidontheblock
    @SuperKidontheblock 2 месяца назад +6

    Can you imagine having a large object with different fields being returned. Zod is heaven sent.

    • @LjupcheVasilev
      @LjupcheVasilev  2 месяца назад +1

      100%! I don’t use it enough, I use AJV more, but I will be using it for my new side project.

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

      I just made the decision to use Zod inside Typescript projects after I read some really interesting articles on the net.

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

      Let us know how you're finding it after some time :)) @@heavierthanlight7173

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

      @@LjupcheVasilev will do!

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

    Really great rundown of useful tips for TypeScript! Thanks for the good work!

  • @ivanlysko6677
    @ivanlysko6677 20 дней назад +2

    I've been trying to understand the distinctions between using types, enums, and const in TypeScript. Could you shed some light on how they differ and when to use each one?

    • @LjupcheVasilev
      @LjupcheVasilev  16 дней назад

      Types is a way to define what kind of values does the variable hold and it helps with type safety, catching issues while developing etc. For example `const status: string = 'active'`
      Enums are a way to define a set of named constants. For example when we have a variable of status and we know the status can be Active or Inactive only, that's when enums are most useful. Then these enums can be used to validate the input or whenever we need to use the status we can see which values it can be.
      Const is just a way to define a constant variable, same as in javascript. Constant means the value of the variable never changes. If the type is an array then we can mutate it like add/remove items but if we define a string we can't reassign it.
      Hope that helps.

  • @nimitsavant3127
    @nimitsavant3127 2 месяца назад +1

    Very descriptive and informational thank you :)

  • @morteza7298
    @morteza7298 2 месяца назад +1

    Great video man, keep going

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

    Will you make course on typescript or Vuejs or Nuxtjs or NodeJs ExpressJs or Nestjs or Graphql?

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

      Probably not a whole course soon. But I will continue to make videos on those subjects.

  • @manishgautam2424
    @manishgautam2424 2 месяца назад +1

    That was great , You can deliver much better content , Keep it up

  • @user-dd7kw3ym5i
    @user-dd7kw3ym5i 2 месяца назад +1

    I think you don't need to check their types here 2:41 you already have defined types of it so TS will throw an error and you don't have to check it

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

      The reason why I’m checking the types there is because in my types they are set as required properties, but because they are input from the user we can’t be sure the user has actually sent all the required fields.
      I could’ve made the properties optional and then typescript will complain if they are not checked.

  • @umaralifayzullayev
    @umaralifayzullayev 2 месяца назад +1

    Wow this channel is so good 👍 👍 👍