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.

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.

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.

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.

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.