-
Notifications
You must be signed in to change notification settings - Fork 907
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Retrict the type of subscription iterables to
AsyncIterable
(#3131)
# Summary We want to return `Iterables` from here; it's not important that a generator itself is iterable.
- Loading branch information
1 parent
04942c9
commit 75710e7
Showing
2 changed files
with
26 additions
and
3 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
.../rpc-subscriptions-transport-websocket/src/__typetests__/websocket-connection-typetest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { RpcWebSocketConnection } from '../websocket-connection'; | ||
|
||
const connection = null as unknown as RpcWebSocketConnection; | ||
|
||
// [DESCRIBE] RpcWebSocketConnection | ||
{ | ||
// It is an `AsyncIterable` | ||
{ | ||
connection satisfies AsyncIterable<unknown>; | ||
} | ||
|
||
// It produces an `AsyncIterator` | ||
{ | ||
connection[Symbol.asyncIterator]() satisfies AsyncIterator<unknown>; | ||
} | ||
|
||
// Is not an `AsyncIterableIterator` | ||
{ | ||
// @ts-expect-error Should not be able to produce an iterable. | ||
connection satisfies AsyncIterableIterator<unknown>; | ||
// @ts-expect-error Should not be able to produce an iterable. | ||
connection[Symbol.asyncIterator]() satisfies AsyncIterableIterator<unknown>; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters