Skip to content

Commit 475f27e

Browse files
authored
Merge pull request #231 from VincentBel/webworker-add-FormData
add FormData typing to webworker
2 parents fe9b62d + 472ffaf commit 475f27e

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

TS.fsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ module Emit =
699699
let extendedTypes =
700700
["ArrayBuffer";"ArrayBufferView";"Int8Array";"Uint8Array";"Int16Array";"Uint16Array";"Int32Array";"Uint32Array";"Float32Array";"Float64Array"]
701701

702-
let integerTypes =
702+
let integerTypes =
703703
["byte";"octet";"short";"unsigned short";"long";"unsigned long";"long long";"unsigned long long"]
704704

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

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

1093-
let removedCtor = getRemovedItems ItemKind.Constructor Flavor.All |> Array.tryFind (matchInterface i.Name)
1093+
let removedCtor = getRemovedItems ItemKind.Constructor flavor |> Array.tryFind (matchInterface i.Name)
10941094
if Option.isNone removedCtor then
1095-
let overriddenCtor = getOverriddenItems ItemKind.Constructor Flavor.All |> Array.tryFind (matchInterface i.Name)
1095+
let overriddenCtor = getOverriddenItems ItemKind.Constructor flavor |> Array.tryFind (matchInterface i.Name)
10961096
match overriddenCtor with
10971097
| Some c' -> emitConstructorSigFromJson c'
10981098
| _ ->
@@ -1104,7 +1104,7 @@ module Emit =
11041104
Pt.Printl "new(%s): %s;" paramsString i.Name
11051105
| _ -> Pt.Printl "new(): %s;" i.Name
11061106

1107-
getAddedItems ItemKind.Constructor Flavor.All
1107+
getAddedItems ItemKind.Constructor flavor
11081108
|> Array.filter (matchInterface i.Name)
11091109
|> Array.iter emitConstructorSigFromJson
11101110

@@ -1113,7 +1113,7 @@ module Emit =
11131113
Pt.IncreaseIndent()
11141114

11151115
Pt.Printl "prototype: %s;" i.Name
1116-
EmitConstructorSignature i
1116+
EmitConstructorSignature flavor i
11171117
EmitConstants i
11181118
let prefix = ""
11191119
EmitMembers flavor prefix EmitScope.StaticOnly i
@@ -1507,11 +1507,11 @@ module Emit =
15071507
List.contains p.Type integerTypes
15081508

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

15131513
let findIterableGetter() =
1514-
let anonymousGetter =
1514+
let anonymousGetter =
15151515
if (i.AnonymousMethods.IsSome) then Array.tryFind isIterableGetter i.AnonymousMethods.Value.Methods
15161516
else None
15171517

@@ -1541,7 +1541,7 @@ module Emit =
15411541
Pt.Printl ""
15421542

15431543
browser.Interfaces |> Array.iter EmitIterator
1544-
1544+
15451545
fprintf target "%s" (Pt.GetResult())
15461546
target.Flush()
15471547
target.Close()

baselines/webworker.generated.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,15 @@ declare var FileReader: {
450450
new(): FileReader;
451451
};
452452

453+
interface FormData {
454+
append(name: string, value: string | Blob, fileName?: string): void;
455+
}
456+
457+
declare var FormData: {
458+
prototype: FormData;
459+
new(): FormData;
460+
};
461+
453462
interface Headers {
454463
append(name: string, value: string): void;
455464
delete(name: string): void;

inputfiles/knownWorkerInterfaces.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"FileList",
3434
"FileReader",
3535
"ForEachCallback",
36+
"FormData",
3637
"FunctionStringCallback",
3738
"GetNotificationOptions",
3839
"GlobalFetch",

inputfiles/overridingTypes.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@
359359
{
360360
"kind": "constructor",
361361
"interface": "FormData",
362+
"flavor": "Web",
362363
"signatures": ["new (form?: HTMLFormElement): FormData"]
363364
},
364365
{

0 commit comments

Comments
 (0)