Skip to content

Commit

Permalink
fix: Typing for WritableStream (#1186)
Browse files Browse the repository at this point in the history
- Import in a different file and just export it
- Use implicit typing to work around the issue
- Fixes #803
  • Loading branch information
mofojed authored Mar 30, 2023
1 parent 4870171 commit dfdf356
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 28 deletions.
16 changes: 2 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions packages/iris-grid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@
"prop-types": "^15.7.2",
"react-beautiful-dnd": "^13.1.0",
"react-transition-group": "^4.4.2",
"shortid": "^2.2.16",
"web-streams-polyfill": "^2.1.0"
"shortid": "^2.2.16"
},
"peerDependencies": {
"react": "^17.x",
Expand Down
13 changes: 1 addition & 12 deletions packages/iris-grid/src/sidebar/TableSaver.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { PureComponent } from 'react';
import { WritableStream as ponyfillWritableStream } from 'web-streams-polyfill/ponyfill';
import dh, {
Column,
DateWrapper,
Expand All @@ -10,7 +9,6 @@ import dh, {
} from '@deephaven/jsapi-shim';
import Log from '@deephaven/log';
import { GridRange, GridRangeIndex, memoizeClear } from '@deephaven/grid';

import { Formatter, FormatterUtils, TableUtils } from '@deephaven/jsapi-utils';
import {
CancelablePromise,
Expand Down Expand Up @@ -97,9 +95,6 @@ export default class TableSaver extends PureComponent<
this.snapshotPending = 0;
this.cancelableSnapshots = [];

// WritableStream is not supported in Firefox (also IE) yet. use ponyfillWritableStream instead
this.WritableStream = window.WritableStream ?? ponyfillWritableStream;

// Due to an open issue in Chromium, readableStream.cancel() is never called when a user cancel the stream from Chromium's UI and the stream goes on even it's canceled.
// Instead, we monitor the pull() behavior from the readableStream called when the stream wants more data to write.
// If the stream doesn't pull for long enough time, chances are the stream is already canceled, so we stop the stream.
Expand Down Expand Up @@ -175,12 +170,6 @@ export default class TableSaver extends PureComponent<

cancelableSnapshots: (CancelablePromise<unknown> | null)[];

// WritableStream is not supported in Firefox (also IE) yet. use ponyfillWritableStream instead

// TODO: Fix type error
WritableStream = window.WritableStream ?? ponyfillWritableStream;
// WritableStream: typeof window.WritableStream | typeof ponyfillWritableStream;

// Due to an open issue in Chromium, readableStream.cancel() is never called when a user cancel the stream from Chromium's UI and the stream goes on even it's canceled.
// Instead, we monitor the pull() behavior from the readableStream called when the stream wants more data to write.
// If the stream doesn't pull for long enough time, chances are the stream is already canceled, so we stop the stream.
Expand Down Expand Up @@ -257,7 +246,7 @@ export default class TableSaver extends PureComponent<
};
}

return new this.WritableStream(streamConfig);
return new WritableStream(streamConfig);
}

startDownload(
Expand Down

0 comments on commit dfdf356

Please sign in to comment.