Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

225
Views
Pregunta de TS newb: error de compilación al iniciar Apollo Server tratando de resolver la promesa

Con suerte, alguien puede ayudar con esto: estoy tratando de iniciar el servidor apollo en un proyecto de TypeScript que ejecuta Express. Mi app.ts está debajo. Estoy teniendo el siguiente error:

 Argument of type '(value: unknown) => void' is not assignable to parameter of type '() => void'.ts(2769)

Creo que esto tiene algo que ver con la resolución de la última promesa de iniciar el servidor. ¡Gracias por responder a esta pregunta presumiblemente muy básica!

 import express from 'express'; import { ApolloServer } from 'apollo-server-express'; import depthLimit from 'graphql-depth-limit'; import compression from 'compression'; import cors from 'cors'; import schema from './schema'; const corsConfig = { origin: '*', credentials: true }; async function startApolloServer() { const server = new ApolloServer({ schema, validationRules: [depthLimit(7)] }); await server.start(); const app = express(); app.use(cors(corsConfig)); app.use(compression()); server.applyMiddleware({ app }); await new Promise(resolve => app.listen({ port: 4000 }, resolve)); console.log(`🚀 Server ready at http://localhost:4000${server.graphqlPath}`); }
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Intente lo siguiente para que coincida con la firma de devolución de llamada esperada:

 async function startApolloServer() { const server = new ApolloServer({ schema, validationRules: [depthLimit(7)] }); await server.start(); const app = express(); app.use(cors(corsConfig)); app.use(compression()); server.applyMiddleware({ app }); await new Promise(resolve => app.listen({ port: 4000 }, (value) => resolve(value))); console.log(`🚀 Server ready at http://localhost:4000${server.graphqlPath}`); }

¡Espero que eso ayude!

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!