Skip to content

Conversation

@vincentbel
Copy link
Contributor

FormData is also available in worker. (IDL spec).

Problem

The FormData declaration in DOM is

declare var FormData: {
    prototype: FormData;
    new (form?: HTMLFormElement): FormData;
}

But HTMLFormElement is not available in worker. So I think we should change the constructor to:
(but can't find related info in w3c spec)

new (): FormData;

form-data

I add a flavor to inputfiles/overridingTypes.json, but it seems not work. How can I achieve this?

{
"kind": "constructor",
"interface": "FormData",
"flavor": "DOM",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think you mean "web"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I change it to Web, but seem still not work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I guess the origin FormData constructor definition is ininputfiles/browser.webidl.xml#L4303.


declare var FormData: {
prototype: FormData;
new (form?: HTMLFormElement): FormData;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tis is failing the CI tests:

generated/webworker.generated.d.ts(459,17): error TS2304: Cannot find name 'HTMLFormElement'.

you will need to update this for WebWorkers only to be string i presume.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mhegazy The IDL spec says Constructor(optional HTMLFormElement form). So I think it should be empty rather than a string.

let removedCtor = getRemovedItems ItemKind.Constructor flavor |> Array.tryFind (matchInterface i.Name)
if Option.isNone removedCtor then
let overriddenCtor = getOverriddenItems ItemKind.Constructor Flavor.All |> Array.tryFind (matchInterface i.Name)
let overriddenCtor = getOverriddenItems ItemKind.Constructor flavor |> Array.tryFind (matchInterface i.Name)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mhegazy After looking into this generating script, I found out the reason why "flavor": "Web" in inputfiles/overridingTypes.json is ignored is that it always use Flavor.All to EmitConstructorSignature.

@mhegazy mhegazy merged commit 475f27e into microsoft:master May 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants