this post was submitted on 16 Mar 2025
804 points (100.0% liked)

Programmer Humor

21852 readers
1100 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
804
C++ (ani.social)
submitted 1 week ago* (last edited 1 week ago) by [email protected] to c/[email protected]
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 9 points 1 week ago (3 children)

I've thought about moving to typescript. Do you have suggestions for a 20+ year JavaScript dev?

[–] [email protected] 2 points 6 days ago

I suggest against it. Just use JSDocs syntax and typescript (the CLI and VSCode checker) will check it. No need to use transcompiler anymore. It was more useful when JS itself was more ES5 based and CommonJS.

Using something like esbuild will get you minification if you want it, but it's only for deployment, not actually needed for runtime. Having pure JS code is much easier to work with and debug.

[–] [email protected] 17 points 1 week ago

Try porting a very small bit of behavior into a new tiny library or module that is Typescript based and independently published. Enable the strictness checks in tsconfig - really, really resist the urge to use any, and enforce that any is disallowed in tsconfig. Familiarize yourself with its utility types that really trip new authors up. "Record" comes to mind here, and others that involve generics if you haven't before worked with generics. Some of the type error messaging can be pretty obtuse - don't be afraid to paste them into an LLM (or use Copilot enhanced Intellisense) to explain what it actually means. IMO the type violation messaging is a weak dev experience point for new authors, so don't sweat it if you occasionally "struggle to make the squiggles go away".

[–] [email protected] 7 points 1 week ago

Just try it. You can usually convert a single file at a time. Start small (or even with a pet project)