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

7.3 #13499

Merged
merged 38 commits into from Jun 14, 2023
Merged

7.3 #13499

merged 38 commits into from Jun 14, 2023

Conversation

vkarpov15
Copy link
Collaborator

Summary

Examples

vkarpov15 and others added 21 commits May 25, 2023 11:14
Co-authored-by: hasezoey <hasezoey@gmail.com>
Co-authored-by: hasezoey <hasezoey@gmail.com>
Co-authored-by: hasezoey <hasezoey@gmail.com>
feat(schema): consistently add `.get()` function to all SchemaType classes
types: allow overwriting `Paths` in `select()` to tell TypeScript which fields are projected
feat(populate): pass virtual to `match` function to allow merging match options
Copy link
Collaborator

@hasezoey hasezoey left a comment

Choose a reason for hiding this comment

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

Aside from the one types issue, these changes seems to be work just fine with current latest typegoose (both tsc build and runtime & types tests)

types/query.d.ts Outdated
Comment on lines 625 to 633
select<Paths extends { [P in keyof ResultType]?: any } = {}>(
arg: string | string[] | Record<string, number | boolean | object>
): QueryWithHelpers<
UnpackedIntersection<{}, Paths>,
DocType,
THelpers,
UnpackedIntersection<{}, Paths>,
QueryOp
>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

this does not seem to give the proper type when testing against typegoose 11.2.0 (current latest for mongoose 7.2.3)

error:

test/tests/indexes.test.ts:25:108 - error TS2339: Property 'toObject' does not exist on type '{}'.

25     const fSExtra = (await SelectModel.findOne({}).select(['+test1', '+test3', '-test2']).orFail().exec()).toObject();
                                                                                                              ~~~~~~~~

code:

const fSExtra = (await SelectModel.findOne({}).select(['+test1', '+test3', '-test2']).orFail().exec()).toObject();

hovering over .exec() says it returns a Promise<{}>, meaning not a document

likely because generic ResultType (first generic) in QueryWithHelpers is because it operates on {}

changing to the following return fixes the error, though i dont know if they are the proper intended types (similar to what .populate returns):

QueryWithHelpers<
      UnpackedIntersection<ResultType, Paths>,
      DocType,
      THelpers,
      UnpackedIntersection<RawDocType, Paths>,
      QueryOp
    >;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@hasezoey I think I fixed this in 30e7833, can you please try against the latest commit on this branch?

Copy link
Collaborator

@hasezoey hasezoey left a comment

Choose a reason for hiding this comment

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

current version of e8987d0 runs file (both in types and runtime) in typegoose

IslandRhythms and others added 4 commits June 14, 2023 11:03
feat(aggregate): add `Aggregate.prototype.finally()` to be consistent with Promise API for TypeScript
…ncurrency-array

Island rhythms/optimistic concurrency array
@vkarpov15 vkarpov15 merged commit 3742d8f into master Jun 14, 2023
38 checks passed
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.

None yet

4 participants