Skip to content

Commit 85f7c11

Browse files
authored
Fix TypeScript Error in isConstructor (#412)
* Fix TS error node_modules/laravel-echo/src/util/index.ts:5:13 - error TS18046: 'err' is of type 'unknown'. * Refactor to not use Reflect.construct to reduce chance on breaking change * Update index.ts
1 parent 09c9350 commit 85f7c11

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/util/index.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
function isConstructor(obj: any): obj is new (...args: any[]) => any {
1+
function isConstructor(obj: unknown): obj is new (...args: any[]) => any {
22
try {
3-
new obj();
3+
new (obj as new (...args: any[]) => any)();
44
} catch (err) {
5-
if (err.message.includes('is not a constructor')) return false;
5+
if (err instanceof Error && err.message.includes('is not a constructor')) {
6+
return false;
7+
}
68
}
9+
710
return true;
811
}
912

0 commit comments

Comments
 (0)