mongoose icon indicating copy to clipboard operation
mongoose copied to clipboard

Add types for browser

Open vixalien opened this issue 3 years ago • 4 comments

Do you want to request a feature or report a bug?

I want to request a feature.

What is the current behavior?

I want to start using the Mongoose browser script from non-Node environments (Deno in this case) mainly for the robust Schema API (Validations) but I won't get types because there are no types for the browser script.

What is the expected behavior?

It would be nice if there were types for browser and amazing if there were types for schema only.

What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.

NodeJS: no Deno: 1.21.0 MongoDB: 5.0.7 Mongoose: 6.3.2

vixalien avatar May 07 '22 09:05 vixalien

tbh, I didnt know that there are special typings for browser environments. Do you have some more information about that?

Btw. I tested few weeks ago mongoose in deno and it seems that esm support works properly now. So probably you dont need the browser version of mongoose but can use the node version of it. Or is it because of dependencies?

Would be cool if you could point out the issues with using deno, then we could adapt mongoose properly for deno.

Uzlopak avatar May 07 '22 09:05 Uzlopak

What do you mean mongoose in Deno? How did you get that to work??? I think it's impossible unless you poly-patch all the Node dependencies (stream, buffer, crypto etc).

I don't think there are special typings for browser environments, but the typings for mongoose are all currently node-dependant and so would NOT work on a browser environment (read: non-node environment).

Mongoose can't work on Deno, atleast as of now, all I needed is the types for the schema. I was trying to create a PR but it's way too complex (for me atleast).

vixalien avatar May 07 '22 09:05 vixalien

Ok, I guess without patching those it is not possible.But mongoose seem to load in deno

https://github.com/Automattic/mongoose/issues/9056#issuecomment-1104533278

Uzlopak avatar May 08 '22 15:05 Uzlopak

oh okay

vixalien avatar May 08 '22 16:05 vixalien

This will be fixed with #15385 in Mongoose 9: you'll get the full Mongoose global in the browser, so same types.

vkarpov15 avatar Jul 03 '25 19:07 vkarpov15