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

Unable to declare type of "this" in function #564

Open
DieserMerlin opened this issue Sep 27, 2020 · 0 comments
Open

Unable to declare type of "this" in function #564

DieserMerlin opened this issue Sep 27, 2020 · 0 comments

Comments

@DieserMerlin
Copy link

Right now the style rules make it impossible to declare the type of "this" in a function.
When you do it like this:

function (this: UserDocument) {
}

it tells you to use an arrow function (Unexpected function expression.(prefer-arrow-callback)) that do not support to set "this".

I need this for mongoose virtuals where you can set virtual fields to the value returned by a callback function. You can access all document fields from "this" inside the function. In my use case, there is a virtual field named "makeJwt" which needs access to the jwtSecret stored in the UserDocument.

Is it intended to disallow this in functions in general?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants