I know for setting .env types, we write this code in .d.ts:
var process: {
env: {
MONGO_DB_URL: string;
}
}
But if I do this in global declaration, like this:
declare global {
var process: {
env: {
MONGO_DB_URL: string;
}
}
module Express {
export interface Request {
decodedToken: DecodedToken;
}
export interface Application {
io: Server;
sessionQIDtoSocketMap: Record<string, string>;
}
}
}
It gives me this error:
var process: globalThis.NodeJS.Process
Subsequent variable declarations must have the same type. Variable 'process' must be of type 'Process', but here has type '{ env: { MONGO_DB_URL: string; }; }'.ts(2403)
globals.d.ts(44, 13): 'process' was also declared here.
If I do something like this:
declare var process: {
env: {
MONGO_DB_URL: string;
};
};
declare global {
module Express {
export interface Request {
decodedToken: DecodedToken;
}
export interface Application {
io: Server;
sessionQIDtoSocketMap: Record<string, string>;
}
}
}
The errors then go away but typescript still doesn't register the types
