Skip to content

Commit f4f1d76

Browse files
committed
fix window types
1 parent 61bbfa6 commit f4f1d76

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

packages/laravel-echo/src/connector/connector.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/// <reference types="window" />
2+
13
import type { Channel, PresenceChannel } from "../channel";
24
import type { BroadcastDriver, EchoOptions } from "../echo";
35

@@ -90,11 +92,7 @@ export abstract class Connector<
9092
protected csrfToken(): null | string {
9193
let selector;
9294

93-
if (
94-
typeof window !== "undefined" &&
95-
typeof window.Laravel !== "undefined" &&
96-
window.Laravel.csrfToken
97-
) {
95+
if (window?.Laravel?.csrfToken) {
9896
return window.Laravel.csrfToken;
9997
}
10098

packages/laravel-echo/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"emitDecoratorMetadata": true,
1919
"esModuleInterop": true,
2020
"strict": true,
21-
"typeRoots": ["node_modules/@types"],
21+
"typeRoots": ["node_modules/@types", "./typings"],
2222
"lib": ["dom", "es2020"]
2323
},
2424
"include": ["./typings/**/*.ts", "./src/**/*.ts"],

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import type { io } from "socket.io-client";
21
import type Pusher from "pusher-js";
3-
4-
export {};
2+
import type { io } from "socket.io-client";
53

64
declare global {
75
interface Window {

0 commit comments

Comments
 (0)