🌶️ Why ditch TS for JSDoc?

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ก.ค. 2023
  • Svelte switched from TypeScript to JSDoc for their core libraries. I think other library maintainers should follow their lead!
    #programming #webdevelopment #beginner #whiteboardtheweb
  • เกม

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

  • @flix8565
    @flix8565 หลายเดือนก่อน +4

    The type safety that TS provides is insane. And if your infrastructure is capable enough, which is always the case if you use a modern environment, then using TS is not much different from using JS. It's just a file extension. And having tsc provide you with advice is a massive boon.

  • @CottidaeSEA
    @CottidaeSEA 11 หลายเดือนก่อน +7

    It's honestly absurd that more people don't know about JSDoc. If you use proper documentation for your JavaScript, there's really not much you need to use TypeScript for.

    • @shirakuyanai4095
      @shirakuyanai4095 10 หลายเดือนก่อน +1

      I tried TS for 2 days. It didn't really help me with anything. It lets me define types for variables but it really doesn't matter that much. JS revolves around objects which could be literally anything. Creating a dedicated type for every variable is just not worth the effort. So pretty much only defining the types for parameters is valuable and guess what? JSDoc does that too.

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

      @@shirakuyanai4095 It's honestly faster to just create a class rather than using TS in most cases where you work with objects. As you say, specific types for variables just takes ages. Even if you only want two different values, 'foo'|'bar' does things just as well as a TS type.
      If developers would start caring more about IDE warnings and errors instead of ignoring them, they wouldn't need TS in most cases.
      I've had the same experience as the one you're describing, you do a bunch of work and end up with a result you'd get easier by just documenting the code properly.

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

      @@CottidaeSEA Tbh if you're code's gonna break prod, TS is not gonna help anyway. Most of the errors regarding types are just numbers and strings which you can prevent by simply being a bit more careful when coding. Only takes about a few seconds more to achieve the same results as using TS which adds 50% of the work time.
      I've only had one instance where dynamic typing fucked me over which was the time I had to process a number sent from front end but it wasn't a number at all by the time it reached back end.

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

      @@shirakuyanai4095 Yeah, whenever I fuck up, I've fucked up logic somewhere. Types were never a real issue. Now, something which has been an issue is external systems doing stupid shit to URLs we've sent them.

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

      @@CottidaeSEA How long have you been in the field btw?