Skip to content

Commit

Permalink
🚧 progress: Fix type issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
make-github-pseudonymous-again committed Jun 5, 2024
1 parent e979365 commit cd30d0f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
19 changes: 9 additions & 10 deletions imports/api/makeObservedQueryPublication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,23 @@ const makeObservedQueryPublication = <T extends Document, U = T>(
const diffOptions = callbacks.changed
? undefined
: {
projectionFn: ({_id}) => _id,
// @ts-expect-error TODO
projectionFn: ({_id}: T): Partial<T> => ({_id}),
};

const observer: ObserveChangesCallbacks<T> = Object.fromEntries(
[
callbacks.addedBefore && ['addedBefore', stop],
callbacks.movedBefore && ['movedBefore', stop],
callbacks.removed && ['removed', stop],
callbacks.changed && ['changed', stop],
].filter(Boolean),
);
const observer: ObserveChangesCallbacks<T> = {};

if (callbacks.addedBefore) observer.addedBefore = stop;
if (callbacks.movedBefore) observer.movedBefore = stop;
if (callbacks.removed) observer.removed = stop;
if (callbacks.changed) observer.changed = stop;

const handle = await watch<T, U>(
QueriedCollection,
selector as Filter<T>,
options,
async (init) => {
DiffSequence.diffQueryOrderedChanges(
DiffSequence.diffQueryOrderedChanges<T>(
handle.init,
init,
observer,
Expand Down
4 changes: 2 additions & 2 deletions types/meteor/diff-sequence.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ declare module 'meteor/diff-sequence' {

namespace DiffSequence {
function diffQueryOrderedChanges<T extends Document>(
old_results: T,
new_results: T,
old_results: T[],
new_results: T[],
observer: Mongo.ObserveChangesCallbacks<T>,
options?: Options<T> | undefined,
): void;
Expand Down

0 comments on commit cd30d0f

Please sign in to comment.