Skip to content

ReadyState is ambiguous #615

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
japgolly opened this issue Oct 21, 2021 · 3 comments · Fixed by #617
Closed

ReadyState is ambiguous #615

japgolly opened this issue Oct 21, 2021 · 3 comments · Fixed by #617
Assignees
Labels

Comments

@japgolly
Copy link
Contributor

We have ReadyState as closed | ended | open which is currently being used in MediaSource.

The problem is that there are many ReadyState definitions depending on where it's used. For example, IDBRequest.readyState is pending | done.

We should add types for all (or at least some common) ready state enums, and prefix them all according to their domain.

> rgs ' readyState: '
dom/src/main/scala/org/scalajs/dom/MediaSource.scala
16:  def readyState: ReadyState = js.native

dom/src/main/scala/org/scalajs/dom/RTCDataChannel.scala
33:  def readyState: RTCDataChannelState = js.native

dom/src/main/scala/org/scalajs/dom/IDBRequest.scala
52:  def readyState: String = js.native

dom/src/main/scala/org/scalajs/dom/MediaStreamTrack.scala
44:  val readyState: MediaStreamTrackState = js.native
110:      readyState: js.UndefOr[String] = js.undefined, remote: js.UndefOr[Boolean] = js.undefined,

dom/src/main/scala/org/scalajs/dom/HTMLDocument.scala
50:  def readyState: String = js.native

dom/src/main/scala/org/scalajs/dom/EventSource.scala
36:  def readyState: Int = js.native

dom/src/main/scala/org/scalajs/dom/FileReader.scala
26:  def readyState: Short = js.native

dom/src/main/scala/org/scalajs/dom/HTMLElement.scala
65:  var readyState: js.Any = js.native

dom/src/main/scala/org/scalajs/dom/TextTrack.scala
16:  var readyState: Int = js.native

dom/src/main/scala/org/scalajs/dom/WebSocket.scala
28:  def readyState: Int = js.native

dom/src/main/scala/org/scalajs/dom/XMLHttpRequest.scala
33:  def readyState: Int = js.native
@armanbilge
Copy link
Member

Yes I realized this issue as well and brought it up in #588 (comment). What I ended up doing is checking what Typescript does, which is use this one for MediaSource. Of course, we don't have to follow typescript.

type ReadyState = "closed" | "ended" | "open";
type DocumentReadyState = "complete" | "interactive" | "loading";
type IDBRequestReadyState = "done" | "pending";

@armanbilge armanbilge added the bug label Oct 21, 2021
@japgolly
Copy link
Contributor Author

Yeah let's not follow Typescript, clearer is clearly better IMO. I'll PR this now. I'm done with my RC1 testing 🚀

@japgolly japgolly self-assigned this Oct 21, 2021
@japgolly
Copy link
Contributor Author

btw, thanks for pasting those ts definitions! saving me work ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants