Skip to content

Commit

Permalink
fix(node-ws): allow Hono with custom Env for createNodeWebSocket (#…
Browse files Browse the repository at this point in the history
…951)

* fix(node-ws): allow `Hono` with custom Env

* add changeset
  • Loading branch information
yusukebe authored Feb 2, 2025
1 parent 5cad2e1 commit c80ffbf
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/ninety-dogs-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hono/node-ws': patch
---

fix: allow `Hono` with custom Env for `createNodeWebSocket`
4 changes: 2 additions & 2 deletions packages/node-ws/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dist"
],
"scripts": {
"test": "vitest --run",
"test": "tsc --noEmit && vitest --run",
"build": "tsup ./src/index.ts --format esm,cjs --dts",
"publint": "publint",
"release": "yarn build && yarn test && yarn publint && yarn publish"
Expand Down Expand Up @@ -48,4 +48,4 @@
"engines": {
"node": ">=18.14.1"
}
}
}
11 changes: 11 additions & 0 deletions packages/node-ws/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,15 @@ describe('WebSocket helper', () => {
expect((receivedMessage as Buffer).at(idx)).toBe(val)
})
})

describe('Types', () => {
it('Should not throw a type error with an app with Variables generics', () => {
const app = new Hono<{
Variables: {
foo: string
}
}>()
createNodeWebSocket({ app })
})
})
})
3 changes: 2 additions & 1 deletion packages/node-ws/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export interface NodeWebSocket {
injectWebSocket(server: Server | Http2Server | Http2SecureServer): void
}
export interface NodeWebSocketInit {
app: Hono
// eslint-disable-next-line @typescript-eslint/no-explicit-any
app: Hono<any, any, any>
baseUrl?: string | URL
}

Expand Down

0 comments on commit c80ffbf

Please sign in to comment.