Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the key of this in Schema.path occur error with typecsrcipt #12590

Closed
vkarpov15 opened this issue Oct 24, 2022 Discussed in #12557 · 0 comments · Fixed by #12663
Closed

the key of this in Schema.path occur error with typecsrcipt #12590

vkarpov15 opened this issue Oct 24, 2022 Discussed in #12557 · 0 comments · Fixed by #12663
Labels
typescript Types or Types-test related issue / Pull Request
Milestone

Comments

@vkarpov15
Copy link
Collaborator

Discussed in #12557

Originally posted by huge689 October 14, 2022
code:

UserSchema.path('hashed_password').validate(function (v) {
  if (this._password && this._password.length < 8) {
    this.invalidate('password', 'Password must be at least 8 characters.');
  }
});

error:
any
'this' implicitly has type 'any' because it does not have a type annotation.ts(2683)
user.model.ts(57, 45): An outer value of 'this' is shadowed by this container.
'this' implicitly has type 'any' because it does not have a type annotation.ts(2683)
user.model.ts(57, 45): An outer value of 'this' is shadowed by this container.
'this' implicitly has type 'any' because it does not have a type annotation.ts(2683)

@vkarpov15 vkarpov15 added the typescript Types or Types-test related issue / Pull Request label Oct 24, 2022
@vkarpov15 vkarpov15 added this to the 6.6.9 milestone Oct 24, 2022
@vkarpov15 vkarpov15 modified the milestones: 6.7.3, 6.7.2 Nov 7, 2022
vkarpov15 added a commit that referenced this issue Nov 7, 2022
fix(types): set `this` to doc type in `SchemaType.prototype.validate()`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typescript Types or Types-test related issue / Pull Request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant