Posts about js

10 posts

Back to the whole garden

  1. GRD 033 #693

    Running TypeScript in Node without a build step

    Node 23 strips types out of the box and TypeScript 5.8 has a flag that keeps your code strippable. For scripts and small services I dropped tsx, though the compiler still has a job.

  2. GRD 027 #62B

    When I reach for React's memo, useMemo and useCallback

    A lot of the memoisation in a React codebase does nothing, and some of it costs more than it saves. These are the few cases where I still use it.

  3. GRD 025 #945

    The tsconfig module settings I finally understand

    module, moduleResolution and the new verbatimModuleSyntax were three knobs I turned until the errors went away. TypeScript 5.0 finally made me read what they do, and now I know why my Vite app and my Node service need different ones.

  4. GRD 022 #631

    TypeScript trusts your API too much, so I added Zod

    A backend rename turned a typed field into undefined and the compiler never blinked, because types are gone at runtime. So now the data gets checked where it comes in.

  5. GRD 021 #842

    Fixing a laggy search filter with useDeferredValue

    Typing into the filter above a long table felt like typing over a bad SSH connection. React 18 has a hook for exactly this and the fix was one line. Well, two.

  6. GRD 020 #42A

    Why I stopped writing enums in TypeScript

    Enums were the first thing I reached for when I started with TypeScript. Then I read what they compile to. A const object does the same job with less magic, and TypeScript 4.9 just added the piece that was missing.

  7. GRD 018 #3A7

    Moving my tests from Jest to Vitest

    Eight months ago I left the tests behind when I moved to Vite. Moving them took an evening. Reading them took longer, because most of them tested the wrong thing.

  8. GRD 016 #259

    Why React 18 runs your effects twice

    We upgraded to React 18 and every request in the dev tools showed up twice. React does that on purpose, as a test, and our effects were failing it.

  9. GRD 013 #14B

    Moving a Create React App project to Vite

    Create React App 5 landed this week after a year of waiting, and I still moved my side project to Vite. It took an evening, mostly spent renaming things.

  10. GRD 007 #4B9

    How to solve missing chunk code splitting errors after deploy

    Code splitting is a great way to avoid huge javascript files, but weird things can happen after a deploy. Let's fix that.