I've run into an issue while working on my small project in Typescript. The problem arises when I attempt to nest my router, as Typescript doesn't seem to acknowledge the parent's parameter.
Within the "child" file, I have the following code:
const childRouter = express.Router({ mergeParams: true });
childRouter.get('/', (req, res) => {
const userName = req.params.username;
// This results in the error, Property 'username' does not exist on type '{}'
});
Then, in the "parent" file, the code looks like this:
import childRouter from './child';
const parentRouter = express.Router();
parentRouter.use('/:username', childRouter);
I'm at a loss on how to resolve this issue. It seems like Typescript is not recognizing that I'm using the parent's parameter. Any suggestions on how to address this?