-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(websockets): improve type safety for WebSocketGateway options #14305
base: master
Are you sure you want to change the base?
refactor(websockets): improve type safety for WebSocketGateway options #14305
Conversation
Pull Request Test Coverage Report for Build c9edbf1d-dcc3-4eba-8f47-e0946aebec59Details
💛 - Coveralls |
FYI this does introduces a breaking change as we'll narrow the type in a public API |
The type of WebSocketGateway options is |
@sapenlei this introduces a breaking change as you added |
export function WebSocketGateway< | ||
T extends Record<string, any> = GatewayMetadata, | ||
>(portOrOptions?: number | T, options?: T): ClassDecorator { | ||
export function WebSocketGateway<T extends GatewayMetadata>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can't do extends GatewayMetadata
here as GatewayMetadata
interface is specific to socket.io. What if someone uses ws
instead? (a different adapter)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should update the generic argument of this method then (as T is not always a subset of GatewayMetadata)
Closes #14303
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: #14303
What is the new behavior?
improve type safety for WebSocketGateway options
Does this PR introduce a breaking change?
Other information