Skip to content

Commit

Permalink
fix some types (#437)
Browse files Browse the repository at this point in the history
* fix some types

* fix faye callback type
  • Loading branch information
Amin Mahboubi authored Mar 19, 2021
1 parent 3b92722 commit 77711bc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ export type RankedFeedOptions = {
session?: string;
};

export type GetFeedOptions = FeedPaginationOptions & EnrichOptions & RankedFeedOptions;

export type NotificationFeedOptions = {
mark_read?: boolean | 'current' | string[];
mark_seen?: boolean | 'current' | string[];
};

export type GetFeedOptions = FeedPaginationOptions & EnrichOptions & RankedFeedOptions & NotificationFeedOptions;

export type GetFollowOptions = {
filter?: string[];
limit?: number;
Expand Down Expand Up @@ -476,12 +476,12 @@ export class StreamFeed<
* @link https://getstream.io/activity-feeds/docs/node/adding_activities/?language=js#retrieving-activities
* @method get
* @memberof StreamFeed.prototype
* @param {GetFeedOptions & NotificationFeedOptions} options Additional options
* @param {GetFeedOptions} options Additional options
* @return {Promise<FeedAPIResponse>}
* @example feed.get({limit: 10, id_lte: 'activity-id'})
* @example feed.get({limit: 10, mark_seen: true})
*/
get(options: GetFeedOptions & NotificationFeedOptions = {}) {
get(options: GetFeedOptions = {}) {
const extraOptions: { mark_read?: boolean | string; mark_seen?: boolean | string } = {};

if (options.mark_read && (options.mark_read as string[]).join) {
Expand Down Expand Up @@ -548,7 +548,7 @@ export class StreamFeed<
* console.log('we are now listening to changes');
* });
*/
subscribe(callback: Faye.Callback<RealTimeMessage<UserType, ActivityType>>) {
subscribe(callback: Faye.SubscribeCallback<RealTimeMessage<UserType, ActivityType>>) {
if (!this.client.appId) {
throw new SiteError(
'Missing app id, which is needed to subscribe, use var client = stream.connect(key, secret, appId);',
Expand Down
6 changes: 3 additions & 3 deletions src/reaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export class StreamReaction<
add(
kind: string,
activity: string | { id: string },
data: ReactionType,
data?: ReactionType,
{ id, targetFeeds = [], userId, targetFeedsExtraData }: ReactionAddOptions = {},
) {
const body: ReactionBody<ReactionType> = {
Expand Down Expand Up @@ -188,7 +188,7 @@ export class StreamReaction<
addChild(
kind: string,
reaction: string | { id: string },
data: ChildReactionType,
data?: ChildReactionType,
{ targetFeeds = [], userId, targetFeedsExtraData }: ReactionAddChildOptions = {},
) {
const body: ReactionBody<ChildReactionType> = {
Expand Down Expand Up @@ -279,7 +279,7 @@ export class StreamReaction<
*/
update(
id: string,
data: ReactionType | ChildReactionType,
data?: ReactionType | ChildReactionType,
{ targetFeeds = [], targetFeedsExtraData }: ReactionUpdateOptions = {},
) {
const body: ReactionBody<ReactionType | ChildReactionType> = {
Expand Down
4 changes: 2 additions & 2 deletions types/modules.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ declare module 'faye' {
};

type Callback<T extends UR = UR> = (message: Message<T>) => unknown;
type SubscribeCallback<T extends UR = UR> = (data: T) => unknown;

type Middleware<T extends UR = UR> = {
incoming: (message: Message<T>, callback: Callback<T>) => unknown;
Expand All @@ -23,8 +24,7 @@ declare module 'faye' {
export class Client<T extends UR = UR> {
constructor(url: string, options: { timeout: number });
addExtension(extension: Middleware<T>): void;
subscribe(channel: string, callback: Callback<T>): Promise<Subscription>;

subscribe(channel: string, callback: SubscribeCallback<T>): Promise<Subscription>;
disconnect(): void;
}
}

0 comments on commit 77711bc

Please sign in to comment.