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

530
Views
Un valor externo de 'esto' está sombreado por este contenedor con Mongoose Schema Typescript

Tengo lo siguiente para un validador de esquema para MongoDB:{

 UserSchema.path('email').validate(async function (email: string) { const count = await User.count({ email, _id: { $ne: this._id } }) return !count }, 'Email already exists')

Recibo el siguiente error:

 'this' implicitly has type 'any' because it does not have a type annotation.ts(2683) User.ts(171, 35): An outer value of 'this' is shadowed by this container.

Esto se define en mi archivo User.ts Todo funciona exactamente como se esperaba, pero este error de mecanografiado impide que CI continúe. ¿Hay alguna forma de evitar esto (sin juego de palabras)?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Tratar:

 UserSchema.path('email').validate(async function (this:any, email: string) { const count = await User.count({ email, _id: { $ne: this._id } }) return !count }, 'Email already exists')

Puede usar su tipo en lugar de "cualquiera".

Y el enlace al documento: https://www.typescriptlang.org/docs/handbook/functions.html#this-parameters

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!