Skip to content

Commit a4311c0

Browse files
lifefloatingclaude
andcommitted
fix(ws): use local type alias to avoid path-to-regexp type leak in d.ts
Avoid leaking `import { Key } from 'path-to-regexp'` into the emitted ws-adapter.d.ts, which causes sample builds to fail when path-to-regexp is not installed. Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent 5055e14 commit a4311c0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/platform-ws/adapters/ws-adapter.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ import {
99
} from '@nestjs/websockets/constants';
1010
import { MessageMappingProperties } from '@nestjs/websockets/gateway-metadata-explorer';
1111
import * as http from 'http';
12-
import { pathToRegexp, Key } from 'path-to-regexp';
12+
import { pathToRegexp } from 'path-to-regexp';
1313
import { EMPTY, fromEvent, Observable } from 'rxjs';
1414
import { filter, first, mergeMap, share, takeUntil } from 'rxjs/operators';
1515

16+
type PathKey = { name: string };
17+
1618
let wsPackage: any = {};
1719

1820
enum READY_STATE {
@@ -38,7 +40,7 @@ type WsAdapterOptions = {
3840
interface WsServerWithPath {
3941
path: string;
4042
pathRegexp?: RegExp;
41-
pathKeys?: Key[];
43+
pathKeys?: PathKey[];
4244
isStaticPath?: boolean;
4345
handleUpgrade: (
4446
request: any,
@@ -65,7 +67,7 @@ interface PathMatcher {
6567
dynamicPaths: Array<{
6668
server: WsServerWithPath;
6769
pathRegexp: RegExp;
68-
pathKeys: Key[];
70+
pathKeys: PathKey[];
6971
}>;
7072
}
7173

0 commit comments

Comments
 (0)