-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
BREAKING CHANGE: rename FilterQuery -> QueryFilter, add 1-level deep nested paths to QueryFilter #15592
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
base: 9.0
Are you sure you want to change the base?
Conversation
…nested paths to QueryFilter Fix #12064
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements a breaking change by renaming FilterQuery
to QueryFilter
to follow more idiomatic TypeScript naming conventions, and adds 1-level deep nested path support via WithLevel1NestedPaths
for improved autocomplete functionality. The changes also remove the deprecated RootFilterQuery
type.
- Renamed
FilterQuery
type toQueryFilter
throughout the codebase - Enhanced
WithLevel1NestedPaths
type utility to better handle document arrays and edge cases - Updated migration documentation to reflect the breaking changes
Reviewed Changes
Copilot reviewed 4 out of 9 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
test/types/sanitizeFilter.test.ts | Updates import and type expectation to use QueryFilter instead of FilterQuery |
test/types/queries.test.ts | Comprehensive update of all FilterQuery references to QueryFilter , adds nested path testing, and includes new test case for gh12064 |
test/types/models.test.ts | Updates WithLevel1NestedPaths type tests with improved type assertions and optional property handling |
docs/migrating_to_9.md | Updates migration documentation to reflect the FilterQuery to QueryFilter rename and related breaking changes |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good change, but something with generics in this PR causes infinite type loops for mongoose.Schema<any>
:
src/typegoose.ts:103:46 - error TS2589: Type instantiation is excessively deep and possibly infinite.
103 const compiledModel: mongoose.Model<any> = modelFn(name, buildSchema(cl, mergedOptions));
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/typegoose.ts:192:11 - error TS2589: Type instantiation is excessively deep and possibly infinite.
192 sch = _buildSchema(parentClass, sch!, mergedOptions, false, undefined, extraOptions);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/typegoose.ts:465:9 - error TS2589: Type instantiation is excessively deep and possibly infinite.
465 const sch: mongoose.Schema<any> = buildSchema(cl, mergedOptions);
~~~
src/typegoose.ts:493:9 - error TS2589: Type instantiation is excessively deep and possibly infinite.
493 const sch: mongoose.Schema<any> = {} as mongoose.Schema<DocumentType<InstanceType<U>>>;
Note that the error for line 493 is simply a repro try:
type AnyParamConstructorT<T> = new (...args: any) => T;
type DocumentTypeT<T> = mongoose.Document<unknown, {}, T> & mongoose.Default__v</* mongoose.Require_id<T> */ T>;
function test<U extends AnyParamConstructorT<U>>(cl: U) {
const sch: mongoose.Schema<any> = {} as mongoose.Schema<DocumentTypeT<InstanceType<U>>>;
console.log(sch);
}
(the error does not happen if mongoose.Default__v
or mongoose.Require_id
is not in the chain, if either is present, the error occurs)
@hasezoey can you please try again? With my fix in 9f40ebf, the following compiles
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works without any extra changes or errors with 9f40ebf in typegoose.
Fix #12064
Summary
Renamed FilterQuery -> QueryFilter to be more idiomatic, and also added
WithLevel1NestedPaths
to get us 1-level deep nested paths for better autocomplete. I needed to make some fixes toWithLevel1NestedPaths
to better handle document arrays and other edge cases.Also removed RootFilterQuery.
Examples