Skip to content

Commit 77fd202

Browse files
robin-phamfacebook-github-bot
authored andcommitted
[PR] Fix static declarations for XMLHttpRequest
Summary: Encountered this error while using static values from [XMLHttpRequest](https://xhr.spec.whatwg.org/#interface-xmlhttprequest): ``` Cannot get `XMLHttpRequest.DONE` because property `DONE` is missing in statics of `XMLHttpRequest` ``` I think they were never declared properly in the [bom.js](https://github.com/facebook/flow/blob/master/lib/bom.js#L584) file. Here's a [stripped down tryflow](https://flow.org/try/#0CYUwxgNghgTiAEkoGdnwMIFcZwHYBcANAWQBkAJffABwCUQBHTEZfedgbwCh32ARAPIA5AKIAueLkwBbAEYgYAbi49erKPgCWYZBO68DiOBpAAKAJQSsOEARIUqdRs1bKAkAcGiJUuQuUGAL5cwVygSHCI0KjwAAowAPbUCcggwABimgAe9pQ09EwsbJxcbupaYPBe4pIy8kqq-MI1vvXKjfDl2rrw+obsYMb4ZpZxicmpGdm5jgUu+AG8waFgCbis8MOsAIzwALwY2HhEZHlOhawAdNVcq+tsW-gATPtjSSlpmTmns85F180gA) demonstrating the issue as well as the fix. On a related note, I'm not sure what the `create()` declaration in the `statics` block is for either. Pull Request resolved: #6091 Reviewed By: dsainati1 Differential Revision: D13820105 Pulled By: nmote fbshipit-source-id: 624042d694e2804473e75751bf75c61d9d21f65a
1 parent 93409d9 commit 77fd202

File tree

3 files changed

+141
-142
lines changed

3 files changed

+141
-142
lines changed

lib/bom.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,11 @@ declare class XDomainRequest {
579579

580580

581581
declare class XMLHttpRequest extends EventTarget {
582+
static LOADING: number;
583+
static DONE: number;
584+
static UNSENT: number;
585+
static OPENED: number;
586+
static HEADERS_RECEIVED: number;
582587
responseBody: any;
583588
status: number;
584589
readyState: number;
@@ -616,12 +621,6 @@ declare class XMLHttpRequest extends EventTarget {
616621

617622
statics: {
618623
create(): XMLHttpRequest;
619-
620-
LOADING: number;
621-
DONE: number;
622-
UNSENT: number;
623-
OPENED: number;
624-
HEADERS_RECEIVED: number;
625624
}
626625
}
627626

tests/bom/bom.exp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -578,8 +578,8 @@ Cannot assign `headers.get(...)` to `b` because null [1] is incompatible with st
578578
^^^^^^^^^^^^^^^^^^
579579

580580
References:
581-
<BUILTINS>/bom.js:951:24
582-
951| get(name: string): null | string;
581+
<BUILTINS>/bom.js:950:24
582+
950| get(name: string): null | string;
583583
^^^^ [1]
584584
Headers.js:8:10
585585
8| const b: string = headers.get('foo'); // incorrect
@@ -803,8 +803,8 @@ Cannot assign `params.get(...)` to `b` because null [1] is incompatible with str
803803
^^^^^^^^^^^^^^^^^
804804

805805
References:
806-
<BUILTINS>/bom.js:965:24
807-
965| get(name: string): null | string;
806+
<BUILTINS>/bom.js:964:24
807+
964| get(name: string): null | string;
808808
^^^^ [1]
809809
URLSearchParams.js:8:10
810810
8| const b: string = params.get('foo'); // incorrect

0 commit comments

Comments
 (0)