Skip to content

Commit 1cfe243

Browse files
authored
fix(util-stream): avoid compilation of type parameter in global ReadableStream (#1343)
1 parent ac1677e commit 1cfe243

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

.changeset/forty-candles-taste.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@smithy/eventstream-serde-browser": patch
3+
"@smithy/util-stream": patch
4+
---
5+
6+
avoid compilation of global ReadableStream with type parameter

packages/eventstream-serde-browser/src/EventStreamMarshaller.ts

+6
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,11 @@ export class EventStreamMarshaller {
6868
}
6969
}
7070

71+
/**
72+
* @internal
73+
* Warning: do not export this without aliasing the reference to
74+
* global ReadableStream.
75+
* @see https://github.com/smithy-lang/smithy-typescript/issues/1341.
76+
*/
7177
const isReadableStream = (body: any): body is ReadableStream =>
7278
typeof ReadableStream === "function" && body instanceof ReadableStream;
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
/**
22
* @internal
3+
* Alias prevents compiler from turning
4+
* ReadableStream into ReadableStream<any>, which is incompatible
5+
* with the NodeJS.ReadableStream global type.
36
*/
4-
export const isReadableStream = (stream: unknown): stream is ReadableStream =>
7+
type ReadableStreamType = ReadableStream;
8+
9+
/**
10+
* @internal
11+
*/
12+
export const isReadableStream = (stream: unknown): stream is ReadableStreamType =>
513
typeof ReadableStream === "function" &&
614
(stream?.constructor?.name === ReadableStream.name || stream instanceof ReadableStream);

0 commit comments

Comments
 (0)