Skip to content

Commit 1fda2ca

Browse files
committed
add DOMException (not provided by IDL)
1 parent f74d0a7 commit 1fda2ca

File tree

5 files changed

+282
-9
lines changed

5 files changed

+282
-9
lines changed

TS.fsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,8 @@ module Emit =
715715
| "any" -> "any"
716716
| "bool" | "boolean" | "Boolean" -> "boolean"
717717
| "Date" -> "Date"
718-
| "DOMException" -> "Error"
718+
| "Error" -> "Error"
719+
| "DOMException" -> "DOMException"
719720
| "DOMHighResTimeStamp" -> "number"
720721
| "DOMString" | "USVString" | "ByteString" -> "string"
721722
| "DOMTimeStamp" -> "number"
@@ -787,7 +788,7 @@ module Emit =
787788
| Some c' -> emitConstantFromJson c'
788789
| None -> Pt.Printl "readonly %s: %s;" c.Name (DomTypeToTsType c.Type)
789790

790-
let addedConstants = getAddedItems ItemKind.Constant Flavor.All
791+
let addedConstants = getAddedItemsByInterfaceName ItemKind.Constant Flavor.All i.Name
791792
Array.iter emitConstantFromJson addedConstants
792793

793794
if i.Constants.IsSome then
@@ -1146,8 +1147,7 @@ module Emit =
11461147
else
11471148
Pt.Printl "new (): %s;" i.Name
11481149

1149-
getAddedItems ItemKind.Constructor Flavor.All
1150-
|> Array.filter (matchInterface i.Name)
1150+
getAddedItemsByInterfaceName ItemKind.Constructor Flavor.All i.Name
11511151
|> Array.iter emitConstructorSigFromJson
11521152

11531153
let EmitConstructor flavor (i:Browser.Interface) =
@@ -1473,10 +1473,13 @@ module Emit =
14731473
| _ -> ()
14741474
m.Signatures |> Array.iter (Pt.PrintWithAddedIndent "%s;")
14751475

1476+
let emitConstant (c: InputJsonType.Constant) =
1477+
Pt.PrintWithAddedIndent "readonly %s: %s;" c.Name c.Type
14761478

14771479
ai.Properties |> Array.iter emitProperty
14781480
ai.Methods |> Array.iter emitMethod
14791481
ai.Indexer |> Array.collect (fun i -> i.Signatures) |> Array.iter (Pt.PrintWithAddedIndent "%s;")
1482+
ai.Constants |> Array.iter emitConstant
14801483
Pt.Printl "}"
14811484
Pt.Printl ""
14821485

@@ -1487,6 +1490,7 @@ module Emit =
14871490
| Some comment -> Pt.PrintWithAddedIndent "%s" comment
14881491
| _ -> ()
14891492
ai.ConstructorSignatures |> Array.iter (Pt.PrintWithAddedIndent "%s;")
1493+
ai.Constants |> Array.iter emitConstant
14901494
Pt.Printl "}"
14911495
Pt.Printl ""
14921496

baselines/dom.generated.d.ts

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,7 +1470,7 @@ interface ScrollToOptions extends ScrollOptions {
14701470
}
14711471

14721472
interface SensorErrorEventInit extends EventInit {
1473-
error?: any;
1473+
error?: Error;
14741474
}
14751475

