Initially, I acknowledge that there are numerous similar questions out there, but none of them seem to provide a solution to my specific issue...
Here's the setup of my ElectronJS project created with Nextron and its file structure looks something like this:
├── main/
│ └──...
├── renderer/
│ ├── src/
│ │ └── index.ts
│ ├── td/
│ │ └── env.d.ts
│ ├── ...
│ └── tsconfig.json
├── tsconfig.json
└──...
The content within the root tsconfig.json
file is as follows:
{
"compilerOptions": {
"target": "es5",
"module": "esnext",
"moduleResolution": "node",
"jsx": "preserve",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"isolatedModules": true
},
"include": ["renderer/next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules", "renderer/next.config.js", "app", "dist"]
}
Meanwhile, the content in renderer/tsconfig.json
is:
{
"extends": "../tsconfig.json",
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@src": ["src"],
"@src/*": ["src/*"]
}
},
"include": ["./td/*.ts"]
}
Everything runs smoothly when I execute the project via
npm run dev
or
npm run build
However, in vs-code, I'm encountering errors (within files in the renderer
directory) regarding constants and other declarations not being recognized (even though they are defined in /renderer/td/env.d.ts
)
In essence, I can continue working despite seeing IDE errors, knowing that the build process will function properly (meaning I can retrieve values from declared environment constants and access specified path aliases), but it's still quite frustrating...
Any suggestions on how to enable vs-code to accurately detect the included files?
As a reference, the content of /renderer/ts/env/d/ts
resembles:
/** Env constant set to (package.json).name */
declare const PACKAGE_NAME: string;
/** Env constant set to (package.json).version */
declare const PACKAGE_VERSION: string;
/** Env constant set to the build ID */
declare const BUILD_ID: string;
/** Env constant set to the git commit hash */
declare const COMMIT_HASH: string;
/** Env constant set to the 7 first characters of the git commit hash */
declare const COMMIT_HASH_SHORT: string;
/** Env constant set to `true` for server-side code usage, or `false` for client-side delivery */
declare const IS_SERVER: boolean;
/** Env constant set to `true` for production build, or `false` for development */
declare const IS_PRODUCTION: boolean;
This essentially declares the environment variables set during build time by webpack on NextJS
Edit: Uploading a repository with the basic configuration to replicate this issue: https://github.com/danikaze/vscode-multi-tsconfig