We have a Typescript project where some of the files are auto-generated by a tool that we have. This tool fetches some interfaces/dtos/enums from our backend project and generates types in our front end project for us to use.
Whenever we regenerate the files where those definitions are located, the IDE no longer can find those types and complains that 'Cannot find name X', even though we have the file open in the IDE. Restarting the IDE solves the problem, and as long as we don't regenerate the definition file we are okay. Even though the IDE is complaining about not finding those files, the project still compiles and runs fine - we have found no issues during debugging.
This error occurs sporadically, and both in Rider and VSCode. For our Rider users, this happens sporadically, though for our VSCode users this is consistent behaviour. Whenever the files are regenerated, the IDE needs to be restarted.
Our tsconfig.json files looks like the following:
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"baseUrl": "src",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": false,
"noEmit": true,
"jsx": "react-jsx"
},
"include": [
"src/**/*",
"src/enums.d.ts",
"src/api.d.ts",
"src/models.d.ts",
"src/models-static.d.ts"
]
}
Some of our devs believe that the issue might be related to large definition files. The four files you can see in our include list are the generated files. 15k lines of code are generated through the four files, where 14k~ of them are located in one of them. It is difficult to guess how many types/interfaces are actually generated, but my best guess would be at in the ball park of 1k, based on searching for interface/type on the files. Most of them are located in the one large file.
Any help in trying to figure out what the issue is would be greatly appreciated.
Have tried changing the "includes" section of the tsconfig file to only have the src directory in it
"include": [
"src/**/*"
]
and also completely removed it. That did not help. Breaking down the file would require a large rework of our tool, so we want to figure out if that would actually solve the problem before we dig into it.