-
Notifications
You must be signed in to change notification settings - Fork 424
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
Add XMLHttpRequest types #432
Conversation
baselines/webworker.generated.d.ts
Outdated
@@ -641,18 +641,20 @@ declare var FileReaderSync: { | |||
}; | |||
|
|||
interface FormData { | |||
append(name: string, value: string | Blob, fileName?: string): void; | |||
append(name: string, value: string): void; | |||
append(name: string, blobValue: Blob, filename?: string): void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the previous overload was better.. since you can pass a value of type string | Blob
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, but somehow the spec authors have decided to use two signatures. No idea why, maybe documentation purpose?
[Constructor(optional HTMLFormElement form),
Exposed=(Window,Worker)]
interface FormData {
void append(USVString name, USVString value);
void append(USVString name, Blob blobValue, optional USVString filename);
void delete(USVString name);
FormDataEntryValue? get(USVString name);
sequence<FormDataEntryValue> getAll(USVString name);
boolean has(USVString name);
void set(USVString name, USVString value);
void set(USVString name, Blob blobValue, optional USVString filename);
iterable<USVString, FormDataEntryValue>;
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can override these two methods to avoid breaking existing users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I just noted this is a breaking change, but anyway formData.append('str', 'str', 'str');
is invalid and throws on Firefox. I would say the spec signature is better to prevent unexpected runtime breakage.
f.append("abc", "abc", "abc")
// TypeError: Argument 2 of FormData.append is not an object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the union problem... looks like there is no ideal solution here, I'll just override them to keep previous behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i agree.. but append(string, sring|Blob)
should just work fine.
baselines/webworker.generated.d.ts
Outdated
delete(name: string): void; | ||
get(name: string): FormDataEntryValue | null; | ||
getAll(name: string): FormDataEntryValue[]; | ||
has(name: string): boolean; | ||
set(name: string, value: string | Blob, fileName?: string): void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here.
"progress": ProgressEvent; | ||
"timeout": ProgressEvent; | ||
} | ||
|
||
interface XMLHttpRequestEventTarget { | ||
onabort: ((this: XMLHttpRequest, ev: Event) => any) | null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the this
type was intentional see microsoft/TypeScript#15101 and #275
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
XMLHttpRequestUpload
also extends XMLHttpRequestEventTarget
, hmm. It doesn't have any properties so forcing XMLHttpRequest won't be an issue for now...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -111,7 +111,7 @@ function emitDom() { | |||
if (obj["callback-interfaces"]) result["callback-interfaces"]!.interface = filterInterface(obj["callback-interfaces"]!.interface, template["callback-interfaces"] && template["callback-interfaces"]!.interface); | |||
if (obj.dictionaries) result.dictionaries!.dictionary = filterDictionary(obj.dictionaries.dictionary, template.dictionaries && template.dictionaries.dictionary); | |||
if (obj.enums) result.enums!.enum = filterEnum(obj.enums.enum, template.enums && template.enums.enum); | |||
if (obj.mixins) result.mixins!.mixin = filterInterface(obj.mixins.mixin, template.mixins && template.mixins.mixin); | |||
if (obj.mixins) result.mixins!.mixin = filterProperties(obj.mixins.mixin, mixin => !(template.mixins && template.mixins!.mixin[mixin.name])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure i understand this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previous code removed mixin members, the changed one removes the mixin itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(XMLHttpRequestEventTarget was a mixin but now is an interface, so the previous one should be removed.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's really a copy of line 110.
if (obj["callback-functions"]) result["callback-functions"]!["callback-function"] = filterProperties(obj["callback-functions"]!["callback-function"], (cb) => !(template["callback-functions"] && template["callback-functions"]!["callback-function"][cb.name]));
Add
FormData.forEach
, remove obsoleteinitProgressEvent
, fixXMLHttpRequestEventTargetEventMap
, etc.Fixes microsoft/TypeScript#21414
Fixes microsoft/TypeScript#19830