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

SchemaOptions TypeKey #1407

Open
3 of 4 tasks
Shikakka opened this issue Jun 30, 2022 · 0 comments
Open
3 of 4 tasks

SchemaOptions TypeKey #1407

Shikakka opened this issue Jun 30, 2022 · 0 comments
Labels

Comments

@Shikakka
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

When assigning the option typeKey to a Schema decorator it gives the following warning.

(property) SchemaOptions<"type", unknown, {}, {}, {}, {}>.typeKey?: "type" | undefined
By default, if you have an object with key 'type' in your schema, mongoose will interpret it as a type declaration. However, for applications like geoJSON, the 'type' property is important. If you want to control which key mongoose uses to find type declarations, set the 'typeKey' schema option.

Type '"$type"' is not assignable to type '"type"'.ts(2322)

Minimum reproduction code

https://gist.github.com/Shikakka/e3ceef24128d63b7b40368cd9ed7c518

Steps to reproduce

No response

Expected behavior

Apply the typeKey correctly, like the Mongoose package itself does. Using $type as the typeKey:

(alias) new MongooseSchema<any, Model<any, any, any, any, any>, {}, {}, any, {}, "$test", {
    type?: string | undefined;

Package version

9.1.1

mongoose version

6.4.1

NestJS version

8.4.7

Node.js version

16.15.1

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

It is a change done in the Mongoose package itself. Previously typeKey was typed as a string. In one of the later versions they changed it.
April 20th vs Change

@Shikakka Shikakka added the bug label Jun 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant