Closed
Description
TypeScript Version: 3.9.6
Search Terms:
6133, unused parameter, quick fix, code action, tsserver
Code
const express = require('express')
const unusedImport = require('fs')
const anotherUnusedImport = require('util')
const app = express()
const port = 3000
app.get('/', helloWorld)
app.get('/used', (req, res) => res.send('used'))
function helloWorld(unusedReq, res) {
return res.send('Hello World!');
}
function unusedFunction() {
}
app.listen(port, () => console.log(`Example app listening at http://localhost:${port}`))
Expected behavior:
If I apply the code action "Delete all unused declarations" to "unusedImport", it, "anotherUnusedImport" and "unusedFunction" should be deleted, but nothing else.
Actual behavior:
The parameter "unusedReq" in helloWorld is also deleted, but the line app.get('/', helloWorld)
is not modified.
The unread req
parameter in app.get('/used', (req, res) => res.send('used'))
is correctly not removed.
If I were to change the line to app.get('/', (req, res, next) => helloWorld(req, res, next))
it would be adjusted correctly, but using the function directly with a changed parameter set changes the behaviour.
Playground Link:
Related Issues: