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

fix: make mongoose typings work without esmModuleInterop true #11695

Merged
merged 7 commits into from
Apr 27, 2022

Conversation

Uzlopak
Copy link
Collaborator

@Uzlopak Uzlopak commented Apr 20, 2022

Resolves #11664

@Uzlopak
Copy link
Collaborator Author

Uzlopak commented Apr 20, 2022

This was kind of messy Bug.

To get it work without esmModuleInterOp I had to move the imports into the namespace and do the default export in the namespace. Exporting a default forces you to explicitly export all types, interfaces,namespaces and classes in that specific namespace.

Moved NativeError and NativeDate out of the mongoose-namespace, as that was clearly wrong as we dont export such classes. Changed two "classes" (SchemaTypeOptions, MixedSchemaTypeOptions) to interfaces, as they can not be instantiated.

Fixed also validateSync typing and modified model.validate to properly handle pathsToValidate (normalized the behaviour).

@Uzlopak Uzlopak changed the title Fix mongoose typings interop fix: make mongoose typings work without esmModuleInterop true Apr 20, 2022
@vkarpov15
Copy link
Collaborator

At first glance looks good. I'll do some quick tests this PR over the next couple of days.

Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍

@vkarpov15 vkarpov15 added this to the 6.3.2 milestone Apr 27, 2022
@vkarpov15 vkarpov15 merged commit e03fa62 into Automattic:master Apr 27, 2022
@Uzlopak Uzlopak deleted the fix-mongoose-typings-interop branch April 29, 2022 07:07
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

Successfully merging this pull request may close these issues.

Typescript: default import does not work without esModuleInterop
2 participants