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

Mongoose 6.1.5 typescript build fail #11180

Closed
imranbarbhuiya opened this issue Jan 5, 2022 · 12 comments
Closed

Mongoose 6.1.5 typescript build fail #11180

imranbarbhuiya opened this issue Jan 5, 2022 · 12 comments
Milestone

Comments

@imranbarbhuiya
Copy link

Do you want to request a feature or report a bug?
Bug
What is the current behavior?
My build is failing after updating mongoose to 6.1.5 but it was working fine in 6.1.4
If the current behavior is a bug, please provide the steps to reproduce.

https://github.com/Codversity/Codversity/runs/4710880686?check_suite_focus=true

Here's the github action

https://github.com/Codversity/Codversity/blob/main/tsconfig.json

https://github.com/Codversity/Codversity/blob/main/tsconfig.server.json
What is the expected behavior?
It shouldn't break as it's a patch update.
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Node v16
Mongoose v6.1.5

@wejd
Copy link

wejd commented Jan 5, 2022

@imranbarbhuiya if you are using the latest version of @types/node try to downgrade to the v17.0.5, i had the same issue and this solution solves my problem

@imranbarbhuiya
Copy link
Author

imranbarbhuiya commented Jan 5, 2022

@imranbarbhuiya if you are using the latest version of @types/node try to downgrade to the v17.0.5, i had the same issue and this solution solves my problem

I'm on "@types/node": "^17.0.5". U can check.

https://github.com/Codversity/Codversity/blob/b2d594322cb5c849f2bbd50eb0bbc6c7601b1f9c/package.json#L76

Edit: My bad, I'm on "@types/node": "^17.0.7" in the branch where build failed.

@IslandRhythms
Copy link
Collaborator

@imranbarbhuiya so did that fix your issue? Was it being on a broken build that caused the problem?

@imranbarbhuiya
Copy link
Author

imranbarbhuiya commented Jan 5, 2022

@imranbarbhuiya so did that fix your issue? Was it being on a broken build that caused the problem?

In my case, it's still failing in @types/node v17.0.5 also

node v16 test
https://github.com/Codversity/Codversity/runs/4717302087?check_suite_focus=true

node v17 test
https://github.com/Codversity/Codversity/runs/4717302162?check_suite_focus=true

both are failing

@wejd
Copy link

wejd commented Jan 5, 2022

@imranbarbhuiya so did that fix your issue? Was it being on a broken build that caused the problem?

In my case, it's still failing in @types/node v17.0.5 also

node v16 test https://github.com/Codversity/Codversity/runs/4717302087?check_suite_focus=true

node v17 test https://github.com/Codversity/Codversity/runs/4717302162?check_suite_focus=true

both are failing

I checked your code and you did not fix the version of types/node you should delete the ^ before the version number

@imranbarbhuiya
Copy link
Author

@imranbarbhuiya so did that fix your issue? Was it being on a broken build that caused the problem?

In my case, it's still failing in @types/node v17.0.5 also
node v16 test https://github.com/Codversity/Codversity/runs/4717302087?check_suite_focus=true
node v17 test https://github.com/Codversity/Codversity/runs/4717302162?check_suite_focus=true
both are failing

I checked your code and you did not fix the version of types/node you should delete the ^ before the version number

I've changed it
https://github.com/Codversity/Codversity/blob/263a1a0f119f8b1fce3e889b783f8b79932c1521/package.json#L76

But still the build is failing
https://github.com/Codversity/Codversity/runs/4717494014?check_suite_focus=true

@AndrewBarba
Copy link

Also failing for me on v6.1.5 but the issue is in the mongodb package:

node_modules/mongodb/mongodb.d.ts:3311:5 - error TS2416: Property 'end' in type 'GridFSBucketWriteStream' is not assignable to the same property in base type 'WritableStream'.
  Type '{ (): void; (chunk: Buffer): void; (callback: Callback<void | GridFSFile>): void; (chunk: Buffer, callback: Callback<void | GridFSFile>): void; (chunk: Buffer, encoding: BufferEncoding): void; (chunk: Buffer, encoding: BufferEncoding | undefined, callback: Callback<...>): void; }' is not assignable to type '{ (cb?: (() => void) | undefined): this; (data: string | Uint8Array, cb?: (() => void) | undefined): this; (str: string, encoding?: BufferEncoding | undefined, cb?: (() => void) | undefined): this; }'.

--> end(callback: Callback<GridFSFile | void>): void;

@imranbarbhuiya
Copy link
Author

imranbarbhuiya commented Jan 6, 2022

@AndrewBarba R U sure this error is related to this issue?

Also, for me, it was working in v6.1.5 even in @types/node v17.0.8

@wejd
Copy link

wejd commented Jan 6, 2022

Also failing for me on v6.1.5 but the issue is in the mongodb package:

node_modules/mongodb/mongodb.d.ts:3311:5 - error TS2416: Property 'end' in type 'GridFSBucketWriteStream' is not assignable to the same property in base type 'WritableStream'.
  Type '{ (): void; (chunk: Buffer): void; (callback: Callback<void | GridFSFile>): void; (chunk: Buffer, callback: Callback<void | GridFSFile>): void; (chunk: Buffer, encoding: BufferEncoding): void; (chunk: Buffer, encoding: BufferEncoding | undefined, callback: Callback<...>): void; }' is not assignable to type '{ (cb?: (() => void) | undefined): this; (data: string | Uint8Array, cb?: (() => void) | undefined): this; (str: string, encoding?: BufferEncoding | undefined, cb?: (() => void) | undefined): this; }'.

--> end(callback: Callback<GridFSFile | void>): void;

I had the same issue, when i use @types/node v17.0.5 the problem seems to be solved . ( PS: i am on node 14.18, typescript: 4.4.4 )

here after an issue opened on @types/node yesterday relating the same issue:
DefinitelyTyped/DefinitelyTyped#57994

@AndrewBarba
Copy link

AndrewBarba commented Jan 6, 2022

@wejd I'm also on Node 14.18 and thus I use "@types/node": "^14.18.0" yet I still have this issue. If you're running on Node 14 why would you install types for Node 17? You could end up using an API in 17 that's not available to your runtime.

@imranbarbhuiya
Copy link
Author

imranbarbhuiya commented Jan 6, 2022

Mongoose 6.1.4 works in @types/node v17.0.8 and its not working in Mongoose 6.1.5 so I'm pretty sure the error is present in Mongoose and not @types/node.

@vkarpov15 vkarpov15 added this to the 6.1.6 milestone Jan 7, 2022
@vkarpov15
Copy link
Collaborator

@imranbarbhuiya your build is now failing for a different reason:

./server/model/blogModel.ts:92:12
Type error: Property 'title' does not exist on type 'Document<any, any, any>'.

  90 | 
  91 | blogSchema.pre("validate", function (next) {
> 92 |   if (this.title && !this.slug) {
     |            ^
  93 |     this.slug = slugify(this.title, { lower: true, strict: true });
  94 |   } else if (this.slug) {
  95 |     this.slug = slugify(this.slug, { lower: true, strict: true });

It looks like this isn't tied to @types/node after all, sorry for the confusion. The easiest workaround is to pass the context to pre:

blogSchema.pre<Blog>('validate', function(next) { ... })

We'll take a look and see if we can work around this without causing significant perf overhead. I suspect the issue here is 1141ec4 .

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

No branches or pull requests

5 participants