Skip to content

Commit

Permalink
fix(types): extends check of generic in WithSdkStreamMixin (#4119)
Browse files Browse the repository at this point in the history
* fix(types): Fix issue with WithSdkStreamMixin

Fix an issue where WithSdkStreamMixin would apply to more properties than intended due to Distributive Conditional Types.

* fix(streams): apply mixin only to key match instead of type match

* fix(streams): update docs to indicate single key match instead of type match

Co-authored-by: George Fu <kuhe@users.noreply.github.com>
  • Loading branch information
Lewenhaupt and kuhe authored Oct 31, 2022
1 parent ea98484 commit 299d245
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/types/src/serde.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ export interface SdkStreamMixin {
export type SdkStream<BaseStream> = BaseStream & SdkStreamMixin;

/**
* Indicates that any members of type T
* that were of type T[StreamKey] have been extended
* Indicates that the member of type T with
* key StreamKey have been extended
* with the SdkStreamMixin helper methods.
*/
export type WithSdkStreamMixin<T, StreamKey extends keyof T> = {
[key in keyof T]: T[key] extends T[StreamKey] ? SdkStream<T[StreamKey]> : T[key];
[key in keyof T]: key extends StreamKey ? SdkStream<T[StreamKey]> : T[key];
};

/**
Expand Down

0 comments on commit 299d245

Please sign in to comment.