Skip to content

Commit d6ac21e

Browse files
author
Kevin Snyder
committed
Fix DefinitelyTyped#21235: add global types to DOMWindow interface
TypeScript team is figuring out how to expose these types on their `Window` interface, which `DOMWindow` extends (discussion [here](microsoft/TypeScript#19816)). In the meantime, this workaround will ensure that jsdom code compiles. Some types are not defined even globally by TypeScript. These have been commented out in the `DOMWindow` interface, but are still valid properties in jsdom. If someone tries to use these properties, their code will still not compile.
1 parent e562021 commit d6ac21e

File tree

1 file changed

+147
-1
lines changed

1 file changed

+147
-1
lines changed

types/jsdom/index.d.ts

Lines changed: 147 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,153 @@ export type ConstructorOptions = Options & {
103103
contentType?: string;
104104
};
105105

106-
export interface DOMWindow extends Window { eval(script: string): void; }
106+
export interface DOMWindow extends Window {
107+
eval(script: string): void;
108+
109+
/* node_modules/jsdom/living/index.js */
110+
DOMException: typeof DOMException,
111+
Attr: typeof Attr,
112+
Node: typeof Node,
113+
Element: typeof Element,
114+
DocumentFragment: typeof DocumentFragment,
115+
Document: typeof Document,
116+
HTMLDocument: typeof HTMLDocument,
117+
XMLDocument: typeof XMLDocument,
118+
CharacterData: typeof CharacterData,
119+
Text: typeof Text,
120+
CDATASection: typeof CDATASection,
121+
ProcessingInstruction: typeof ProcessingInstruction,
122+
Comment: typeof Comment,
123+
DocumentType: typeof DocumentType,
124+
DOMImplementation: typeof DOMImplementation,
125+
NodeList: typeof NodeList,
126+
HTMLCollection: typeof HTMLCollection,
127+
HTMLOptionsCollection: typeof HTMLOptionsCollection,
128+
DOMStringMap: typeof DOMStringMap,
129+
DOMTokenList: typeof DOMTokenList,
130+
Event: typeof Event,
131+
CustomEvent: typeof CustomEvent,
132+
MessageEvent: typeof MessageEvent,
133+
ErrorEvent: typeof ErrorEvent,
134+
HashChangeEvent: typeof HashChangeEvent,
135+
FocusEvent: typeof FocusEvent,
136+
PopStateEvent: typeof PopStateEvent,
137+
UIEvent: typeof UIEvent,
138+
MouseEvent: typeof MouseEvent,
139+
KeyboardEvent: typeof KeyboardEvent,
140+
TouchEvent: typeof TouchEvent,
141+
ProgressEvent: typeof ProgressEvent,
142+
CompositionEvent: typeof CompositionEvent,
143+
WheelEvent: typeof WheelEvent,
144+
EventTarget: typeof EventTarget,
145+
Location: typeof Location,
146+
History: typeof History,
147+
Blob: typeof Blob,
148+
File: typeof File,
149+
FileList: typeof FileList,
150+
DOMParser: typeof DOMParser,
151+
FormData: typeof FormData,
152+
XMLHttpRequestEventTarget: XMLHttpRequestEventTarget,
153+
XMLHttpRequestUpload: typeof XMLHttpRequestUpload,
154+
NodeIterator: typeof NodeIterator,
155+
TreeWalker: typeof TreeWalker,
156+
NamedNodeMap: typeof NamedNodeMap,
157+
URL: typeof URL,
158+
URLSearchParams: typeof URLSearchParams,
159+
160+
/* node_modules/jsdom/living/register-elements.js */
161+
HTMLElement: typeof HTMLElement,
162+
HTMLAnchorElement: typeof HTMLAnchorElement,
163+
HTMLAppletElement: typeof HTMLAppletElement,
164+
HTMLAreaElement: typeof HTMLAreaElement,
165+
HTMLAudioElement: typeof HTMLAudioElement,
166+
HTMLBaseElement: typeof HTMLBaseElement,
167+
HTMLBodyElement: typeof HTMLBodyElement,
168+
HTMLBRElement: typeof HTMLBRElement,
169+
HTMLButtonElement: typeof HTMLButtonElement,
170+
HTMLCanvasElement: typeof HTMLCanvasElement,
171+
HTMLDataElement: typeof HTMLDataElement,
172+
HTMLDataListElement: typeof HTMLDataListElement,
173+
// HTMLDetailsElement: typeof HTMLDetailsElement,
174+
// HTMLDialogElement: typeof HTMLDialogElement,
175+
HTMLDirectoryElement: typeof HTMLDirectoryElement,
176+
HTMLDivElement: typeof HTMLDivElement,
177+
HTMLDListElement: typeof HTMLDListElement,
178+
HTMLEmbedElement: typeof HTMLEmbedElement,
179+
HTMLFieldSetElement: typeof HTMLFieldSetElement,
180+
HTMLFontElement: typeof HTMLFontElement,
181+
HTMLFormElement: typeof HTMLFormElement,
182+
HTMLFrameElement: typeof HTMLFrameElement,
183+
HTMLFrameSetElement: typeof HTMLFrameSetElement,
184+
HTMLHeadingElement: typeof HTMLHeadingElement,
185+
HTMLHeadElement: typeof HTMLHeadElement,
186+
HTMLHRElement: typeof HTMLHRElement,
187+
HTMLHtmlElement: typeof HTMLHtmlElement,
188+
HTMLIFrameElement: typeof HTMLIFrameElement,
189+
HTMLImageElement: typeof HTMLImageElement,
190+
HTMLInputElement: typeof HTMLInputElement,
191+
HTMLLabelElement: typeof HTMLLabelElement,
192+
HTMLLegendElement: typeof HTMLLegendElement,
193+
HTMLLIElement: typeof HTMLLIElement,
194+
HTMLLinkElement: typeof HTMLLinkElement,
195+
HTMLMapElement: typeof HTMLMapElement,
196+
HTMLMarqueeElement: typeof HTMLMarqueeElement,
197+
HTMLMediaElement: typeof HTMLMediaElement,
198+
HTMLMenuElement: typeof HTMLMenuElement,
199+
HTMLMetaElement: typeof HTMLMetaElement,
200+
HTMLMeterElement: typeof HTMLMeterElement,
201+
HTMLModElement: typeof HTMLModElement,
202+
HTMLObjectElement: typeof HTMLObjectElement,
203+
HTMLOListElement: typeof HTMLOListElement,
204+
HTMLOptGroupElement: typeof HTMLOptGroupElement,
205+
HTMLOptionElement: typeof HTMLOptionElement,
206+
HTMLOutputElement: typeof HTMLOutputElement,
207+
HTMLParagraphElement: typeof HTMLParagraphElement,
208+
HTMLParamElement: typeof HTMLParamElement,
209+
HTMLPictureElement: typeof HTMLPictureElement,
210+
HTMLPreElement: typeof HTMLPreElement,
211+
HTMLProgressElement: typeof HTMLProgressElement,
212+
HTMLQuoteElement: typeof HTMLQuoteElement,
213+
HTMLScriptElement: typeof HTMLScriptElement,
214+
HTMLSelectElement: typeof HTMLSelectElement,
215+
HTMLSourceElement: typeof HTMLSourceElement,
216+
HTMLSpanElement: typeof HTMLSpanElement,
217+
HTMLStyleElement: typeof HTMLStyleElement,
218+
HTMLTableCaptionElement: typeof HTMLTableCaptionElement,
219+
HTMLTableCellElement: typeof HTMLTableCellElement,
220+
HTMLTableColElement: typeof HTMLTableColElement,
221+
HTMLTableElement: typeof HTMLTableElement,
222+
HTMLTimeElement: typeof HTMLTimeElement,
223+
HTMLTitleElement: typeof HTMLTitleElement,
224+
HTMLTableRowElement: typeof HTMLTableRowElement,
225+
HTMLTableSectionElement: typeof HTMLTableSectionElement,
226+
HTMLTemplateElement: typeof HTMLTemplateElement,
227+
HTMLTextAreaElement: typeof HTMLTextAreaElement,
228+
HTMLTrackElement: typeof HTMLTrackElement,
229+
HTMLUListElement: typeof HTMLUListElement,
230+
HTMLUnknownElement: typeof HTMLUnknownElement,
231+
HTMLVideoElement: typeof HTMLVideoElement,
232+
233+
/* node_modules/jsdom/level2/style.js */
234+
StyleSheet: typeof StyleSheet,
235+
MediaList: typeof MediaList,
236+
CSSStyleSheet: typeof CSSStyleSheet,
237+
CSSRule: typeof CSSRule,
238+
CSSStyleRule: typeof CSSStyleRule,
239+
CSSMediaRule: typeof CSSMediaRule,
240+
CSSImportRule: typeof CSSImportRule,
241+
CSSStyleDeclaration: typeof CSSStyleDeclaration,
242+
StyleSheetList: typeof StyleSheetList,
243+
244+
/* node_modules/jsdom/level3/xpath.js */
245+
// XPathException: typeof XPathException,
246+
XPathExpression: typeof XPathExpression,
247+
XPathResult: typeof XPathResult,
248+
XPathEvaluator: typeof XPathEvaluator,
249+
250+
/* node_modules/jsdom/living/node-filter.js */
251+
NodeFilter: typeof NodeFilter
252+
}
107253

108254
export type BinaryData = ArrayBuffer | DataView | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
109255

0 commit comments

Comments
 (0)