-
Notifications
You must be signed in to change notification settings - Fork 31
Description
At the moment the polyfill follows the reference implementation in keeping private instance data in fields with leading underscores:
export class ReadableStream<R = any> {
/** @internal */
_state!: ReadableStreamState;
/** @internal */
_reader: ReadableStreamReader<R> | undefined;
/** @internal */
_storedError: any;
/** @internal */
_disturbed!: boolean;
/** @internal */
_readableStreamController!: ReadableStreamDefaultController<R> | ReadableByteStreamController;
// ...
}For some use cases it would be nice to have the internals hidden in a more enforced way. An obvious approach would be to use ES private fields, but polyfilling them accurately requires WeakMaps, so it would be necessary to have some kind of additional processing using something like the babel loose transform mode to support pure ES5 targets (without actually enforcing privacy for them, which seems reasonable). I don't think TypeScript offers this itself at the moment.
Would you be interested in accepting a patch along those lines? Obviously adopting this for the whole polyfill would be a bit of an invasive change.