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.
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”.
I’ve thought about moving to typescript. Do you have suggestions for a 20+ year JavaScript dev?
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.
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”.
Just try it. You can usually convert a single file at a time. Start small (or even with a pet project)