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

This line broke typings in a project I help maintain: #12375

Closed
Uzlopak opened this issue Sep 1, 2022 · 1 comment · Fixed by #12488
Closed

This line broke typings in a project I help maintain: #12375

Uzlopak opened this issue Sep 1, 2022 · 1 comment · Fixed by #12488
Labels
typescript Types or Types-test related issue / Pull Request
Milestone

Comments

@Uzlopak
Copy link
Collaborator

Uzlopak commented Sep 1, 2022

This line broke typings in a project I help maintain:

toConstructor(): typeof this;

That project uses typescript 4.1.3, which is quite dated. When dependabot bumped mongoose from 6.2.0 to 6.5.4, CI broke with this error:

node_modules/mongoose/types/query.d.ts:619:29 - error TS2304: Cannot find name 'this'.

619     toConstructor(): typeof this;
                                ~~~~


Found 1 error.

error Command failed with exit code 2

I tried bumping typescript, but it was not very successful. Versions below 4.4 showed the same error and v4.4+ generated a lot of other errors, unrelated to the library. Most of them were to do with error becoming unknown instead of any in catch.

Not sure if this is actionable, but flagging the problem just in case.

Originally posted by @kachkaev in #12284 (comment)

@hasezoey hasezoey added the typescript Types or Types-test related issue / Pull Request label Sep 2, 2022
@vkarpov15 vkarpov15 added this to the 6.6.3 milestone Sep 26, 2022
vkarpov15 added a commit that referenced this issue Sep 30, 2022
@vkarpov15 vkarpov15 modified the milestones: 6.6.3, 6.6.4 Sep 30, 2022
vkarpov15 added a commit that referenced this issue Oct 3, 2022
fix(types): avoid relying on `typeof this`, which isn't supported in TypeScript < 4.4
@huangapple
Copy link

I have the same problem, mongoose version 6.6.4, typescript 4.6.0.

If “typeof” is removed, it can be compiled through

image

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
4 participants