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

Types.Array type does not accept default property #11391

Closed
jansedlon opened this issue Feb 14, 2022 · 4 comments
Closed

Types.Array type does not accept default property #11391

jansedlon opened this issue Feb 14, 2022 · 4 comments
Labels
typescript Types or Types-test related issue / Pull Request
Milestone

Comments

@jansedlon
Copy link

jansedlon commented Feb 14, 2022

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

What is the current behavior?
When using Types.Array<Types.ObjectId>, I can't pass object configuration for that property with attribute default because it's of type never.

If the current behavior is a bug, please provide the steps to reproduce.

https://codesandbox.io/s/aged-dawn-biq34?file=/src/index.ts

TSConfig Included in CodeSandbox

What is the expected behavior?
To have correct TS typings.

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

@IslandRhythms IslandRhythms added the typescript Types or Types-test related issue / Pull Request label Feb 14, 2022
@Uzlopak
Copy link
Collaborator

Uzlopak commented Feb 17, 2022

You have to use Schema.Types.Array and not Types.Array

@jansedlon
Copy link
Author

@Uzlopak How exactly do you have in mind? Tried both ways and unfortunately, nothing worked.
image
image

@Uzlopak
Copy link
Collaborator

Uzlopak commented Feb 19, 2022

Usually you would not type it like you did:

interface User {
ids: Schema.Types.ObjectId[];
}

@vkarpov15 vkarpov15 added this to the 6.2.7 milestone Mar 2, 2022
@vkarpov15
Copy link
Collaborator

Fixed in 5a96692, fix will be in v6.2.7

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

No branches or pull requests

4 participants