laravel / echo

Laravel Echo library for beautiful Pusher and Ably integration.
https://laravel.com/docs/broadcasting#client-side-installation
MIT License
1.18k stars 182 forks source link

Property whisper does not exist on type Channel #401

Closed DGINXREAL closed 1 month ago

DGINXREAL commented 1 month ago

Echo Version

1.16.1

Laravel Version

N/A

PHP Version

N/A

NPM Version

10.5.1

Database Driver & Version

N/A

Description

I got an issue with Typescript that says that the whisper methode is not available on Channel

echo?.private('conversation.' + conversationIdFromRoute)
  .whisper('typing', { isTyping: true });

But the code works fine in dev mode.

Steps To Reproduce

See description

DGINXREAL commented 1 month ago
const echo = new Echo({
  broadcaster: 'reverb',
  key: import.meta.env.VITE_REVERB_APP_KEY,
  wsHost: import.meta.env.VITE_REVERB_HOST,
  wsPort: import.meta.env.VITE_REVERB_PORT,
  wssPort: import.meta.env.VITE_REVERB_PORT,
  forceTLS: (import.meta.env.VITE_REVERB_SCHEME ?? 'https') === 'https',
  enabledTransports: ['ws', 'wss'],
  auth: {
    headers: {
      Authorization: 'Bearer XXX',
      "Accept": "application/json",
      "Content-Type": "application/json",
    }
  },
  authorizer: (channel: any) => {
    return {
      authorize: (socketId: string , callback: Function) => {
        console.log('AAA')
        sr.post('https://' + import.meta.env.VITE_API_HOST + '/broadcasting/auth', {
          socket_id: socketId,
          channel_name: channel.name
        })
        .then(response => {
          callback(false, response.data);
        })
        .catch(error => {
          callback(true, error);
        });
      }
    };
  },
});
crynobone commented 1 month ago

Hi there,

whisper should already be added to interface via https://github.com/laravel/echo/pull/377. However, you are free to submit PR to improves this to cover above usage.