Skip to content

No overload matches this call error ts(2769) #6545

Open
@vishalsingh2972

Description

@vishalsingh2972

This is my indexWithZod.ts file:

import { z } from 'zod';

export const appWithZod = express();
appWithZod.use(express.json());


const sumInput = z.object({
  a: z.number(),
  b: z.number()
});

appWithZod.post('/sum', (req, res) => {

  const parsedResponse = sumInput.safeParse(req.body);

  if (!parsedResponse.success) {
    return res.status(411).json({
      message: 'Incorrect inputs'
    });
  }
  
  const answer = parsedResponse.data.a + parsedResponse.data.b;

  return res.json({
    answer
  });
});

I am getting error at (req, res) => { where the exact error message is

No overload matches this call.
The last overload gave the following error.
Argument of type '(req: Request<{}, any, any, ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>, number>) => Response<any, Record<...>, number>' is not assignable to parameter of type 'Application<Record<string, any>>'.
Type '(req: Request<{}, any, any, ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>, number>) => Response<any, Record<...>, number>' is missing the following properties from type 'Application<Record<string, any>>': init, defaultConfiguration, engine, set, and 63 more.ts(2769)

Here is the additional bin.ts file for reference:

import { appWithZod } from './indexWithZod';

appWithZod.listen(3001, () => {
  console.log('Server (appWithZod) is running on PORT 3001');
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions