Skip to main content
Zubin KhavarianZubin Khavarian

Writing / tag

#javascript

JavaScript modules, exports and the language features worth knowing well. 5 posts, newest first.

switch(true) in React: First True Wins

5 min read

switch(true) runs the first case that is true, which makes it a tidy way to write ordered conditions. It is the right tool less often than it looks. Here is when it earns its place.

#react#javascript

Turn on skipLibCheck

5 min read

skipLibCheck in tsconfig skips type-checking .d.ts files, so tsc spends its time on your code. Turn it on (tsc --init already does) and leave it on in CI.

#javascript#typescript

Use ESM

6 min read

JavaScript has a standard module system, and new code should use it. Here is how Node decides whether a file is ESM or CommonJS, where CommonJS still matters, and why AMD and UMD are history.

#javascript#typescript

Prefer Named Exports

4 min read

Named exports vs default exports: a default import can be called anything, so names drift. A named export keeps one name, and TypeScript renames it.

#javascript#typescript

TypeScript Has Two Decorator Systems

5 min read

Standard decorators take (value, context) and need no tsconfig flag. experimentalDecorators switches you back to the 2015 design. The two are not compatible, so pick one on purpose.

#javascript#typescript

All writing

zubin@zubin.dev: man keys

// go to

  • ghhome
  • gwwriting
  • gaapps
  • gpprojects
  • goopen source
  • gnnow
  • guuses

// move

  • jscroll down
  • kscroll up
  • ggtop of page
  • Gbottom of page
  • }next section (posts)
  • {previous section (posts)
  • ]newer post
  • [older post

// do

  • ⌘Ksearch everything
  • /search, too
  • ttoggle light / dark
  • ?this sheet
  • escclose