Pete
Pete

Reputation: 3451

Any Way To Get TypeScript To Not Error When Not Using One Parameter?

I have a method call as follows where I'm not using the res parameter but am using the next parameter. I don't want to use // @ts-ignore but not sure what the best practice is to handle this situation.

Thoughts?

server.post('/rpc/Account/IsLoggedIn', function(req: any, res: any, next: () => {}) {
    req.body = 'abcd'
    next();
});

Upvotes: 0

Views: 62

Answers (1)

Jimmy Hedström
Jimmy Hedström

Reputation: 571

Add an underscore _ to the params that you don't wanna use. By doing this, TypeScript won't complain about the unused variables.

server.post('/rpc/Account/IsLoggedIn', function(req: any, _res: any, next: () => {}) {
    req.body = 'abcd'
    next();
});

Upvotes: 2

Related Questions