Skip to content

Commit f430ca5

Browse files
committed
types(query+model): use function overrides instead of | Query<any, any> to support using Query as filter
Fix #15779
1 parent ca36b12 commit f430ca5

File tree

3 files changed

+383
-1
lines changed

3 files changed

+383
-1
lines changed

test/types/queries.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,3 +826,20 @@ function gh15671() {
826826
};
827827
};
828828
}
829+
830+
async function gh15779() {
831+
type Entity = {
832+
id: string;
833+
age: number;
834+
name: string;
835+
};
836+
837+
function getV8FilterQuery(filter: QueryFilter<Entity>): QueryFilter<Entity> {
838+
return { ...filter, deletedAt: null };
839+
}
840+
841+
const v8Filter = getV8FilterQuery({ age: { $gt: 18 } });
842+
843+
expectAssignable<typeof v8Filter.age>(42);
844+
expectNotAssignable<typeof v8Filter.age>('taco');
845+
}

0 commit comments

Comments
 (0)