Skip to content

Commit 113e962

Browse files
committed
fix!: new laravel-echo typing system
1 parent c67d3a4 commit 113e962

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

src/runtime/composables/useEcho.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import type Echo from 'laravel-echo'
2+
import type { SupportedBroadcaster } from '../types'
23
import { useNuxtApp } from '#app'
34

4-
export const useEcho = (): Echo => {
5+
export const useEcho = (): Echo<SupportedBroadcaster> => {
56
const { $echo } = useNuxtApp()
67

7-
return $echo as Echo
8+
return $echo as Echo<SupportedBroadcaster>
89
}

src/runtime/plugin.client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import type { ChannelAuthorizationData } from 'pusher-js/types/src/core/auth/opt
44
import { type ConsolaInstance, createConsola } from 'consola'
55
import type { FetchOptions } from 'ofetch'
66
import { useEchoConfig } from './composables/useEchoConfig'
7-
import type { Authentication, ModuleOptions } from './types'
7+
import type { Authentication, ModuleOptions, SupportedBroadcaster } from './types'
88
import { createError, defineNuxtPlugin, useCookie } from '#app'
99

1010
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1111
const Pusher = (PusherPkg as any).default || PusherPkg
1212

1313
declare global {
1414
interface Window {
15-
Echo: Echo
15+
Echo: Echo<SupportedBroadcaster>
1616
Pusher: typeof Pusher
1717
}
1818
}

src/runtime/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
export type SupportedBroadcaster = 'reverb' | 'pusher'
2+
13
export interface Authentication {
24
/**
35
* The base URL of Laravel application.
@@ -36,7 +38,7 @@ export interface ModuleOptions {
3638
* The Laravel broadcaster type to use.
3739
* @default 'reverb'
3840
*/
39-
broadcaster: 'reverb' | 'pusher'
41+
broadcaster: SupportedBroadcaster
4042
/**
4143
* The host to connect to WebSocket.
4244
* @default 'localhost'

0 commit comments

Comments
 (0)