TypeScript Config with tsconfig.json
This is an advanced topic. If you use the recommended templates, a default typescript config file is included and you will generally not want to change it.
The recommended templates provide typescript config presets in tsconfig.json that we believe to be best practice, but they can be configured to be too strict for some, or may need to be modified if you change the name of the source or destination directories.
A typical tsconfig.json file looks like:
{
"extends": "@companion-module/tools/tsconfig/node22/recommended",
"include": ["src/**/*.ts"],
"exclude": ["node_modules/**", "src/**/*spec.ts", "src/**/__tests__/*", "src/**/__mocks__/*"],
"compilerOptions": {
"outDir": "./dist",
"baseUrl": "./",
"paths": {
"*": ["./node_modules/*"],
},
},
}
Our TypeScript template splits it into two files:
//tsconfig.json
{
"extends": "./tsconfig.build.json",
"include": ["src/**/*.ts"],
"exclude": ["node_modules/**"],
"compilerOptions": {
"types": ["node"],
},
}
// tsconfig.build.json
{
"extends": "@companion-module/tools/tsconfig/node22/recommended",
"include": ["src/**/*.ts"],
"exclude": ["node_modules/**", "src/**/*spec.ts", "src/**/__tests__/*", "src/**/__mocks__/*"],
"compilerOptions": {
"outDir": "./dist",
"baseUrl": "./",
"paths": {
"*": ["./node_modules/*"],
},
"module": "Node16",
"moduleResolution": "Node16",
},
}
You are free to override properties as you wish, this is only our recommendation after all.
If you have any suggestions on changes to make to this base tsconfig, do open an issue to let us know. We hope to collect some alternate presets along with recommended.