Description
As an example, the docs for ReadableStream.getReader()
says that it returns a ReadableStreamReader
. Cool.
Except the docs for ReadableStreamReader
says that it's just a JSObject
.
Now what am I supposed to do?
After talking to @kevmoo, I learned that this happens when there's a JS union, which Dart doesn't support. Fair enough. I also learned that the MDN docs for getReader()
tell me that the possible JS returns are ReadableStreamDefaultReader
or ReadableStreamBYOBReader
, both of which have Dart equivalents. However neither of these types is mentioned in the Dart web getReader()
docs or the ReadableStreamReader
docs, so how do I know that if I don't talk to Kevin?
With this info, my first thought is to do a Dart cast to ReadableStreamDefaultReader
(the default) but according to Kevin, I'm not supposed to do that either. Apparently there's some lint that tells me what to do. Which is great, if I've got that lint enabled.
But even if I do have that lint enabled, the docs should tell me not to waste my time on Dart as
or is
to learn from the lint (if I have it enabled) what the right thing to do is.
The MDN docs tell me what the right thing to do is. And it's my understanding that the Dart docs are generated from the MDN docs (or the same metadata that the MDN docs are generated from). So can we please make the Dart docs tell me what the right thing to do in the face of a JS union is?
Thank you. And thank you for attending my Ted talk.