14761476
interface SensorOptions {
@@ -8538,7 +8538,7 @@ declare var Sensor: {
85388538
}
85398539

85408540
interface SensorErrorEvent extends Event {
8541-
readonly error: any;
8541+
readonly error: Error;
85428542
}
85438543

85448544
declare var SensorErrorEvent: {
@@ -12728,13 +12728,73 @@ interface AssignedNodesOptions {
1272812728
flatten?: boolean;
1272912729
}
1273012730

12731+
interface DOMException extends Error {
12732+
readonly name: string;
12733+
readonly code: number;
12734+
readonly INDEX_SIZE_ERR: number;
12735+
readonly DOMSTRING_SIZE_ERR: number;
12736+
readonly HIERARCHY_REQUEST_ERR: number;
12737+
readonly WRONG_DOCUMENT_ERR: number;
12738+
readonly INVALID_CHARACTER_ERR: number;
12739+
readonly NO_DATA_ALLOWED_ERR: number;
12740+
readonly NO_MODIFICATION_ALLOWED_ERR: number;
12741+
readonly NOT_FOUND_ERR: number;
12742+
readonly NOT_SUPPORTED_ERR: number;
12743+
readonly INUSE_ATTRIBUTE_ERR: number;
12744+
readonly INVALID_STATE_ERR: number;
12745+
readonly SYNTAX_ERR: number;
12746+
readonly INVALID_MODIFICATION_ERR: number;
12747+
readonly NAMESPACE_ERR: number;
12748+
readonly INVALID_ACCESS_ERR: number;
12749+
readonly VALIDATION_ERR: number;
12750+
readonly TYPE_MISMATCH_ERR: number;
12751+
readonly SECURITY_ERR: number;
12752+
readonly NETWORK_ERR: number;
12753+
readonly ABORT_ERR: number;
12754+
readonly URL_MISMATCH_ERR: number;
12755+
readonly QUOTA_EXCEEDED_ERR: number;
12756+
readonly TIMEOUT_ERR: number;
12757+
readonly INVALID_NODE_TYPE_ERR: number;
12758+
readonly DATA_CLONE_ERR: number;
12759+
}
12760+
12761+
declare var DOMException: {
12762+
prototype: DOMException;
12763+
new (message?: string, name?: string): DOMException;
12764+
readonly INDEX_SIZE_ERR: number;
12765+
readonly DOMSTRING_SIZE_ERR: number;
12766+
readonly HIERARCHY_REQUEST_ERR: number;
12767+
readonly WRONG_DOCUMENT_ERR: number;
12768+
readonly INVALID_CHARACTER_ERR: number;
12769+
readonly NO_DATA_ALLOWED_ERR: number;
12770+
readonly NO_MODIFICATION_ALLOWED_ERR: number;
12771+
readonly NOT_FOUND_ERR: number;
12772+
readonly NOT_SUPPORTED_ERR: number;
12773+
readonly INUSE_ATTRIBUTE_ERR: number;
12774+
readonly INVALID_STATE_ERR: number;
12775+
readonly SYNTAX_ERR: number;
12776+
readonly INVALID_MODIFICATION_ERR: number;
12777+
readonly NAMESPACE_ERR: number;
12778+
readonly INVALID_ACCESS_ERR: number;
12779+
readonly VALIDATION_ERR: number;
12780+
readonly TYPE_MISMATCH_ERR: number;
12781+
readonly SECURITY_ERR: number;
12782+
readonly NETWORK_ERR: number;
12783+
readonly ABORT_ERR: number;
12784+
readonly URL_MISMATCH_ERR: number;
12785+
readonly QUOTA_EXCEEDED_ERR: number;
12786+
readonly TIMEOUT_ERR: number;
12787+
readonly INVALID_NODE_TYPE_ERR: number;
12788+
readonly DATA_CLONE_ERR: number;
12789+
}
12790+
1273112791
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
1273212792

1273312793
interface BlobCallback {
1273412794
(blob: Blob | null): void;
1273512795
}
1273612796
interface DecodeErrorCallback {
12737-
(error: Error): void;
12797+
(error: DOMException): void;
1273812798
}
1273912799
interface DecodeSuccessCallback {
1274012800
(decodedData: AudioBuffer): void;
@@ -12785,7 +12845,7 @@ interface PositionErrorCallback {
1278512845
(positionError: PositionError): void;
1278612846
}
1278712847
interface RTCPeerConnectionErrorCallback {
12788-
(error: Error): void;
12848+
(error: DOMException): void;
1278912849
}
1279012850
interface RTCSessionDescriptionCallback {
1279112851
(description: RTCSessionDescriptionInit): void;

baselines/webworker.generated.d.ts

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1466,10 +1466,70 @@ interface ProgressEventInit extends EventInit {
14661466
interface IDBArrayKey extends Array<IDBValidKey> {
14671467
}
14681468

1469+
interface DOMException extends Error {
1470+
readonly name: string;
1471+
readonly code: number;
1472+
readonly INDEX_SIZE_ERR: number;
1473+
readonly DOMSTRING_SIZE_ERR: number;
1474+
readonly HIERARCHY_REQUEST_ERR: number;
1475+
readonly WRONG_DOCUMENT_ERR: number;
1476+
readonly INVALID_CHARACTER_ERR: number;
1477+
readonly NO_DATA_ALLOWED_ERR: number;
1478+
readonly NO_MODIFICATION_ALLOWED_ERR: number;
1479+
readonly NOT_FOUND_ERR: number;
1480+
readonly NOT_SUPPORTED_ERR: number;
1481+
readonly INUSE_ATTRIBUTE_ERR: number;
1482+
readonly INVALID_STATE_ERR: number;
1483+
readonly SYNTAX_ERR: number;
1484+
readonly INVALID_MODIFICATION_ERR: number;
1485+
readonly NAMESPACE_ERR: number;
1486+
readonly INVALID_ACCESS_ERR: number;
1487+
readonly VALIDATION_ERR: number;
1488+
readonly TYPE_MISMATCH_ERR: number;
1489+
readonly SECURITY_ERR: number;
1490+
readonly NETWORK_ERR: number;
1491+
readonly ABORT_ERR: number;
1492+
readonly URL_MISMATCH_ERR: number;
1493+
readonly QUOTA_EXCEEDED_ERR: number;
1494+
readonly TIMEOUT_ERR: number;
1495+
readonly INVALID_NODE_TYPE_ERR: number;
1496+
readonly DATA_CLONE_ERR: number;
1497+
}
1498+
1499+
declare var DOMException: {
1500+
prototype: DOMException;
1501+
new (message?: string, name?: string): DOMException;
1502+
readonly INDEX_SIZE_ERR: number;
1503+
readonly DOMSTRING_SIZE_ERR: number;
1504+
readonly HIERARCHY_REQUEST_ERR: number;
1505+
readonly WRONG_DOCUMENT_ERR: number;
1506+
readonly INVALID_CHARACTER_ERR: number;
1507+
readonly NO_DATA_ALLOWED_ERR: number;
1508+
readonly NO_MODIFICATION_ALLOWED_ERR: number;
1509+
readonly NOT_FOUND_ERR: number;
1510+
readonly NOT_SUPPORTED_ERR: number;
1511+
readonly INUSE_ATTRIBUTE_ERR: number;
1512+
readonly INVALID_STATE_ERR: number;
1513+
readonly SYNTAX_ERR: number;
1514+
readonly INVALID_MODIFICATION_ERR: number;
1515+
readonly NAMESPACE_ERR: number;
1516+
readonly INVALID_ACCESS_ERR: number;
1517+
readonly VALIDATION_ERR: number;
1518+
readonly TYPE_MISMATCH_ERR: number;
1519+
readonly SECURITY_ERR: number;
1520+
readonly NETWORK_ERR: number;
1521+
readonly ABORT_ERR: number;
1522+
readonly URL_MISMATCH_ERR: number;
1523+
readonly QUOTA_EXCEEDED_ERR: number;
1524+
readonly TIMEOUT_ERR: number;
1525+
readonly INVALID_NODE_TYPE_ERR: number;
1526+
readonly DATA_CLONE_ERR: number;
1527+
}
1528+
14691529
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
14701530

14711531
interface DecodeErrorCallback {
1472-
(error: Error): void;
1532+
(error: DOMException): void;
14731533
}
14741534
interface DecodeSuccessCallback {
14751535
(decodedData: AudioBuffer): void;

inputfiles/addedTypes.json

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,5 +632,128 @@
632632
"name": "formData",
633633
"flavor": "Web",
634634
"signatures": ["formData(): Promise<FormData>"]
635+
},
636+
637+
{
638+
"kind": "interface",
639+
"name": "DOMException",
640+
"extends": "Error",
641+
"properties": [
642+
{
643+
"name": "name",
644+
"type": "string",
645+
"readonly": true
646+
},
647+
{
648+
"name": "code",
649+
"type": "number",
650+
"readonly": true
651+
}
652+
],
653+
"constructorSignatures": [
654+
"new (message?: string, name?: string): DOMException"
655+
],
656+
"constants": [
657+
{
658+
"name": "INDEX_SIZE_ERR",
659+
"type": "number"
660+
},
661+
{
662+
"name": "DOMSTRING_SIZE_ERR",
663+
"type": "number"
664+
},
665+
{
666+
"name": "HIERARCHY_REQUEST_ERR",
667+
"type": "number"
668+
},
669+
{
670+
"name": "WRONG_DOCUMENT_ERR",
671+
"type": "number"
672+
},
673+
{
674+
"name": "INVALID_CHARACTER_ERR",
675+
"type": "number"
676+
},
677+
{
678+
"name": "NO_DATA_ALLOWED_ERR",
679+
"type": "number"
680+
},
681+
{
682+
"name": "NO_MODIFICATION_ALLOWED_ERR",
683+
"type": "number"
684+
},
685+
{
686+
"name": "NOT_FOUND_ERR",
687+
"type": "number"
688+
},
689+
{
690+
"name": "NOT_SUPPORTED_ERR",
691+
"type": "number"
692+
},
693+
{
694+
"name": "INUSE_ATTRIBUTE_ERR",
695+
"type": "number"
696+
},
697+
{
698+
"name": "INVALID_STATE_ERR",
699+
"type": "number"
700+
},
701+
{
702+
"name": "SYNTAX_ERR",
703+
"type": "number"
704+
},
705+
{
706+
"name": "INVALID_MODIFICATION_ERR",
707+
"type": "number"
708+
},
709+
{
710+
"name": "NAMESPACE_ERR",
711+
"type": "number"
712+
},
713+
{
714+
"name": "INVALID_ACCESS_ERR",
715+
"type": "number"
716+
},
717+
{
718+
"name": "VALIDATION_ERR",
719+
"type": "number"
720+
},
721+
{
722+
"name": "TYPE_MISMATCH_ERR",
723+
"type": "number"
724+
},
725+
{
726+
"name": "SECURITY_ERR",
727+
"type": "number"
728+
},
729+
{
730+
"name": "NETWORK_ERR",
731+
"type": "number"
732+
},
733+
{
734+
"name": "ABORT_ERR",
735+
"type": "number"
736+
},
737+
{
738+
"name": "URL_MISMATCH_ERR",
739+
"type": "number"
740+
},
741+
{
742+
"name": "QUOTA_EXCEEDED_ERR",
743+
"type": "number"
744+
},
745+
{
746+
"name": "TIMEOUT_ERR",
747+
"type": "number"
748+
},
749+
{
750+
"name": "INVALID_NODE_TYPE_ERR",
751+
"type": "number"
752+
},
753+
{
754+
"name": "DATA_CLONE_ERR",
755+
"type": "number"
756+
}
757+
]
635758
}
636759
]

inputfiles/sample.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,5 +348,31 @@
348348
"type": "HTMLCollection"
349349
}
350350
]
351+
},
352+
{
353+
"kind": "interface",
354+
"name": "DOMException",
355+
"extends": "Error",
356+
"properties": [
357+
{
358+
"name": "name",
359+
"type": "string",
360+
"readonly": true
361+
},
362+
{
363+
"name": "code",
364+
"type": "number",
365+
"readonly": true
366+
}
367+
],
368+
"constructorSignatures": [
369+
"new (message?: string, name?: string): DOMException"
370+
],
371+
"constants": [
372+
{
373+
"name": "INDEX_SIZE_ERR",
374+
"type": "number"
375+
}
376+
]
351377
}
352378
]

0 commit comments

Comments
 (0)