Skip to content

Commit 8fdbbbe

Browse files
committed
type fixes and note to eventually remove vue-resource
1 parent 2cdc569 commit 8fdbbbe

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

packages/laravel-echo/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@
5050
"typescript": "^5.7.0",
5151
"vite": "^5.0.0",
5252
"vite-plugin-dts": "^3.0.0",
53-
"vitest": "^3.1.2",
54-
"vue": "^3.5.13"
53+
"vitest": "^3.1.2"
5554
},
5655
"peerDependencies": {
5756
"pusher-js": "*",

packages/laravel-echo/src/echo.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { InternalAxiosRequestConfig } from "axios";
12
import {
23
Channel,
34
NullChannel,
@@ -179,7 +180,9 @@ export default class Echo<T extends keyof Broadcaster> {
179180
* send a connections socket id to a Laravel app with a X-Socket-Id header.
180181
*/
181182
registerInterceptors(): void {
182-
if (typeof Vue === "function" && Vue.http) {
183+
// TODO: This package is deprecated and we should remove it in a future version.
184+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
185+
if (Vue?.http) {
183186
this.registerVueRequestInterceptor();
184187
}
185188

@@ -200,12 +203,15 @@ export default class Echo<T extends keyof Broadcaster> {
200203
* Register a Vue HTTP interceptor to add the X-Socket-ID header.
201204
*/
202205
registerVueRequestInterceptor(): void {
206+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
203207
Vue.http.interceptors.push(
204208
(request: Record<any, any>, next: CallableFunction) => {
205209
if (this.socketId()) {
210+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
206211
request.headers.set("X-Socket-ID", this.socketId());
207212
}
208213

214+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
209215
next();
210216
},
211217
);
@@ -215,13 +221,15 @@ export default class Echo<T extends keyof Broadcaster> {
215221
* Register an Axios HTTP interceptor to add the X-Socket-ID header.
216222
*/
217223
registerAxiosRequestInterceptor(): void {
218-
axios.interceptors.request.use((config: Record<any, any>) => {
219-
if (this.socketId()) {
220-
config.headers["X-Socket-Id"] = this.socketId();
221-
}
224+
axios!.interceptors.request.use(
225+
(config: InternalAxiosRequestConfig<any>) => {
226+
if (this.socketId()) {
227+
config.headers["X-Socket-Id"] = this.socketId();
228+
}
222229

223-
return config;
224-
});
230+
return config;
231+
},
232+
);
225233
}
226234

227235
/**

packages/laravel-echo/typings/window.d.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import type { JQueryStatic } from "@types/jquery";
21
import type { AxiosStatic } from "axios";
2+
import type { JQueryStatic } from "jquery";
33
import type Pusher from "pusher-js";
44
import type { io } from "socket.io-client";
5-
import type { VueElementConstructor } from "vue";
65

76
declare global {
87
interface Window {
@@ -13,13 +12,13 @@ declare global {
1312
io?: typeof io;
1413
Pusher?: typeof Pusher;
1514

16-
Vue?: VueElementConstructor;
15+
Vue?: any;
1716
axios?: AxiosStatic;
1817
jQuery?: JQueryStatic;
1918
Turbo?: object;
2019
}
2120

22-
const Vue: VueElementConstructor | undefined;
21+
const Vue: any | undefined;
2322
const axios: AxiosStatic | undefined;
2423
const jQuery: JQueryStatic | undefined;
2524
const Turbo: object | undefined;

pnpm-lock.yaml

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)