I updated yarn, from an unknown version (using node_modules) to v3.2.2, and my only module declaration stopped working. Prior to the update it worked fine, but after the update the module declaration is no longer working. With the upgrade I also installed the additional tools and plugins via yarn dlx @yarnpkg/sdks vim vscode and yarn plugin import typescript. The TypeScript version (v4.7.4) has not changed and there are no complaints from TypeScript aside from that the properties defined in the module declaration are not part of the type when used in the rest of the code, so I don't understand what is causing the issue or how to solve it.
Example of an error from running yarn tsc:
src/routes/nominate/loyalty.ts:16:17 - error TS2339: Property 'dbClient' does not exist on type 'Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>'.
16 req.dbClient!,
My module declaration is a simple Express.js one:
src/types/express/Request.d.ts
import {ClientSession, MongoClient} from "mongodb";
declare module "express-serve-static-core"
{
interface Request {
dbClient: MongoClient,
dbSession: ClientSession,
logger: console
}
}
Which is included by the tsconfig.json:
{
"compilerOptions": {
"incremental": true,
"target": "ES2018",
"module": "CommonJS",
"rootDir": "./src/",
"allowJs": true,
"declaration": true,
"noUnusedLocals": true,
"sourceMap": true,
"outDir": "./bld/",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"typeRoots": [
"./src/types"
]
},
"exclude": [
"./bld",
"./scripts",
"./test"
],
"include": [
"./src"
],
"buildOptions": {
"incremental": true
}
}
What should I do to either fix the issue present or replace the functionality?
If there is anything missing feel free to mention and I'll do my best to provide the additional information. Thank you!