What is the best way to set up a basic TypeScript framework for starting a program with strict settings, based on the following program structure?
- An initial "client" code containing the actual program logic
- A separate "utility" module for defining functions and extensions (which can be used to create additional modules)
- A definition file that allows for extensions from the utility module mentioned in point 2.
This setup should adhere to strict TypeScript rules to fully utilize TypeScript features instead of relying solely on plain JavaScript. This involves using a tsconfig.json configuration similar to the one below:
{
"compilerOptions": {
"strictNullChecks": true,
"allowJs": false,
"alwaysStrict": true,
"noImplicitAny": true,
"types": [
"node"
]
}
}
To summarize, the project will enforce strict null checks, disallow plain js files, maintain consistent strict mode, eliminate implicit any types, and explicitly define each imported type within the project.
The only flexibility allowed is in the "relaxed" sections related to include
, exclude
, and files
in the TypeScript project file. These sections ensure that only relevant .ts
, .d.ts
, and .tsx
files located in the current directory are included in the build process, avoiding any unnecessary or unrelated source code cluttering the folder.