Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions TS.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ module Emit =
let extendedTypes =
["ArrayBuffer";"ArrayBufferView";"Int8Array";"Uint8Array";"Int16Array";"Uint16Array";"Int32Array";"Uint32Array";"Float32Array";"Float64Array"]

let integerTypes =
let integerTypes =
["byte";"octet";"short";"unsigned short";"long";"unsigned long";"long long";"unsigned long long"]

/// Get typescript type using object dom type, object name, and it's associated interface name
Expand Down Expand Up @@ -731,7 +731,7 @@ module Emit =
// Name of an interface / enum / dict. Just return itself
if allInterfacesMap.ContainsKey objDomType ||
allCallbackFuncs.ContainsKey objDomType ||
allDictionariesMap.ContainsKey objDomType ||
allDictionariesMap.ContainsKey objDomType ||
allEnumsMap.ContainsKey objDomType then
objDomType
// Name of a type alias. Just return itself
Expand Down Expand Up @@ -1086,13 +1086,13 @@ module Emit =
"%saddEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;"
fPrefix

let EmitConstructorSignature (i:Browser.Interface) =
let EmitConstructorSignature flavor (i:Browser.Interface) =
let emitConstructorSigFromJson (c: InputJsonType.Root) =
c.Signatures |> Array.iter (Pt.Printl "%s;")

let removedCtor = getRemovedItems ItemKind.Constructor Flavor.All |> Array.tryFind (matchInterface i.Name)
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.

match overriddenCtor with
| Some c' -> emitConstructorSigFromJson c'
| _ ->
Expand All @@ -1104,7 +1104,7 @@ module Emit =
Pt.Printl "new(%s): %s;" paramsString i.Name
| _ -> Pt.Printl "new(): %s;" i.Name

getAddedItems ItemKind.Constructor Flavor.All
getAddedItems ItemKind.Constructor flavor
|> Array.filter (matchInterface i.Name)
|> Array.iter emitConstructorSigFromJson

Expand All @@ -1113,7 +1113,7 @@ module Emit =
Pt.IncreaseIndent()

Pt.Printl "prototype: %s;" i.Name
EmitConstructorSignature i
EmitConstructorSignature flavor i
EmitConstants i
let prefix = ""
EmitMembers flavor prefix EmitScope.StaticOnly i
Expand Down Expand Up @@ -1507,11 +1507,11 @@ module Emit =
List.contains p.Type integerTypes

// check anonymous unsigned long getter and length property
let isIterableGetter (m: Browser.Method) =
let isIterableGetter (m: Browser.Method) =
m.Getter = Some 1 && m.Params.Length = 1 && isIntegerKeyParam m.Params.[0]

let findIterableGetter() =
let anonymousGetter =
let anonymousGetter =
if (i.AnonymousMethods.IsSome) then Array.tryFind isIterableGetter i.AnonymousMethods.Value.Methods
else None

Expand Down Expand Up @@ -1541,7 +1541,7 @@ module Emit =
Pt.Printl ""

browser.Interfaces |> Array.iter EmitIterator

fprintf target "%s" (Pt.GetResult())
target.Flush()
target.Close()
Expand Down
9 changes: 9 additions & 0 deletions baselines/webworker.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,15 @@ declare var FileReader: {
new(): FileReader;
};

interface FormData {
append(name: string, value: string | Blob, fileName?: string): void;
}

declare var FormData: {
prototype: FormData;
new(): FormData;
};

interface Headers {
append(name: string, value: string): void;
delete(name: string): void;
Expand Down
1 change: 1 addition & 0 deletions inputfiles/knownWorkerInterfaces.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"FileList",
"FileReader",
"ForEachCallback",
"FormData",
"FunctionStringCallback",
"GetNotificationOptions",
"GlobalFetch",
Expand Down
1 change: 1 addition & 0 deletions inputfiles/overridingTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@
{
"kind": "constructor",
"interface": "FormData",
"flavor": "Web",
"signatures": ["new (form?: HTMLFormElement): FormData"]
},
{
Expand Down