TypeScript is automatically configured by Next, but we need to install it as a dev dependency:
I also often end up installing
ts-node to execute TS files, or
ts-node-dev to restart the Node process on file changes while developing, both in transpile-only mode.
I also set an absolute path for imports:
Which allows me to import files this way:
Pick whatever symbol you like. A lot of people use
@/ but I find it confusing because scoped packages also start with
It is natively supported by Next, but if you are not using Next, you might need tsconfig-paths to get those paths to work with Node,
ts-node is used in production, it should have the
I also set
commonjs for a broader compatibility with NPM modules:
I find TypeScript more reliable than Flow, and it has a much bigger community and support. I would recommend Python to someone learning the fundamentals of programming though.