This is my WebStorm editor screen:
Here, WebStorm marks QUASAR_ELECTRON_RELOAD and APP_URL with the red underline and displays TS2345: Argument of type 'string | undefined' is not assignable to parameter of type 'string'. Type 'undefined' is not assignable to type 'string' and QUASAR_ELECTRON_PRELOAD is undefined or APP_URL is undefined when hovering on.
I've tried to add env.d.ts file on the same directory as electron-main.ts with the following contents, but the error still shows.
/* eslint-disable */
declare namespace NodeJS {
interface ProcessEnv {
QUASAR_ELECTRON_PRELOAD: string;
APP_URL: string;
}
}
How can I remove the errors?
UPDATE
Adding the following contents to the electron-main.ts solved the problem.
(BTW, ESLint complains on using namespace with this message: ESLint: ES2015 module syntax is preferred over custom TypeScript modules and namespaces.(@typescript-eslint/no-namespace))
declare global {
namespace NodeJS {
interface ProcessEnv {
QUASAR_ELECTRON_PRELOAD: string;
APP_URL: string;
}
}
}
But, changing env.d.ts file's content as the following did not solve the problem.
/* eslint-disable */
declare global {
namespace NodeJS {
interface ProcessEnv {
QUASAR_ELECTRON_PRELOAD: string;
APP_URL: string;
}
}
}
export {};
Maybe WebStorm does not refer the other module file when checking a file's error?
