question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typescript: listen property does not exist on type 'Presence Channel'

See original GitHub issue

I use laravel echo with Typescript and I have a problem on listen property, I receive a

TS2339: Property ‘listen’ does not exist on type ‘PresenceChannel’.

In this segment of code:

    echo.join(channel)
            .here((users) => {
                EventBusMain.$emit(EVENTS.HERE_MAIN_CHANNEL_EVENT, {users});
            })
            .joining((user) => {
                EventBusMain.$emit(EVENTS.JOIN_MAIN_CHANNEL_EVENT, {user});
            })
            .leaving((user) => {
                EventBusMain.$emit(EVENTS.LEAVE_MAIN_CHANNEL_EVENT, {user});
            })
            .listen('.event', (e) => {
                EventBusMain.$emit(e.event, e.data)
            });

The version of laravel echo I’m using is 1.5.4

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:19 (7 by maintainers)

github_iconTop GitHub Comments

7reactions
mengyang1229commented, Nov 6, 2019

@willypuzzle @driesvints @Mathem8tic @ellisio @JeffreyWay

I found a solution that worked for me and hope it can help you.

import { NullPresenceChannel } from 'laravel-echo/src/channel'

const LaravelEchoChannel = echo.join(channel)
    .here((users) => {
        EventBusMain.$emit(EVENTS.HERE_MAIN_CHANNEL_EVENT, {users});
    })
    .joining((user) => {
        EventBusMain.$emit(EVENTS.JOIN_MAIN_CHANNEL_EVENT, {user});
    })
    .leaving((user) => {
        EventBusMain.$emit(EVENTS.LEAVE_MAIN_CHANNEL_EVENT, {user});
    }) as NullPresenceChannel;

LaravelEchoChannel
    .listen('.event', (e) => {
        EventBusMain.$emit(e.event, e.data)
    });

2reactions
driesvintscommented, Apr 20, 2020

I’m going to close this because I feel that there isn’t much progress here to make anymore. All the types seem to be defined properly on all channel classes so I wouldn’t know how this problem could exist. The solution from https://github.com/laravel/echo/pull/241 also doesn’t seems to be wanted because we don’t want the listen method to be defined on the presence channels interface.

Anyone’s free to send in a PR and explain in detail why it would be needed, thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular - How to fix 'property does not exist on type' error?
It usually happens when you develop Angular applications. To solve this just shut down the server & start it again: $ ng serve....
Read more >
Release Notes | Supabase
RealtimeSubscription class no longer exists and replaced by RealtimeChannel . RealtimeClient 's disconnect method now returns type of void . It used to...
Read more >
Broadcasting - Laravel - The PHP Framework For Web Artisans
Laravel Echo is a JavaScript library that makes it painless to subscribe to channels and listen for events broadcast by your server-side broadcasting...
Read more >
Node.js v19.3.0 Documentation
If the values do not match, or if the string argument is of another type than string , an AssertionError is thrown with...
Read more >
Notifications - Expo Documentation
The plugin allows you to configure various properties that cannot be set ... This prompt will not appear until at least one notification...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found