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

ts bug: toConstructor(): typeof Query<ResultType, DocType, THelpers, RawDocType>; #12688

Closed
2 tasks done
simllll opened this issue Nov 14, 2022 · 3 comments · Fixed by #12712
Closed
2 tasks done

ts bug: toConstructor(): typeof Query<ResultType, DocType, THelpers, RawDocType>; #12688

simllll opened this issue Nov 14, 2022 · 3 comments · Fixed by #12712
Labels
typescript Types or Types-test related issue / Pull Request
Milestone

Comments

@simllll
Copy link
Contributor

simllll commented Nov 14, 2022

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Mongoose version

6.7.2

Node.js version

16.x

MongoDB server version

5.x

Typescript version (if applicable)

4.8.4

Description

somehow this fails now suddenly:
../../node_modules/mongoose/types/query.d.ts(619,34): error TS1144: '{' or ';' expected.
../../node_modules/mongoose/types/query.d.ts(619,45): error TS1005: '>' expected.
../../node_modules/mongoose/types/query.d.ts(619,77): error TS1109: Expression expected.
../../node_modules/mongoose/types/query.d.ts(622,19): error TS1109: Expression expected.
../../node_modules/mongoose/types/query.d.ts(622,41): error TS1109: Expression expected.
../../node_modules/mongoose/types/query.d.ts(622,50): error TS1109: Expression expected.
../../node_modules/mongoose/types/query.d.ts(622,73): error TS1005: '(' expected.
../../node_modules/mongoose/types/query.d.ts(622,114): error TS1109: Expression expected.
../../node_modules/mongoose/types/query.d.ts(622,138): error TS1005: '(' expected.

the change was made already some weeks ago, but the line is definitly wrong:

toConstructor(): typeof Query<ResultType, DocType, THelpers, RawDocType>;

Query is already a Class and therefore typeof should just get removed.

image

change line 619 to
toConstructor(): Query<ResultType, DocType, THelpers, RawDocType>;

fixes it

Steps to Reproduce

just open the query.d.ts file in your favourite IDE :)

Expected Behavior

No response

@suits-at
Copy link

suits-at commented Nov 16, 2022

I also have the same problem, downgrading to 6.6.3 does help for me. I think it has to do with this commit: 86ca628. So reverting to 6.6.3 does change this line back to toConstructor(): typeof this; instead of deleting typeof

@IslandRhythms IslandRhythms added the typescript Types or Types-test related issue / Pull Request label Nov 16, 2022
@hasezoey
Copy link
Collaborator

Possibly a duplicate of #12529

though i still dont understand why this error occurs, because i cannot reproduce it in any project and from what i can tell, the syntax is correct


@simllll did you already confirm the following things (if yes, could you also provide them?):

  • tsc --version actually prints 4.8.4 (or higher)
  • re-install node_modules
  • look for yarn why mongoose / npm ls mongoose and see if the latest version is actually installed (and not duplicated)
  • (in case typescript is not correct): yarn why typescript / npm ls typescript

@simllll
Copy link
Contributor Author

simllll commented Nov 21, 2022

Hi @hasezoey, it's indeed strange...

i was looking into it again , and tested different typescript versions.

I need to go deeper why it's happening on our side, as we actually have tsc 4.8.4 everywhere, but my result shows that it only happens with tsc < 4.7.

tsc 4.6.4: $ npx tsc-files --noEmit types/query.d.ts FAILS
tsc 4.7.x: $ npx tsc-files --noEmit types/query.d.ts WORKS
tsc 4.8.x: $ npx tsc-files --noEmit types/query.d.ts WORKS
tsc 4.9.x: $ npx tsc-files --noEmit types/query.d.ts WORKS

vkarpov15 added a commit that referenced this issue Nov 23, 2022
fix(types): avoid typeof Query with generics for TypeScript 4.6 support
@vkarpov15 vkarpov15 added this to the 6.7.4 milestone Nov 23, 2022
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.

5 participants