You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I want to use the Promise based API and found that in the connection.once method the compiler doesn't distinguish between the Callback based and the Promise based.
Hi,
Using ably js v 1.1.18
When I want to use the Promise based API and found that in the connection.once method the compiler doesn't distinguish between the Callback based and the Promise based.
const connectedPromise = this.ablyClient.connection.once('connected'); connectedPromise.then(x => console.log('Hey'));
The error is: Property 'then' does not exist on type 'void'
The workaround is to do add a casting to any:
const connectedPromise: any = this.ablyClient.connection.once('connected'); connectedPromise.then(x => console.log('Hey'));
Looking at ably.d.ts
once(eventOrCallback: EventType | CallbackType, callback?: CallbackType): void; once(event: EventType): Promise<ResultType>;
There's really no way to tell the difference between the two methods since the callback in the first one is optional.
The text was updated successfully, but these errors were encountered: