Skip to content

Commit 08f5fd1

Browse files
authored
yarn 2 needs additional installation configuration (#307)
Without this, the types do not work and you get errors like: ``` error TS2353: Object literal may only specify known properties, and 'websocket' does not exist in type 'RouteShorthandOptions<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGenericInterface, unknown, FastifySchema, FastifyTypeProvider, FastifyBaseLogger>'. ``` Signed-off-by: Zachary Salzbank <zsalzbank@gmail.com>
1 parent 389ca8d commit 08f5fd1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ npm i @types/ws -D
2323
yarn add -D @types/ws
2424
```
2525

26+
If you use TypeScript and Yarn 2, you'll need to add a `packageExtension` to your `.yarnrc.yml` file:
27+
28+
```yaml
29+
packageExtensions:
30+
"@fastify/websocket@*":
31+
peerDependencies:
32+
fastify: "*"
33+
```
34+
2635
## Usage
2736
2837
After registering this plugin, you can choose on which routes the WS server will respond. This can be achieved by adding `websocket: true` property to `routeOptions` on a fastify's `.get` route. In this case two arguments will be passed to the handler, the socket connection, and the `fastify` request object:

0 commit comments

Comments
 (0)