Typescript tsconfig file

I will add over time some specific ways to setup a typescript environment. For the immediate term, the idea is to handle the basics:

  • how do we tell typescript where to build the javascript files
  • what version of type do we set and why
  • what is the use of lib in tsconfig

tsconfig can have a huge amount of options and each can help the environment to be better suited to what we want to use it for. The first tsconfig is the very minimal one for us to launch a beginner project and reap the rewards with using typescript

The file tsconfig.json at the root of the project like below will enable typescript latest stable version to compile the ts files and add their compile js version in the build folder. That means build can be ignored with git. It means as well the code is validated with the recent syntax of typescript (this is not always what we want for an old javascript project) and commonjs allows to have typescript files to be written in modules rather than ES6.

{
  "compilerOptions": {
    "target": "ES2022",
    "module": "commonjs",
    "outDir": "./build",
  }
}