• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

265
Vistas
NodeJS "No overload matches this call." error with typescript

I'm trying to create NodeJS app from scratch with typescript addition... I was following some tutorial and basically did the same steps as he did yet he didn't receive this error... Did NodeJS or TypeScript get some kind of updates that are causing this error?

Problem is that I'm receiving error on index.ts file POST with getAllUsers controller and I have no clue what is it about:

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

Any help is welcome :)

index.ts file:

import * as functions from "firebase-functions";
import * as express from "express";
import {getAllUsers } from "./controllers/usersController";

const app = express();
app.post("/users",getAllUsers);
app.get("/", (req, res) => res.status(200).send("default route!"));

exports.app = functions.https.onRequest(app);

Controller file:

const getAllUsers = async (req: Request, res: Response) => {
  let userArray: any[] = [];

  try {
    const user = await db.collection("userInfo").get();

    if (!user.docs) {
      res.status(404).send("not found");
    } else {
      user.docs.forEach((user) =>
        userArray.push({id: user.id, user: user.data()})
      );
    }
    res.status(200).send("<p>some html</p>");
  } catch (error) {
    res.status(500).send("error.message");
  }
};

export {getAllUsers};
about 3 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I got stuck for hours for this one. I hope this helped. Try changing the format of the code from
import {getAllUsers } from "./controllers/usersController"; & export {getAllUsers};

to import getAllUsers from "./controllers/usersController"; & export default getAllUsers;

Have the same problem with importing

After changing the code

about 3 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda