Skip to content

Commit c80ffbf

Browse files
authored
fix(node-ws): allow Hono with custom Env for createNodeWebSocket (#951)
* fix(node-ws): allow `Hono` with custom Env * add changeset
1 parent 5cad2e1 commit c80ffbf

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

.changeset/ninety-dogs-decide.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@hono/node-ws': patch
3+
---
4+
5+
fix: allow `Hono` with custom Env for `createNodeWebSocket`

packages/node-ws/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"dist"
1010
],
1111
"scripts": {
12-
"test": "vitest --run",
12+
"test": "tsc --noEmit && vitest --run",
1313
"build": "tsup ./src/index.ts --format esm,cjs --dts",
1414
"publint": "publint",
1515
"release": "yarn build && yarn test && yarn publint && yarn publish"
@@ -48,4 +48,4 @@
4848
"engines": {
4949
"node": ">=18.14.1"
5050
}
51-
}
51+
}

packages/node-ws/src/index.test.ts

+11
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,15 @@ describe('WebSocket helper', () => {
149149
expect((receivedMessage as Buffer).at(idx)).toBe(val)
150150
})
151151
})
152+
153+
describe('Types', () => {
154+
it('Should not throw a type error with an app with Variables generics', () => {
155+
const app = new Hono<{
156+
Variables: {
157+
foo: string
158+
}
159+
}>()
160+
createNodeWebSocket({ app })
161+
})
162+
})
152163
})

packages/node-ws/src/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export interface NodeWebSocket {
1212
injectWebSocket(server: Server | Http2Server | Http2SecureServer): void
1313
}
1414
export interface NodeWebSocketInit {
15-
app: Hono
15+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
16+
app: Hono<any, any, any>
1617
baseUrl?: string | URL
1718
}
1819

0 commit comments

Comments
 (0)