Eric Liprandi Eric Liprandi - 3 years ago 382
TypeScript Question

how can I avoid TS6133 errors when using anonymous methods?

We have a TypeScript project that I am trying to clean-up a bit.
I started turning on stricter type-checking. Today, I just enabled


We use
and the following code is getting flagged with a
error TS6133: 'req' is declared but never used.

How can I rewrite this to comply?

import * as express from 'express';

const app = express();

app.get('/', (req, res) => {

Obviously, I have to declare
if I want to have

Answer Source

You can resolve this error by prefixing or replacing the unused parameters with an underscore. In this case, you could prefix req as _req:

app.get('/', (_req, res) => {

See this post for more details.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download