• ByteJunk@lemmy.world
      link
      fedilink
      arrow-up
      29
      arrow-down
      1
      ·
      5 months ago

      I spent way too long today figuring out why my app was doing something that it’s NOT supposed to do on weekends.

      I read Luxon’s docs (pretty cool lib tbh) again and again, and tried everything I could think of to get isWeekend to return a sane result.

      Turns out I was pulling a somewhat older version of Luxon, where isWeekend didn’t exist. In any sane language, I expect I’d get a huge warning about a property that doesn’t exist, but alas…

      Typescript helps me keep my sanity, but juuuuust barely.

      • mynameisigglepiggle@lemmy.world
        link
        fedilink
        arrow-up
        20
        arrow-down
        1
        ·
        edit-2
        5 months ago

        If isWeekend doesn’t exist, then the weekend doesn’t exist, so it’s naturally false.

        That’s why JavaScript gets pushed so hard - it’s part of the capitalist agenda to keep us working 7 days a week

          • shastaxc@lemm.ee
            link
            fedilink
            arrow-up
            2
            ·
            edit-2
            5 months ago

            Falsy* because it was undefined

            However, their IDE should have highlighted it as an unknown property. Guess this guy is coding in notepad or vi.

            • humbletightband@lemmy.dbzer0.com
              link
              fedilink
              arrow-up
              2
              ·
              5 months ago

              Yep, thanks for correcting me. In fact, if they write something like

              if (day.isWeekend) {...}
              

              The block will never be executed with the old version of library

              • shastaxc@lemm.ee
                link
                fedilink
                arrow-up
                2
                ·
                5 months ago

                Yeah that’s exactly what I think happened to him. He needs a better IDE and/or needs to stop copy/pasting code from stackoverflow or documentation that doesn’t match his library version.