Exploring Visual Studio Code Features
Working on my TypeScript project in Visual Studio Code has been a great experience, especially with the helpful IDE features like suggested variable names, imports, and unused variables.
However, I've noticed a unique issue when cleaning up my code by removing unused imports - it also ends up removing unused parameters in callback functions, causing some unexpected changes.
For instance, when working with Express controller functions and wanting to fetch something without any filters, this issue becomes apparent:
function getAllItems(req: Request, res: Response)
Removing the unused parameter req
can lead to a mismatch in the function signature:
function getAllItems(res: Response)
This alteration may not align with the callback function requirements.
Exploration and Solutions
I discovered the "noUnusedParameters": true
option in TypeScript's tsconfig.json, but I am looking for a solution that preserves unused parameters, especially in non-callback functions.
Seeking a Solution
Is there a way to customize Visual Studio Code's behavior to retain unused parameters that are not in the last position, regardless of whether they are used or not?