The Best Ways to Organize and Define your TypeScript Types!

แชร์
ฝัง
  • เผยแพร่เมื่อ 17 พ.ย. 2024

ความคิดเห็น • 13

  • @sathishkannan6600
    @sathishkannan6600 ปีที่แล้ว +7

    I would never use .d.ts files as typescript doesn't check these files by default. When we enable checking these files, typescript will scan even node_modules. Better to stick with types.ts files

    • @covalence-io
      @covalence-io  ปีที่แล้ว +1

      I've never had an issue with TypeScript not checking them by default. Do you have a tsconfig or no? Also if you're using types for npm packages, those .d.ts files will be in your node_modules @types folder anyway. If you do not want this behavior, I believe you can exclude folders like node_modules from being looked at.

  • @sadlife7262
    @sadlife7262 ปีที่แล้ว +1

    Amazing tutorial! Thanks for sharing this knowledge, i always get a bit confused when thinking about how will i organize the types.

    • @covalence-io
      @covalence-io  ปีที่แล้ว

      100%! Glad you enjoyed and hope this helps make your projects a little bit easier moving forward :)

  • @gamingbud926
    @gamingbud926 10 หลายเดือนก่อน

    Spectacular! Thanks for the advice.

  • @aniketjadhav2569
    @aniketjadhav2569 ปีที่แล้ว

    Great advice 👍 thanks.
    Can you explain when to use interface and type for reusability

    • @covalence-io
      @covalence-io  ปีที่แล้ว +1

      So types can be primitives whereas interfaces cannot, but for the most part, and in all other cases, interfaces should most likely be used over a type. Interfaces provide better type checking capabilities and allow for more thorough errors to be shown at build/compile time. There are a lot of people that feel that types should be used when you're talking about a physical model whereas interfaces should represent an abstract model that many different models can implement, but I tend to disagree with this just a bit. Personally, I tend to think that types should be used when you want a final declaration of a model that you do not want the possibility of extending further (interfaces can be redeclared multiple times and thus the model extended) whereas if you don't mind that aspect, I'd go with an interface.

  • @TypescriptErrorsCentral-hg7hv
    @TypescriptErrorsCentral-hg7hv 6 หลายเดือนก่อน

    🚀 Tired of banging your head against the wall with TypeScript errors? Look no further than TypescriptErrorsCentral! 🎉 Dive deep into TypeScript & JavaScript errors (even those pesky frameworks!) with crystal-clear examples to squash bugs for good. Perfect for devs of any level! Plus, our community rocks-drop your error message in the comments and let's tackle it together. Don't miss out-subscribe now and kiss those headaches goodbye! 💻✨ #typescript #javascript #programming #errors #coding #devcommunity

  • @siravid_thongsook
    @siravid_thongsook 11 หลายเดือนก่อน

    So helpful thank you😊

  • @amranmohamed377
    @amranmohamed377 ปีที่แล้ว

    Can not find namespace models

    • @covalence-io
      @covalence-io  ปีที่แล้ว

      It's created at the 2min mark

  • @cherrycasicas6828
    @cherrycasicas6828 6 หลายเดือนก่อน

    code gymnastic