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

SchemaDefinition does not yield correct type for string[] properties #10261

Closed
skrtheboss opened this issue May 18, 2021 · 0 comments
Closed
Labels
confirmed-bug We've confirmed this is a bug in Mongoose and will fix it. typescript Types or Types-test related issue / Pull Request
Milestone

Comments

@skrtheboss
Copy link
Contributor

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

Bug

What is the current behavior?
Assigning [String] to the type of a string[] property is not allowed.

import type { SchemaDefinition, DocumentDefinition } from 'mongoose';

interface ValuesEntity {
    values: string[];
}

const colorEntitySchemaDefinition: SchemaDefinition<DocumentDefinition<ValuesEntity>> = {
    values: {
        type: [String],
        required: true,
    } 
}

What is the expected behavior?

Assigning [String] to the type of a string[] property should be allowed.

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

node -v
v14.15.5
mongoose -v
v5.12.9
@IslandRhythms IslandRhythms added typescript Types or Types-test related issue / Pull Request confirmed-bug We've confirmed this is a bug in Mongoose and will fix it. labels May 18, 2021
@vkarpov15 vkarpov15 added this to the 5.12.11 milestone May 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug We've confirmed this is a bug in Mongoose and will fix it. typescript Types or Types-test related issue / Pull Request
Projects
None yet
Development

No branches or pull requests

3 participants