From 9f2fcb8cd7d363c325402865417feff78ec6a7cc Mon Sep 17 00:00:00 2001 From: Sam Zhou Date: Fri, 28 Feb 2025 15:48:08 -0800 Subject: [PATCH] [flow] Remove bom, cssom, dom, stream from bundled libdefs Summary: Changelog: [lib] Since the last version, most of the bundled libdefs will no longer be maintained and shipped with Flow. Going forward, they should be downloaded from flow-typed. Starting from this version, we will also no longer ship a set of precise typing definition for jsx intrinsics. To maintain the same behavior as before, you should have a `flow-typed.config.json` in the root of your project with the following content: ``` { "env": ["node", "dom", "bom", "intl", "cssom", "indexeddb", "serviceworkers", "webassembly", "jsx"] } ``` Reviewed By: jbrown215 Differential Revision: D70409195 fbshipit-source-id: 483f214a71d11f3f98cf2e077fe4a88f49e2c5d6 --- lib/bom.js | 575 --- lib/cssom.js | 555 -- lib/dom.js | 4471 ----------------- lib/streams.js | 127 - newtests/lsp/queries/test.js | 2 +- tests/arrows/arrows.js | 4 + .../autocomplete_from_m_to_q.exp | 244 +- tests/component_syntax/component_syntax.exp | 9 +- tests/component_syntax/refs.js | 2 +- tests/declare_namespace/declare_namespace.exp | 54 +- .../type_only_react_namespace.js | 4 +- tests/global_this/global_this.exp | 30 +- tests/global_this/test.js | 2 +- tests/new_merge_diff/new_merge_diff.exp | 7 +- tests/quick_start/quick_start.exp | 8 +- .../quick_start_add_dependency.exp | 4 +- .../quick_start_add_dependency_on_cycle.exp | 4 +- .../quick_start_check_contents.exp | 4 +- .../quick_start_delete_dependency.exp | 6 +- .../quick_start_unchecked_dependency.exp | 8 +- tests/react_ref_as_prop/react_ref_as_prop.exp | 189 +- tests/react_rules/ref_read_different_type.js | 2 +- tests/union/union.js | 2 + 23 files changed, 162 insertions(+), 6151 deletions(-) delete mode 100644 lib/bom.js delete mode 100644 lib/cssom.js delete mode 100644 lib/dom.js delete mode 100644 lib/streams.js diff --git a/lib/bom.js b/lib/bom.js deleted file mode 100644 index b8a51d9c2c1..00000000000 --- a/lib/bom.js +++ /dev/null @@ -1,575 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -/* BOM */ - - -type PermissionState = - | "granted" - | "denied" - | "prompt"; - -type FileSystemHandlePermissionDescriptor = {| - mode: "read" | "readwrite"; -|} - -declare class PermissionStatus extends EventTarget { - onchange: ?((event: any) => mixed); - +state: PermissionState; -} - -// https://www.w3.org/TR/hr-time-2/#dom-domhighrestimestamp -// https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp -declare type DOMHighResTimeStamp = number; - -declare class Location { - ancestorOrigins: string[]; - hash: string; - host: string; - hostname: string; - href: string; - origin: string; - pathname: string; - port: string; - protocol: string; - search: string; - assign(url: string): void; - reload(flag?: boolean): void; - replace(url: string): void; - toString(): string; -} - -/////////////////////////////////////////////////////////////////////////////// - -type FormDataEntryValue = string | File - -declare class FormData { - constructor(form?: HTMLFormElement, submitter?: HTMLElement | null): void; - - has(name: string): boolean; - get(name: string): ?FormDataEntryValue; - getAll(name: string): Array; - - set(name: string, value: string): void; - set(name: string, value: Blob, filename?: string): void; - set(name: string, value: File, filename?: string): void; - - append(name: string, value: string): void; - append(name: string, value: Blob, filename?: string): void; - append(name: string, value: File, filename?: string): void; - - delete(name: string): void; - - keys(): Iterator; - values(): Iterator; - entries(): Iterator<[string, FormDataEntryValue]>; -} - -declare class DOMRectReadOnly { - static fromRect(rectangle?: { - x: number, - y: number, - width: number, - height: number, - ... - }): DOMRectReadOnly; - constructor(x: number, y: number, width: number, height: number): void; - +bottom: number; - +height: number; - +left: number; - +right: number; - +top: number; - +width: number; - +x: number; - +y: number; -} - -declare class DOMRect extends DOMRectReadOnly { - static fromRect(rectangle?: { - x: number, - y: number, - width: number, - height: number, - ... - }): DOMRect; - bottom: number; - height: number; - left: number; - right: number; - top: number; - width: number; - x: number; - y: number; -} - -declare class DOMRectList { - @@iterator(): Iterator; - length: number; - item(index: number): DOMRect; - [index: number]: DOMRect; -} - -type AudioContextState = 'suspended' | 'running' | 'closed'; - -declare class CanvasCaptureMediaStream extends MediaStream { - canvas: HTMLCanvasElement; - requestFrame(): void; -} - -type DoubleRange = { - max?: number; - min?: number; - ... -} - -type LongRange = { - max?: number; - min?: number; - ... -} - -type ConstrainBooleanParameters = { - exact?: boolean; - ideal?: boolean; - ... -} - -type ConstrainDOMStringParameters = { - exact?: string | string[]; - ideal?: string | string[]; - ... -} - -type ConstrainDoubleRange = { - ...DoubleRange; - exact?: number; - ideal?: number; - ... -} - -type ConstrainLongRange = { - ...LongRange; - exact?: number; - ideal?: number; - ... -} - -type MediaTrackConstraintSet = { - width?: number | ConstrainLongRange; - height?: number | ConstrainLongRange; - aspectRatio?: number | ConstrainDoubleRange; - frameRate?: number | ConstrainDoubleRange; - facingMode?: string | string[] | ConstrainDOMStringParameters; - resizeMode?: string | string[] | ConstrainDOMStringParameters; - volume?: number | ConstrainDoubleRange; - sampleRate?: number | ConstrainLongRange; - sampleSize?: number | ConstrainLongRange; - echoCancellation?: boolean | ConstrainBooleanParameters; - autoGainControl?: boolean | ConstrainBooleanParameters; - noiseSuppression?: boolean | ConstrainBooleanParameters; - latency?: number | ConstrainDoubleRange; - channelCount?: number | ConstrainLongRange; - deviceId?: string | string[] | ConstrainDOMStringParameters; - groupId?: string | string[] | ConstrainDOMStringParameters; - ... -} - -type MediaTrackConstraints = { - ...MediaTrackConstraintSet; - advanced?: Array; - ... -} - -type MediaStreamConstraints = { - audio?: boolean | MediaTrackConstraints; - video?: boolean | MediaTrackConstraints; - peerIdentity?: string; - ... -} - -type MediaTrackSettings = { - aspectRatio?: number; - deviceId?: string; - displaySurface?: 'application' | 'browser' | 'monitor' | 'window'; - echoCancellation?: boolean; - facingMode?: string; - frameRate?: number; - groupId?: string; - height?: number; - logicalSurface?: boolean; - sampleRate?: number; - sampleSize?: number; - volume?: number; - width?: number; - ... -} - -type MediaTrackCapabilities = { - aspectRatio?: number | DoubleRange; - deviceId?: string; - echoCancellation?: boolean[]; - facingMode?: string; - frameRate?: number | DoubleRange; - groupId?: string; - height?: number | LongRange; - sampleRate?: number | LongRange; - sampleSize?: number | LongRange; - volume?: number | DoubleRange; - width?: number | LongRange; - ... -} - -declare class MediaStream extends EventTarget { - active: boolean; - ended: boolean; - id: string; - onactive: (ev: any) => mixed; - oninactive: (ev: any) => mixed; - onended: (ev: any) => mixed; - onaddtrack: (ev: MediaStreamTrackEvent) => mixed; - onremovetrack: (ev: MediaStreamTrackEvent) => mixed; - addTrack(track: MediaStreamTrack): void; - clone(): MediaStream; - getAudioTracks(): MediaStreamTrack[]; - getTrackById(trackid?: string): ?MediaStreamTrack; - getTracks(): MediaStreamTrack[]; - getVideoTracks(): MediaStreamTrack[]; - removeTrack(track: MediaStreamTrack): void; -} - -declare class MediaStreamTrack extends EventTarget { - enabled: boolean; - id: string; - kind: string; - label: string; - muted: boolean; - readonly: boolean; - readyState: 'live' | 'ended'; - remote: boolean; - contentHint?: string; - onstarted: (ev: any) => mixed; - onmute: (ev: any) => mixed; - onunmute: (ev: any) => mixed; - onoverconstrained: (ev: any) => mixed; - onended: (ev: any) => mixed; - getConstraints(): MediaTrackConstraints; - applyConstraints(constraints?: MediaTrackConstraints): Promise; - getSettings(): MediaTrackSettings; - getCapabilities(): MediaTrackCapabilities; - clone(): MediaStreamTrack; - stop(): void; -} - -declare class MediaStreamTrackEvent extends Event { - track: MediaStreamTrack; -} - -declare class URLSearchParams { - @@iterator(): Iterator<[string, string]>; - - size: number; - - constructor(init?: string | URLSearchParams | Array<[string, string]> | { [string]: string, ... } ): void; - append(name: string, value: string): void; - delete(name: string, value?: string): void; - entries(): Iterator<[string, string]>; - forEach(callback: (this : This, value: string, name: string, params: URLSearchParams) => mixed, thisArg: This): void; - get(name: string): null | string; - getAll(name: string): Array; - has(name: string, value?: string): boolean; - keys(): Iterator; - set(name: string, value: string): void; - sort(): void; - values(): Iterator; - toString(): string; -} - -declare class AbortSignal extends EventTarget { - +aborted: boolean; - +reason: any; - abort(reason?: any): AbortSignal; - onabort: (event: Event) => mixed; - throwIfAborted(): void; - timeout(time: number): AbortSignal; -} - -declare class MediaQueryListEvent { - matches: boolean; - media: string; -} - -declare type MediaQueryListListener = MediaQueryListEvent => void; - -/* Trusted Types - * https://w3c.github.io/trusted-types/dist/spec/#trusted-types - */ -declare class TrustedHTML { - toString(): string; - toJSON(): string; -} - -declare class TrustedScript { - toString(): string; - toJSON(): string; -} - -declare class TrustedScriptURL { - toString(): string; - toJSON(): string; -} - -// https://wicg.github.io/webusb/ -// https://developer.mozilla.org/en-US/docs/Web/API/USBDevice -declare class USBDevice { - configuration: USBConfiguration; - configurations: Array; - deviceClass: number; - deviceProtocol: number; - deviceSubclass: number; - deviceVersionMajor: number; - deviceVersionMinor: number; - deviceVersionSubminor: number; - manufacturerName: ?string; - opened: boolean; - productId: number; - productName: ?string; - serialNumber: ?string; - usbVersionMajor: number; - usbVersionMinor: number; - usbVersionSubminor: number; - vendorId: number; - claimInterface(interfaceNumber: number): Promise; - clearHalt(direction: 'in' | 'out', endpointNumber: number): Promise; - close(): Promise; - controlTransferIn(setup: SetUpOptions, length: number): Promise; - controlTransferOut(setup: SetUpOptions, data: ArrayBuffer): Promise; - forget(): Promise; - isochronousTransferIn(endpointNumber: number, packetLengths: Array): Promise; - isochronousTransferOut(endpointNumber: number, data: ArrayBuffer, packetLengths: Array): Promise; - open(): Promise; - releaseInterface(interfaceNumber: number): Promise; - reset(): Promise; - selectAlternateInterface(interfaceNumber: number, alternateSetting: number): Promise; - selectConfiguration(configurationValue: number): Promise; - transferIn(endpointNumber: number, length: number): Promise; - transferOut(endpointNumber: number, data: ArrayBuffer): Promise; -} - -declare type USBDeviceFilter = {| - vendorId?: number; - productId?: number; - classCode?: number; - subclassCode?: number; - protocolCode?: number; - serialNumber?: string; -|}; - -declare type USBDeviceRequestOptions = {| - filters: Array; - exclusionFilters?: Array; -|} - -declare class USBConfiguration { - constructor(): void; - configurationName: ?string; - configurationValue: number; - interfaces: $ReadOnlyArray; - -} - -declare class USBInterface { - constructor(): void; - interfaceNumber: number; - alternate: USBAlternateInterface; - alternates: Array; - claimed: boolean; -} - -declare class USBAlternateInterface { - constructor(): void; - alternateSetting: number; - interfaceClass: number; - interfaceSubclass: number; - interfaceProtocol: number; - interfaceName: ?string; - endpoints : Array; -} - -declare class USBEndpoint { - constructor(): void; - endpointNumber: number; - direction: 'in' | 'out'; - type:'bulk' | 'interrupt' | 'isochronous'; - packetSize: number; -} - -declare class USBOutTransferResult { - constructor(): void; - bytesWritten: number; - status: 'ok' | 'stall'; -} - -declare class USBInTransferResult { - constructor(): void; - data: DataView; - status: 'ok' |'stall' | 'babble'; -} - -declare class USBIsochronousInTransferResult { - constructor(): void; - data: DataView; - packets: Array; -} - -declare class USBIsochronousInTransferPacket { - constructor(): void; - data: DataView; - status: 'ok' |'stall' | 'babble'; -} - -declare class USBIsochronousOutTransferResult { - constructor(): void; - packets: Array -} - -declare class USBIsochronousOutTransferPacket { - constructor(): void; - bytesWritten: number; - status: 'ok' | 'stall'; -} - -type SetUpOptions = { - requestType: string; - recipient: string; - request: number; - value: number; - index: number; - ... -} - -declare type FileSystemHandleKind = "file" | "directory"; - -// https://wicg.github.io/file-system-access/#api-filesystemhandle -declare class FileSystemHandle { - +kind: FileSystemHandleKind; - +name: string; - - isSameEntry: (other: FileSystemHandle) => Promise; - queryPermission?: ( - descriptor: FileSystemHandlePermissionDescriptor - ) => Promise; - requestPermission?: ( - descriptor: FileSystemHandlePermissionDescriptor - ) => Promise; -} - -// https://fs.spec.whatwg.org/#api-filesystemfilehandle -declare class FileSystemFileHandle extends FileSystemHandle { - +kind: "file"; - - constructor(name: string): void; - - getFile(): Promise; - createSyncAccessHandle(): Promise; - createWritable(options?: {| - keepExistingData?: boolean, - |}): Promise; -} - -// https://fs.spec.whatwg.org/#api-filesystemdirectoryhandle -declare class FileSystemDirectoryHandle extends FileSystemHandle { - +kind: "directory"; - - constructor(name: string): void; - - getDirectoryHandle( - name: string, - options?: {| create?: boolean |} - ): Promise; - getFileHandle( - name: string, - options?: {| create?: boolean |} - ): Promise; - removeEntry(name: string, options?: {| recursive?: boolean |}): Promise; - resolve(possibleDescendant: FileSystemHandle): Promise | null>; - - // Async iterator functions - @@asyncIterator(): AsyncIterator<[string, FileSystemHandle]>; - entries(): AsyncIterator<[string, FileSystemHandle]>; - keys(): AsyncIterator; - values(): AsyncIterator; -} - -// https://fs.spec.whatwg.org/#api-filesystemsyncaccesshandle -declare class FileSystemSyncAccessHandle { - close(): void; - flush(): void; - getSize(): number; - read(buffer: ArrayBuffer, options?: {| at: number |}): number; - truncate(newSize: number): void; - write(buffer: ArrayBuffer, options?: {| at: number |}): number; -} - -// https://streams.spec.whatwg.org/#default-writer-class -declare class WritableStreamDefaultWriter { - +closed: Promise; - +desiredSize: number; - +ready: Promise; - - constructor(): void; - - abort(reason?: string): Promise; - close(): Promise; - releaseLock(): void; - write(chunk: any): Promise; -} - -// https://streams.spec.whatwg.org/#ws-class -declare class WriteableStream { - +locked: boolean; - - constructor(): void; - - abort(reason: string): Promise; - close(): Promise; - getWriter(): WritableStreamDefaultWriter; -} - -// https://fs.spec.whatwg.org/#dictdef-writeparams -declare type FileSystemWriteableFileStreamDataTypes = - | ArrayBuffer - | $TypedArray - | DataView - | Blob - | string; - -// https://fs.spec.whatwg.org/#dictdef-writeparams -declare type FileSystemWriteableFileStreamData = - | FileSystemWriteableFileStreamDataTypes - | {| - type: "write", - position?: number, - data: FileSystemWriteableFileStreamDataTypes, - |} - | {| - type: "seek", - position: number, - data: FileSystemWriteableFileStreamDataTypes, - |} - | {| - type: "size", - size: number, - |}; - -// https://fs.spec.whatwg.org/#api-filesystemwritablefilestream -declare class FileSystemWritableFileStream extends WriteableStream { - write(data: FileSystemWriteableFileStreamData): Promise; - truncate(size: number): Promise; - seek(position: number): Promise; -} diff --git a/lib/cssom.js b/lib/cssom.js deleted file mode 100644 index 4ec1641ecfb..00000000000 --- a/lib/cssom.js +++ /dev/null @@ -1,555 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -declare class StyleSheet { - disabled: boolean; - +href: string; - +media: MediaList; - +ownerNode: Node; - +parentStyleSheet: ?StyleSheet; - +title: string; - +type: string; -} - -declare class StyleSheetList { - @@iterator(): Iterator; - length: number; - [index: number]: StyleSheet; -} - -declare class MediaList { - @@iterator(): Iterator; - mediaText: string; - length: number; - item(index: number): ?string; - deleteMedium(oldMedium: string): void; - appendMedium(newMedium: string): void; - [index: number]: string; -} - -declare class CSSStyleSheet extends StyleSheet { - +cssRules: CSSRuleList; - +ownerRule: ?CSSRule; - deleteRule(index: number): void; - insertRule(rule: string, index: number): number; - replace(text: string): Promise; - replaceSync(text: string): void; -} - -declare class CSSRule { - cssText: string; - +parentRule: ?CSSRule; - +parentStyleSheet: ?CSSStyleSheet; - +type: number; - static STYLE_RULE: number; - static MEDIA_RULE: number; - static FONT_FACE_RULE: number; - static PAGE_RULE: number; - static IMPORT_RULE: number; - static CHARSET_RULE: number; - static UNKNOWN_RULE: number; - static KEYFRAMES_RULE: number; - static KEYFRAME_RULE: number; - static NAMESPACE_RULE: number; - static COUNTER_STYLE_RULE: number; - static SUPPORTS_RULE: number; - static DOCUMENT_RULE: number; - static FONT_FEATURE_VALUES_RULE: number; - static VIEWPORT_RULE: number; - static REGION_STYLE_RULE: number; -} - -declare class CSSKeyframeRule extends CSSRule { - keyText: string; - +style: CSSStyleDeclaration; -} - -declare class CSSKeyframesRule extends CSSRule { - name: string; - +cssRules: CSSRuleList; - appendRule(rule: string): void; - deleteRule(select: string): void; - findRule(select: string): CSSKeyframeRule | null; -} - -declare class CSSRuleList { - @@iterator(): Iterator; - length: number; - item(index: number): ?CSSRule; - [index: number]: CSSRule; -} - -declare class CSSStyleDeclaration { - @@iterator(): Iterator; - /* DOM CSS Properties */ - alignContent: string; - alignItems: string; - alignSelf: string; - all: string; - animation: string; - animationDelay: string; - animationDirection: string; - animationDuration: string; - animationFillMode: string; - animationIterationCount: string; - animationName: string; - animationPlayState: string; - animationTimingFunction: string; - backdropFilter: string; - webkitBackdropFilter: string; - backfaceVisibility: string; - background: string; - backgroundAttachment: string; - backgroundBlendMode: string; - backgroundClip: string; - backgroundColor: string; - backgroundImage: string; - backgroundOrigin: string; - backgroundPosition: string; - backgroundPositionX: string; - backgroundPositionY: string; - backgroundRepeat: string; - backgroundSize: string; - blockSize: string; - border: string; - borderBlockEnd: string; - borderBlockEndColor: string; - borderBlockEndStyle: string; - borderBlockEndWidth: string; - borderBlockStart: string; - borderBlockStartColor: string; - borderBlockStartStyle: string; - borderBlockStartWidth: string; - borderBottom: string; - borderBottomColor: string; - borderBottomLeftRadius: string; - borderBottomRightRadius: string; - borderBottomStyle: string; - borderBottomWidth: string; - borderCollapse: string; - borderColor: string; - borderImage: string; - borderImageOutset: string; - borderImageRepeat: string; - borderImageSlice: string; - borderImageSource: string; - borderImageWidth: string; - borderInlineEnd: string; - borderInlineEndColor: string; - borderInlineEndStyle: string; - borderInlineEndWidth: string; - borderInlineStart: string; - borderInlineStartColor: string; - borderInlineStartStyle: string; - borderInlineStartWidth: string; - borderLeft: string; - borderLeftColor: string; - borderLeftStyle: string; - borderLeftWidth: string; - borderRadius: string; - borderRight: string; - borderRightColor: string; - borderRightStyle: string; - borderRightWidth: string; - borderSpacing: string; - borderStyle: string; - borderTop: string; - borderTopColor: string; - borderTopLeftRadius: string; - borderTopRightRadius: string; - borderTopStyle: string; - borderTopWidth: string; - borderWidth: string; - bottom: string; - boxDecorationBreak: string; - boxShadow: string; - boxSizing: string; - breakAfter: string; - breakBefore: string; - breakInside: string; - captionSide: string; - clear: string; - clip: string; - clipPath: string; - color: string; - columns: string; - columnCount: string; - columnFill: string; - columnGap: string; - columnRule: string; - columnRuleColor: string; - columnRuleStyle: string; - columnRuleWidth: string; - columnSpan: string; - columnWidth: string; - contain: string; - content: string; - counterIncrement: string; - counterReset: string; - cursor: string; - direction: string; - display: string; - emptyCells: string; - filter: string; - flex: string; - flexBasis: string; - flexDirection: string; - flexFlow: string; - flexGrow: string; - flexShrink: string; - flexWrap: string; - float: string; - font: string; - fontFamily: string; - fontFeatureSettings: string; - fontKerning: string; - fontLanguageOverride: string; - fontSize: string; - fontSizeAdjust: string; - fontStretch: string; - fontStyle: string; - fontSynthesis: string; - fontVariant: string; - fontVariantAlternates: string; - fontVariantCaps: string; - fontVariantEastAsian: string; - fontVariantLigatures: string; - fontVariantNumeric: string; - fontVariantPosition: string; - fontWeight: string; - grad: string; - grid: string; - gridArea: string; - gridAutoColumns: string; - gridAutoFlow: string; - gridAutoPosition: string; - gridAutoRows: string; - gridColumn: string; - gridColumnStart: string; - gridColumnEnd: string; - gridRow: string; - gridRowStart: string; - gridRowEnd: string; - gridTemplate: string; - gridTemplateAreas: string; - gridTemplateRows: string; - gridTemplateColumns: string; - height: string; - hyphens: string; - imageRendering: string; - imageResolution: string; - imageOrientation: string; - imeMode: string; - inherit: string; - initial: string; - inlineSize: string; - isolation: string; - justifyContent: string; - left: string; - letterSpacing: string; - lineBreak: string; - lineHeight: string; - listStyle: string; - listStyleImage: string; - listStylePosition: string; - listStyleType: string; - margin: string; - marginBlockEnd: string; - marginBlockStart: string; - marginBottom: string; - marginInlineEnd: string; - marginInlineStart: string; - marginLeft: string; - marginRight: string; - marginTop: string; - marks: string; - mask: string; - maskType: string; - maxBlockSize: string; - maxHeight: string; - maxInlineSize: string; - maxWidth: string; - minBlockSize: string; - minHeight: string; - minInlineSize: string; - minWidth: string; - mixBlendMode: string; - mozTransform: string; - mozTransformOrigin: string; - mozTransitionDelay: string; - mozTransitionDuration: string; - mozTransitionProperty: string; - mozTransitionTimingFunction: string; - objectFit: string; - objectPosition: string; - offsetBlockEnd: string; - offsetBlockStart: string; - offsetInlineEnd: string; - offsetInlineStart: string; - opacity: string; - order: string; - orphans: string; - outline: string; - outlineColor: string; - outlineOffset: string; - outlineStyle: string; - outlineWidth: string; - overflow: string; - overflowWrap: string; - overflowX: string; - overflowY: string; - padding: string; - paddingBlockEnd: string; - paddingBlockStart: string; - paddingBottom: string; - paddingInlineEnd: string; - paddingInlineStart: string; - paddingLeft: string; - paddingRight: string; - paddingTop: string; - pageBreakAfter: string; - pageBreakBefore: string; - pageBreakInside: string; - perspective: string; - perspectiveOrigin: string; - pointerEvents: string; - position: string; - quotes: string; - rad: string; - resize: string; - right: string; - rubyAlign: string; - rubyMerge: string; - rubyPosition: string; - scrollBehavior: string; - scrollSnapCoordinate: string; - scrollSnapDestination: string; - scrollSnapPointsX: string; - scrollSnapPointsY: string; - scrollSnapType: string; - shapeImageThreshold: string; - shapeMargin: string; - shapeOutside: string; - tableLayout: string; - tabSize: string; - textAlign: string; - textAlignLast: string; - textCombineUpright: string; - textDecoration: string; - textDecorationColor: string; - textDecorationLine: string; - textDecorationStyle: string; - textIndent: string; - textOrientation: string; - textOverflow: string; - textRendering: string; - textShadow: string; - textTransform: string; - textUnderlinePosition: string; - top: string; - touchAction: string; - transform: string; - transformOrigin: string; - transformStyle: string; - transition: string; - transitionDelay: string; - transitionDuration: string; - transitionProperty: string; - transitionTimingFunction: string; - turn: string; - unicodeBidi: string; - unicodeRange: string; - userSelect: string; - verticalAlign: string; - visibility: string; - webkitOverflowScrolling: string; - webkitTransform: string; - webkitTransformOrigin: string; - webkitTransitionDelay: string; - webkitTransitionDuration: string; - webkitTransitionProperty: string; - webkitTransitionTimingFunction: string; - whiteSpace: string; - widows: string; - width: string; - willChange: string; - wordBreak: string; - wordSpacing: string; - wordWrap: string; - writingMode: string; - zIndex: string; - - cssFloat: string; - cssText: string; - getPropertyPriority(property: string): string; - getPropertyValue(property:string): string; - item(index: number): string; - [index: number]: string; - length: number; - parentRule: CSSRule; - removeProperty(property: string): string; - setProperty(property: string, value: ?string, priority: ?string): void; - setPropertyPriority(property: string, priority: string): void; -} - -declare class TransitionEvent extends Event { - elapsedTime: number; // readonly - pseudoElement: string; // readonly - propertyName: string; // readonly -} - -type AnimationPlayState = 'idle' | 'running' | 'paused' | 'finished' -type AnimationReplaceState = 'active' | 'removed' | 'persisted' -type FillMode = 'none' | 'forwards' | 'backwards' | 'both' | 'auto' -type PlaybackDirection = 'normal' | 'reverse' | 'alternate' | 'alternate-reverse' -type IterationCompositeOperation = 'replace' | 'accumulate' -type CompositeOperation = 'replace' | 'add' | 'accumulate' -type CompositeOperationOrAuto = CompositeOperation | 'auto' - -declare class AnimationTimeline { - +currentTime: number | null; -} - -type DocumentTimelineOptions = { - originTime?: DOMHighResTimeStamp; - ... -} - -declare class DocumentTimeline extends AnimationTimeline { - constructor(options?: DocumentTimelineOptions): void; -} - -type EffectTiming = { - delay: number; - endDelay: number; - fill: FillMode; - iterationStart: number; - iterations: number; - duration: number | string; - direction: PlaybackDirection; - easing: string; - ... -} - -type OptionalEffectTiming = $Rest - -type ComputedEffectTiming = EffectTiming & { - endTime: number; - activeDuration: number; - localTime: number | null; - progress: number | null; - currentIteration: number | null; - ... -} - -declare class AnimationEffect { - getTiming(): EffectTiming; - getComputedTiming(): ComputedEffectTiming; - updateTiming(timing?: OptionalEffectTiming): void; -} - -type Keyframe = { - composite?: CompositeOperationOrAuto; - easing?: string; - offset?: number | null; - [property: string]: string | number | null | void; - ... -} - -type ComputedKeyframe = { - composite: CompositeOperationOrAuto; - computedOffset: number; - easing: string; - offset: number | null; - [property: string]: string | number | null | void; - ... -} - -type PropertyIndexedKeyframes = { - composite?: CompositeOperationOrAuto | CompositeOperationOrAuto[]; - easing?: string | string[]; - offset?: number | (number | null)[]; - [property: string]: string | string[] | number | null | (number | null)[] | void; - ... -} - -type KeyframeEffectOptions = $Rest & { - iterationComposite?: IterationCompositeOperation; - composite?: CompositeOperation; - ... -} - -declare class KeyframeEffect extends AnimationEffect { - constructor( - target: Element | null, - keyframes: Keyframe[] | PropertyIndexedKeyframes | null, - options?: number | KeyframeEffectOptions, - ): void; - constructor(source: KeyframeEffect): void; - - target: Element | null; - iterationComposite: IterationCompositeOperation; - composite: CompositeOperation; - getKeyframes(): ComputedKeyframe[]; - setKeyframes(keyframes: Keyframe[] | PropertyIndexedKeyframes | null): void; -} - -declare class Animation extends EventTarget { - constructor(effect?: AnimationEffect | null, timeline?: AnimationTimeline | null): void; - - id: string; - effect: AnimationEffect | null; - timeline: AnimationTimeline | null; - startTime: number | null; - currentTime: number | null; - playbackRate: number; - +playState: AnimationPlayState; - +replaceState: AnimationReplaceState; - +pending: boolean; - +ready: Promise; - +finished: Promise; - onfinish: ?((ev: AnimationPlaybackEvent) => mixed); - oncancel: ?((ev: AnimationPlaybackEvent) => mixed); - onremove: ?((ev: AnimationPlaybackEvent) => mixed); - cancel(): void; - finish(): void; - play(): void; - pause(): void; - updatePlaybackRate(playbackRate: number): void; - reverse(): void; - persist(): void; - commitStyles(): void; -} - -type KeyframeAnimationOptions = KeyframeEffectOptions & { - id?: string; - ... -} - -type GetAnimationsOptions = { - subtree?: boolean; - ... -} - -interface Animatable { - animate(keyframes: Keyframe[] | PropertyIndexedKeyframes | null, options?: number | KeyframeAnimationOptions): Animation; - getAnimations(options?: GetAnimationsOptions): Animation[]; -} - -type AnimationPlaybackEvent$Init = Event$Init & { - currentTime?: number | null; - timelineTime?: number | null; - ... -} - -declare class AnimationPlaybackEvent extends Event { - constructor(type: string, animationEventInitDict?: AnimationPlaybackEvent$Init): void; - +currentTime: number | null; - +timelineTime: number | null; -} diff --git a/lib/dom.js b/lib/dom.js deleted file mode 100644 index 8ecf31c5f4d..00000000000 --- a/lib/dom.js +++ /dev/null @@ -1,4471 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * Copyright (c) Microsoft Corporation. All rights reserved. - * Modifications Copyright (c) Meta Platforms, Inc. and affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use - * this file except in compliance with the License. You may obtain a copy of the - * License at http://www.apache.org/licenses/LICENSE-2.0 - * THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED - * WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, - * MERCHANTABLITY OR NON-INFRINGEMENT. - * See the Apache Version 2.0 License for specific language governing permissions - * and limitations under the License. - * - * Portions copyright (c) World Wide Web Consortium, (Massachusetts Institute - * of Technology, European Research Consortium for Informatics and Mathematics, - * Keio University, Beihang). All Rights Reserved. This work is distributed - * under the W3C Software and Document License [1] in the hope that it will - * be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * [1] http://www.w3.org/Consortium/Legal/copyright-software - * - * @flow - */ -// @lint-ignore-every LICENSELINT - -/* Files */ - -declare class Blob { - constructor(blobParts?: Array, options?: { - type?: string, - endings?: string, - ... - }): void; - isClosed: boolean; - size: number; - type: string; - close(): void; - slice(start?: number, end?: number, contentType?: string): Blob; - arrayBuffer(): Promise; - text(): Promise, - stream(): ReadableStream, -} - -declare class FileReader extends EventTarget { - +EMPTY: 0; - +LOADING: 1; - +DONE: 2; - +error: null | DOMError; - +readyState: 0 | 1 | 2; - +result: null | string | ArrayBuffer; - abort(): void; - onabort: null | (ev: ProgressEvent) => any; - onerror: null | (ev: ProgressEvent) => any; - onload: null | (ev: ProgressEvent) => any; - onloadend: null | (ev: ProgressEvent) => any; - onloadstart: null | (ev: ProgressEvent) => any; - onprogress: null | (ev: ProgressEvent) => any; - readAsArrayBuffer(blob: Blob): void; - readAsBinaryString(blob: Blob): void; - readAsDataURL(blob: Blob): void; - readAsText(blob: Blob, encoding?: string): void; -} - -declare type FilePropertyBag = { - type?: string, - lastModified?: number, - ... -}; -declare class File extends Blob { - constructor( - fileBits: $ReadOnlyArray, - filename: string, - options?: FilePropertyBag, - ): void; - lastModified: number; - name: string; -} - -declare class FileList { - @@iterator(): Iterator; - length: number; - item(index: number): File; - [index: number]: File; -} - -/* DataTransfer */ - -declare class DataTransfer { - clearData(format?: string): void; - getData(format: string): string; - setData(format: string, data: string): void; - setDragImage(image: Element, x: number, y: number): void; - dropEffect: string; - effectAllowed: string; - files: FileList; // readonly - items: DataTransferItemList; // readonly - types: Array; // readonly -} - -declare class DataTransferItemList { - @@iterator(): Iterator; - length: number; // readonly - [index: number]: DataTransferItem; - add(data: string, type: string): ?DataTransferItem; - add(data: File): ?DataTransferItem; - remove(index: number): void; - clear(): void; -}; - -// https://wicg.github.io/file-system-access/#drag-and-drop -declare class DataTransferItem { - kind: string; // readonly - type: string; // readonly - getAsString(_callback: ?(data: string) => mixed): void; - getAsFile(): ?File; - /* - * This is not supported by all browsers, please have a fallback plan for it. - * For more information, please checkout - * https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem/webkitGetAsEntry - */ - webkitGetAsEntry(): void | () => any; - /* - * Not supported in all browsers - * For up to date compatibility information, please visit - * https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem/getAsFileSystemHandle - */ - getAsFileSystemHandle?: () => Promise; -}; - -/* DOM */ - -declare type DOMStringMap = { [key:string]: string, ... } - -declare class DOMStringList { - @@iterator(): Iterator; - +[key:number]: string; - +length: number; - item(number): string | null; - contains(string): boolean; -} - -declare class DOMError { - name: string; -} - -declare type ElementDefinitionOptions = { extends?: string, ... } - -declare interface CustomElementRegistry { - define(name: string, ctor: Class, options?: ElementDefinitionOptions): void; - get(name: string): any; - whenDefined(name: string): Promise; -} - -declare interface ShadowRoot extends DocumentFragment { - +delegatesFocus: boolean; - +host: Element; - // flowlint unsafe-getters-setters:off - get innerHTML(): string; - set innerHTML(value: string | TrustedHTML): void; - // flowlint unsafe-getters-setters:error - +mode: ShadowRootMode; - - // From DocumentOrShadowRoot Mixin. - +styleSheets: StyleSheetList; - adoptedStyleSheets: Array; -} - -declare type ShadowRootMode = 'open'|'closed'; - -declare type ShadowRootInit = { - delegatesFocus?: boolean, - mode: ShadowRootMode, - ... -} - -declare type ScrollToOptions = { - top?: number; - left?: number; - behavior?: 'auto' | 'smooth'; - ... -} - -type EventHandler = (event: Event) => mixed -type EventListener = { handleEvent: EventHandler, ... } | EventHandler -type MouseEventHandler = (event: MouseEvent) => mixed -type MouseEventListener = { handleEvent: MouseEventHandler, ... } | MouseEventHandler -type FocusEventHandler = (event: FocusEvent) => mixed -type FocusEventListener = { handleEvent: FocusEventHandler, ... } | FocusEventHandler -type KeyboardEventHandler = (event: KeyboardEvent) => mixed -type KeyboardEventListener = { handleEvent: KeyboardEventHandler, ... } | KeyboardEventHandler -type InputEventHandler = (event: InputEvent) => mixed -type InputEventListener = { handleEvent: InputEventHandler, ... } | InputEventHandler -type TouchEventHandler = (event: TouchEvent) => mixed -type TouchEventListener = { handleEvent: TouchEventHandler, ... } | TouchEventHandler -type WheelEventHandler = (event: WheelEvent) => mixed -type WheelEventListener = { handleEvent: WheelEventHandler, ... } | WheelEventHandler -type AbortProgressEventHandler = (event: ProgressEvent) => mixed -type AbortProgressEventListener = { handleEvent: AbortProgressEventHandler, ... } | AbortProgressEventHandler -type ProgressEventHandler = (event: ProgressEvent) => mixed -type ProgressEventListener = { handleEvent: ProgressEventHandler, ... } | ProgressEventHandler -type DragEventHandler = (event: DragEvent) => mixed -type DragEventListener = { handleEvent: DragEventHandler, ... } | DragEventHandler -type PointerEventHandler = (event: PointerEvent) => mixed -type PointerEventListener = { handleEvent: PointerEventHandler, ... } | PointerEventHandler -type AnimationEventHandler = (event: AnimationEvent) => mixed -type AnimationEventListener = { handleEvent: AnimationEventHandler, ... } | AnimationEventHandler -type ClipboardEventHandler = (event: ClipboardEvent) => mixed -type ClipboardEventListener = { handleEvent: ClipboardEventHandler, ... } | ClipboardEventHandler -type TransitionEventHandler = (event: TransitionEvent) => mixed -type TransitionEventListener = { handleEvent: TransitionEventHandler, ... } | TransitionEventHandler -type MessageEventHandler = (event: MessageEvent) => mixed -type MessageEventListener = { handleEvent: MessageEventHandler, ... } | MessageEventHandler -type BeforeUnloadEventHandler = (event: BeforeUnloadEvent) => mixed -type BeforeUnloadEventListener = { handleEvent: BeforeUnloadEventHandler, ... } | BeforeUnloadEventHandler -type StorageEventHandler = (event: StorageEvent) => mixed -type StorageEventListener = { handleEvent: StorageEventHandler, ... } | StorageEventHandler -type SecurityPolicyViolationEventHandler = (event: SecurityPolicyViolationEvent) => mixed -type SecurityPolicyViolationEventListener = { handleEvent: SecurityPolicyViolationEventHandler, ... } | SecurityPolicyViolationEventHandler -type USBConnectionEventHandler = (event: USBConnectionEvent) => mixed -type USBConnectionEventListener = { handleEvent: USBConnectionEventHandler, ... } | USBConnectionEventHandler - -type MediaKeySessionType = 'temporary' | 'persistent-license'; -type MediaKeyStatus = 'usable' | 'expired' | 'released' | 'output-restricted' | 'output-downscaled' | 'status-pending' | 'internal-error'; -type MouseEventTypes = 'contextmenu' | 'mousedown' | 'mouseenter' | 'mouseleave' | 'mousemove' | 'mouseout' | 'mouseover' | 'mouseup' | 'click' | 'dblclick'; -type FocusEventTypes = 'blur' | 'focus' | 'focusin' | 'focusout'; -type KeyboardEventTypes = 'keydown' | 'keyup' | 'keypress'; -type InputEventTypes = 'input' | 'beforeinput' -type TouchEventTypes = 'touchstart' | 'touchmove' | 'touchend' | 'touchcancel'; -type WheelEventTypes = 'wheel'; -type AbortProgressEventTypes = 'abort'; -type ProgressEventTypes = 'abort' | 'error' | 'load' | 'loadend' | 'loadstart' | 'progress' | 'timeout'; -type DragEventTypes = 'drag' | 'dragend' | 'dragenter' | 'dragexit' | 'dragleave' | 'dragover' | 'dragstart' | 'drop'; -type PointerEventTypes = 'pointerover' | 'pointerenter' | 'pointerdown' | 'pointermove' | 'pointerup' | 'pointercancel' | 'pointerout' | 'pointerleave' | 'gotpointercapture' | 'lostpointercapture'; -type AnimationEventTypes = 'animationstart' | 'animationend' | 'animationiteration'; -type ClipboardEventTypes = 'clipboardchange' | 'cut' | 'copy' | 'paste'; -type TransitionEventTypes = 'transitionrun' | 'transitionstart' | 'transitionend' | 'transitioncancel'; -type MessageEventTypes = string; -type BeforeUnloadEventTypes = 'beforeunload'; -type StorageEventTypes = 'storage'; -type SecurityPolicyViolationEventTypes = 'securitypolicyviolation'; -type USBConnectionEventTypes = 'connect' | 'disconnect'; - -type EventListenerOptionsOrUseCapture = boolean | { - capture?: boolean, - once?: boolean, - passive?: boolean, - signal?: AbortSignal, - ... -}; - -declare class EventTarget { - addEventListener(type: MouseEventTypes, listener: MouseEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - addEventListener(type: FocusEventTypes, listener: FocusEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - addEventListener(type: KeyboardEventTypes, listener: KeyboardEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - addEventListener(type: InputEventTypes, listener: InputEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - addEventListener(type: TouchEventTypes, listener: TouchEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - addEventListener(type: WheelEventTypes, listener: WheelEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - addEventListener(type: AbortProgressEventTypes, listener: AbortProgressEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - addEventListener(type: ProgressEventTypes, listener: ProgressEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - addEventListener(type: DragEventTypes, listener: DragEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - addEventListener(type: PointerEventTypes, listener: PointerEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - addEventListener(type: AnimationEventTypes, listener: AnimationEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - addEventListener(type: ClipboardEventTypes, listener: ClipboardEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - addEventListener(type: TransitionEventTypes, listener: TransitionEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - addEventListener(type: MessageEventTypes, listener: MessageEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - addEventListener(type: BeforeUnloadEventTypes, listener: BeforeUnloadEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - addEventListener(type: StorageEventTypes, listener: StorageEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - addEventListener(type: SecurityPolicyViolationEventTypes, listener: SecurityPolicyViolationEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - addEventListener(type: USBConnectionEventTypes, listener: USBConnectionEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - addEventListener(type: string, listener: EventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - - removeEventListener(type: MouseEventTypes, listener: MouseEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - removeEventListener(type: FocusEventTypes, listener: FocusEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - removeEventListener(type: KeyboardEventTypes, listener: KeyboardEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - removeEventListener(type: InputEventTypes, listener: InputEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - removeEventListener(type: TouchEventTypes, listener: TouchEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - removeEventListener(type: WheelEventTypes, listener: WheelEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - removeEventListener(type: AbortProgressEventTypes, listener: AbortProgressEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - removeEventListener(type: ProgressEventTypes, listener: ProgressEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - removeEventListener(type: DragEventTypes, listener: DragEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - removeEventListener(type: PointerEventTypes, listener: PointerEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - removeEventListener(type: AnimationEventTypes, listener: AnimationEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - removeEventListener(type: ClipboardEventTypes, listener: ClipboardEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - removeEventListener(type: TransitionEventTypes, listener: TransitionEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - removeEventListener(type: MessageEventTypes, listener: MessageEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - removeEventListener(type: BeforeUnloadEventTypes, listener: BeforeUnloadEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - removeEventListener(type: StorageEventTypes, listener: StorageEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - removeEventListener(type: SecurityPolicyViolationEventTypes, listener: SecurityPolicyViolationEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - removeEventListener(type: USBConnectionEventTypes, listener: USBConnectionEventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - removeEventListener(type: string, listener: EventListener, optionsOrUseCapture?: EventListenerOptionsOrUseCapture): void; - - attachEvent?: (type: MouseEventTypes, listener: MouseEventListener) => void; - attachEvent?: (type: FocusEventTypes, listener: FocusEventListener) => void; - attachEvent?: (type: KeyboardEventTypes, listener: KeyboardEventListener) => void; - attachEvent?: (type: InputEventTypes, listener: InputEventListener) => void; - attachEvent?: (type: TouchEventTypes, listener: TouchEventListener) => void; - attachEvent?: (type: WheelEventTypes, listener: WheelEventListener) => void; - attachEvent?: (type: AbortProgressEventTypes, listener: AbortProgressEventListener) => void; - attachEvent?: (type: ProgressEventTypes, listener: ProgressEventListener) => void; - attachEvent?: (type: DragEventTypes, listener: DragEventListener) => void; - attachEvent?: (type: PointerEventTypes, listener: PointerEventListener) => void; - attachEvent?: (type: AnimationEventTypes, listener: AnimationEventListener) => void; - attachEvent?: (type: ClipboardEventTypes, listener: ClipboardEventListener) => void; - attachEvent?: (type: TransitionEventTypes, listener: TransitionEventListener) => void; - attachEvent?: (type: MessageEventTypes, listener: MessageEventListener) => void; - attachEvent?: (type: BeforeUnloadEventTypes, listener: BeforeUnloadEventListener) => void; - attachEvent?: (type: StorageEventTypes, listener: StorageEventListener) => void; - attachEvent?: (type: USBConnectionEventTypes, listener: USBConnectionEventListener) => void; - attachEvent?: (type: string, listener: EventListener) => void; - - detachEvent?: (type: MouseEventTypes, listener: MouseEventListener) => void; - detachEvent?: (type: FocusEventTypes, listener: FocusEventListener) => void; - detachEvent?: (type: KeyboardEventTypes, listener: KeyboardEventListener) => void; - detachEvent?: (type: InputEventTypes, listener: InputEventListener) => void; - detachEvent?: (type: TouchEventTypes, listener: TouchEventListener) => void; - detachEvent?: (type: WheelEventTypes, listener: WheelEventListener) => void; - detachEvent?: (type: AbortProgressEventTypes, listener: AbortProgressEventListener) => void; - detachEvent?: (type: ProgressEventTypes, listener: ProgressEventListener) => void; - detachEvent?: (type: DragEventTypes, listener: DragEventListener) => void; - detachEvent?: (type: PointerEventTypes, listener: PointerEventListener) => void; - detachEvent?: (type: AnimationEventTypes, listener: AnimationEventListener) => void; - detachEvent?: (type: ClipboardEventTypes, listener: ClipboardEventListener) => void; - detachEvent?: (type: TransitionEventTypes, listener: TransitionEventListener) => void; - detachEvent?: (type: MessageEventTypes, listener: MessageEventListener) => void; - detachEvent?: (type: BeforeUnloadEventTypes, listener: BeforeUnloadEventListener) => void; - detachEvent?: (type: StorageEventTypes, listener: StorageEventListener) => void; - detachEvent?: (type: USBConnectionEventTypes, listener: USBConnectionEventListener) => void; - detachEvent?: (type: string, listener: EventListener) => void; - - dispatchEvent(evt: Event): boolean; - - // Deprecated - - cancelBubble: boolean; - initEvent(eventTypeArg: string, canBubbleArg: boolean, cancelableArg: boolean): void; -} - -// https://dom.spec.whatwg.org/#dictdef-eventinit -type Event$Init = { - bubbles?: boolean, - cancelable?: boolean, - composed?: boolean, - /** Non-standard. See `composed` instead. */ - scoped?: boolean, - ... -} - -// https://dom.spec.whatwg.org/#interface-event -declare class Event { - constructor(type: string, eventInitDict?: Event$Init): void; - /** - * Returns the type of event, e.g. "click", "hashchange", or "submit". - */ - +type: string; - /** - * Returns the object to which event is dispatched (its target). - */ - +target: EventTarget; // TODO: nullable - /** @deprecated */ - +srcElement: Element; // TODO: nullable - /** - * Returns the object whose event listener's callback is currently being invoked. - */ - +currentTarget: EventTarget; // TODO: nullable - /** - * Returns the invocation target objects of event's path (objects on which - * listeners will be invoked), except for any nodes in shadow trees of which - * the shadow root's mode is "closed" that are not reachable from event's - * currentTarget. - */ - composedPath(): Array; - - +NONE: number; - +AT_TARGET: number; - +BUBBLING_PHASE: number; - +CAPTURING_PHASE: number; - /** - * Returns the event's phase, which is one of NONE, CAPTURING_PHASE, AT_TARGET, - * and BUBBLING_PHASE. - */ - +eventPhase: number; - - /** - * When dispatched in a tree, invoking this method prevents event from reaching - * any objects other than the current object. - */ - stopPropagation(): void; - /** - * Invoking this method prevents event from reaching any registered event - * listeners after the current one finishes running and, when dispatched in a - * tree, also prevents event from reaching any other objects. - */ - stopImmediatePropagation(): void; - - /** - * Returns true or false depending on how event was initialized. True if - * event goes through its target's ancestors in reverse tree order, and - * false otherwise. - */ - +bubbles: boolean; - /** - * Returns true or false depending on how event was initialized. Its - * return value does not always carry meaning, but true can indicate - * that part of the operation during which event was dispatched, can - * be canceled by invoking the preventDefault() method. - */ - +cancelable: boolean; - // returnValue: boolean; // legacy, and some subclasses still define it as a string! - /** - * If invoked when the cancelable attribute value is true, and while - * executing a listener for the event with passive set to false, signals to - * the operation that caused event to be dispatched that it needs to be - * canceled. - */ - preventDefault(): void; - /** - * Returns true if preventDefault() was invoked successfully to indicate - * cancelation, and false otherwise. - */ - +defaultPrevented: boolean; - /** - * Returns true or false depending on how event was initialized. True if - * event invokes listeners past a ShadowRoot node that is the root of its - * target, and false otherwise. - */ - +composed: boolean; - - /** - * Returns true if event was dispatched by the user agent, and false otherwise. - */ - +isTrusted: boolean; - /** - * Returns the event's timestamp as the number of milliseconds measured relative - * to the time origin. - */ - +timeStamp: number; - - /** Non-standard. See Event.prototype.composedPath */ - +deepPath?: () => EventTarget[]; - /** Non-standard. See Event.prototype.composed */ - +scoped: boolean; - - /** - * @deprecated - */ - initEvent( - type: string, - bubbles: boolean, - cancelable: boolean - ): void; -} - -type CustomEvent$Init = { ...Event$Init, detail?: any, ... } - -declare class CustomEvent extends Event { - constructor(type: string, eventInitDict?: CustomEvent$Init): void; - detail: any; - - // deprecated - initCustomEvent( - type: string, - bubbles: boolean, - cancelable: boolean, - detail: any - ): CustomEvent; -} - -type UIEvent$Init = { ...Event$Init, detail?: number, view?: any, ... } - -declare class UIEvent extends Event { - constructor(typeArg: string, uiEventInit?: UIEvent$Init): void; - detail: number; - view: any; -} - -declare class CompositionEvent extends UIEvent { - data: string | null; - locale: string, -} - -type MouseEvent$MouseEventInit = { - screenX?: number, - screenY?: number, - clientX?: number, - clientY?: number, - ctrlKey?: boolean, - shiftKey?: boolean, - altKey?: boolean, - metaKey?: boolean, - button?: number, - buttons?: number, - region?: string | null, - relatedTarget?: EventTarget | null, - ... -}; - -declare class MouseEvent extends UIEvent { - constructor( - typeArg: string, - mouseEventInit?: MouseEvent$MouseEventInit, - ): void; - altKey: boolean; - button: number; - buttons: number; - clientX: number; - clientY: number; - ctrlKey: boolean; - metaKey: boolean; - movementX: number; - movementY: number; - offsetX: number; - offsetY: number; - pageX: number; - pageY: number; - region: string | null; - relatedTarget: EventTarget | null; - screenX: number; - screenY: number; - shiftKey: boolean; - x: number; - y: number; - getModifierState(keyArg: string): boolean; -} - -declare class FocusEvent extends UIEvent { - relatedTarget: ?EventTarget; -} - -type WheelEvent$Init = { - ...MouseEvent$MouseEventInit, - deltaX?: number, - deltaY?: number, - deltaZ?: number; - deltaMode?: 0x00 | 0x01 | 0x02, - ... -} - -declare class WheelEvent extends MouseEvent { - static +DOM_DELTA_PIXEL: 0x00; - static +DOM_DELTA_LINE: 0x01; - static +DOM_DELTA_PAGE: 0x02; - - constructor(type: string, eventInitDict?: WheelEvent$Init): void; - +deltaX: number; - +deltaY: number; - +deltaZ: number; - +deltaMode: 0x00 | 0x01 | 0x02; -} - -declare class DragEvent extends MouseEvent { - dataTransfer: ?DataTransfer; // readonly -} - -type PointerEvent$PointerEventInit = MouseEvent$MouseEventInit & { - pointerId?: number, - width?: number, - height?: number, - pressure?: number, - tangentialPressure?: number, - tiltX?: number, - tiltY?: number, - twist?: number, - pointerType?: string, - isPrimary?: boolean, - ... -}; - -declare class PointerEvent extends MouseEvent { - constructor( - typeArg: string, - pointerEventInit?: PointerEvent$PointerEventInit, - ): void; - pointerId: number; - width: number; - height: number; - pressure: number; - tangentialPressure: number; - tiltX: number; - tiltY: number; - twist: number; - pointerType: string; - isPrimary: boolean; -} - -declare class ProgressEvent extends Event { - lengthComputable: boolean; - loaded: number; - total: number; - - // Deprecated - initProgressEvent( - typeArg: string, - canBubbleArg: boolean, - cancelableArg: boolean, - lengthComputableArg: boolean, - loadedArg: number, - totalArg: number - ): void; -} - -declare class PromiseRejectionEvent extends Event { - promise: Promise; - reason: any; -} - -type PageTransitionEventInit = { - ...Event$Init, - persisted: boolean, - ... -} - -// https://html.spec.whatwg.org/multipage/browsing-the-web.html#the-pagetransitionevent-interface -declare class PageTransitionEvent extends Event { - constructor(type: string, init?: PageTransitionEventInit): void; - +persisted: boolean; -} - -// used for websockets and postMessage, for example. See: -// https://www.w3.org/TR/2011/WD-websockets-20110419/ -// and -// https://www.w3.org/TR/2008/WD-html5-20080610/comms.html -// and -// https://html.spec.whatwg.org/multipage/comms.html#the-messageevent-interfaces -declare class MessageEvent extends Event { - data: mixed; - origin: string; - lastEventId: string; - source: WindowProxy; -} - -// https://www.w3.org/TR/eventsource/ -declare class EventSource extends EventTarget { - constructor(url: string, configuration?: { withCredentials: boolean, ... }): void; - +CLOSED: 2; - +CONNECTING: 0; - +OPEN: 1; - +readyState: 0 | 1 | 2; - +url: string; - +withCredentials: boolean; - onerror: () => void; - onmessage: MessageEventListener; - onopen: () => void; - close: () => void; -} - -// https://w3c.github.io/uievents/#idl-keyboardeventinit -type KeyboardEvent$Init = { - ...UIEvent$Init, - /** - * Initializes the `key` attribute of the KeyboardEvent object to the unicode - * character string representing the meaning of a key after taking into - * account all keyboard modifiers (such as shift-state). This value is the - * final effective value of the key. If the key is not a printable character, - * then it should be one of the key values defined in [UIEvents-Key](https://www.w3.org/TR/uievents-key/). - * - * NOTE: not `null`, this results in `evt.key === 'null'`! - */ - key?: string | void, - /** - * Initializes the `code` attribute of the KeyboardEvent object to the unicode - * character string representing the key that was pressed, ignoring any - * keyboard modifications such as keyboard layout. This value should be one - * of the code values defined in [UIEvents-Code](https://www.w3.org/TR/uievents-code/). - * - * NOTE: not `null`, this results in `evt.code === 'null'`! - */ - code?: string | void, - /** - * Initializes the `location` attribute of the KeyboardEvent object to one of - * the following location numerical constants: - * - * DOM_KEY_LOCATION_STANDARD (numerical value 0) - * DOM_KEY_LOCATION_LEFT (numerical value 1) - * DOM_KEY_LOCATION_RIGHT (numerical value 2) - * DOM_KEY_LOCATION_NUMPAD (numerical value 3) - */ - location?: number, - /** - * Initializes the `ctrlKey` attribute of the KeyboardEvent object to true if - * the Control key modifier is to be considered active, false otherwise. - */ - ctrlKey?: boolean, - /** - * Initializes the `shiftKey` attribute of the KeyboardEvent object to true if - * the Shift key modifier is to be considered active, false otherwise. - */ - shiftKey?: boolean, - /** - * Initializes the `altKey` attribute of the KeyboardEvent object to true if - * the Alt (alternative) (or Option) key modifier is to be considered active, - * false otherwise. - */ - altKey?: boolean, - /** - * Initializes the `metaKey` attribute of the KeyboardEvent object to true if - * the Meta key modifier is to be considered active, false otherwise. - */ - metaKey?: boolean, - /** - * Initializes the `repeat` attribute of the KeyboardEvent object. This - * attribute should be set to true if the the current KeyboardEvent is - * considered part of a repeating sequence of similar events caused by the - * long depression of any single key, false otherwise. - */ - repeat?: boolean, - /** - * Initializes the `isComposing` attribute of the KeyboardEvent object. This - * attribute should be set to true if the event being constructed occurs as - * part of a composition sequence, false otherwise. - */ - isComposing?: boolean, - /** - * Initializes the `charCode` attribute of the KeyboardEvent to the Unicode - * code point for the event’s character. - */ - charCode?: number, - /** - * Initializes the `keyCode` attribute of the KeyboardEvent to the system- - * and implementation-dependent numerical code signifying the unmodified - * identifier associated with the key pressed. - */ - keyCode?: number, - /** Initializes the `which` attribute */ - which?: number, - ... -} - -// https://w3c.github.io/uievents/#idl-keyboardevent -declare class KeyboardEvent extends UIEvent { - constructor(typeArg: string, init?: KeyboardEvent$Init): void; - - /** `true` if the Alt (alternative) (or "Option") key modifier was active. */ - +altKey: boolean; - /** - * Holds a string that identifies the physical key being pressed. The value - * is not affected by the current keyboard layout or modifier state, so a - * particular key will always return the same value. - */ - +code: string; - /** `true` if the Control (control) key modifier was active. */ - +ctrlKey: boolean; - /** - * `true` if the key event occurs as part of a composition session, i.e., - * after a `compositionstart` event and before the corresponding - * `compositionend` event. - */ - +isComposing: boolean; - /** - * Holds a [key attribute value](https://www.w3.org/TR/uievents-key/#key-attribute-value) - * corresponding to the key pressed. */ - +key: string; - /** An indication of the logical location of the key on the device. */ - +location: number; - /** `true` if the meta (Meta) key (or "Command") modifier was active. */ - +metaKey: boolean; - /** `true` if the key has been pressed in a sustained manner. */ - +repeat: boolean; - /** `true` if the shift (Shift) key modifier was active. */ - +shiftKey: boolean; - - /** - * Queries the state of a modifier using a key value. - * - * Returns `true` if it is a modifier key and the modifier is activated, - * `false` otherwise. - */ - getModifierState(keyArg?: string): boolean; - - /** - * Holds a character value, for keypress events which generate character - * input. The value is the Unicode reference number (code point) of that - * character (e.g. event.charCode = event.key.charCodeAt(0) for printable - * characters). For keydown or keyup events, the value of charCode is 0. - * - * @deprecated You should use KeyboardEvent.key instead, if available. - */ - +charCode: number; - /** - * Holds a system- and implementation-dependent numerical code signifying - * the unmodified identifier associated with the key pressed. Unlike the - * `key` attribute, the set of possible values are not normatively defined. - * Typically, these value of the keyCode SHOULD represent the decimal - * codepoint in ASCII or Windows 1252, but MAY be drawn from a different - * appropriate character set. Implementations that are unable to identify - * a key use the key value 0. - * - * @deprecated You should use KeyboardEvent.key instead, if available. - */ - +keyCode: number; - /** - * Holds a system- and implementation-dependent numerical code signifying - * the unmodified identifier associated with the key pressed. In most cases, - * the value is identical to keyCode. - * - * @deprecated You should use KeyboardEvent.key instead, if available. - */ - +which: number; -} - -type InputEvent$Init = { - ...UIEvent$Init, - inputType?: string, - data?: string, - dataTransfer?: DataTransfer, - isComposing?: boolean, - ranges?: Array, // TODO: StaticRange - ... -} - -declare class InputEvent extends UIEvent { - constructor(typeArg: string, inputEventInit: InputEvent$Init): void; - +data: string | null; - +dataTransfer: DataTransfer | null; - +inputType: string; - +isComposing: boolean; - getTargetRanges(): Array; // TODO: StaticRange -} - -declare class AnimationEvent extends Event { - animationName: string; - elapsedTime: number; - pseudoElement: string; - - // deprecated - - initAnimationEvent: ( - type: 'animationstart' | 'animationend' | 'animationiteration', - canBubble: boolean, - cancelable: boolean, - animationName: string, - elapsedTime: number - ) => void; -} - -// https://html.spec.whatwg.org/multipage/webappapis.html#the-errorevent-interface -declare class ErrorEvent extends Event { - constructor( - type: string, - eventInitDict?: { - ...Event$Init, - message?: string, - filename?: string, - lineno?: number, - colno?: number, - error?: any, - ... - }, - ): void; - +message: string; - +filename: string; - +lineno: number; - +colno: number; - +error: any; -} - -// https://html.spec.whatwg.org/multipage/web-messaging.html#broadcasting-to-other-browsing-contexts -declare class BroadcastChannel extends EventTarget { - name: string; - onmessage: ?(event: MessageEvent) => void; - onmessageerror: ?(event: MessageEvent) => void; - - constructor(name: string): void; - postMessage(msg: mixed): void; - close(): void; -} - -// https://www.w3.org/TR/touch-events/#idl-def-Touch -declare class Touch { - clientX: number, - clientY: number, - identifier: number, - pageX: number, - pageY: number, - screenX: number, - screenY: number, - target: EventTarget, -} - -// https://www.w3.org/TR/touch-events/#idl-def-TouchList -// TouchList#item(index) will return null if n > #length. Should #item's -// return type just been Touch? -declare class TouchList { - @@iterator(): Iterator; - length: number, - item(index: number): null | Touch, - [index: number]: Touch, -} - -// https://www.w3.org/TR/touch-events/#touchevent-interface -declare class TouchEvent extends UIEvent { - altKey: boolean, - changedTouches: TouchList, - ctrlKey: boolean, - metaKey: boolean, - shiftKey: boolean, - targetTouches: TouchList, - touches: TouchList, -} - -// https://www.w3.org/TR/webstorage/#the-storageevent-interface -declare class StorageEvent extends Event { - key: ?string, - oldValue: ?string, - newValue: ?string, - url: string, - storageArea: ?Storage, -} - -// https://www.w3.org/TR/clipboard-apis/#typedefdef-clipboarditemdata -// Raw string | Blob are allowed per https://webidl.spec.whatwg.org/#es-promise -type ClipboardItemData = string | Blob | Promise; - -type PresentationStyle = "attachment" | "inline" | "unspecified"; - -type ClipboardItemOptions = { - presentationStyle?: PresentationStyle; - ... -} - -declare class ClipboardItem { - +types: $ReadOnlyArray; - getType(type: string): Promise; - constructor(items: {[type: string]: ClipboardItemData}, options?: ClipboardItemOptions): void; -} - -// https://w3c.github.io/clipboard-apis/ as of 15 May 2018 -type ClipboardEvent$Init = { - ...Event$Init, - clipboardData: DataTransfer | null, - ... -}; - -declare class ClipboardEvent extends Event { - constructor(type: ClipboardEventTypes, eventInit?: ClipboardEvent$Init): void; - +clipboardData: ?DataTransfer; // readonly -} - -// https://www.w3.org/TR/2017/WD-css-transitions-1-20171130/#interface-transitionevent -type TransitionEvent$Init = { - ...Event$Init, - propertyName: string, - elapsedTime: number, - pseudoElement: string, - ... -}; - -declare class TransitionEvent extends Event { - constructor(type: TransitionEventTypes, eventInit?: TransitionEvent$Init): void; - - +propertyName: string; // readonly - +elapsedTime: number; // readonly - +pseudoElement: string; // readonly -} - -// https://www.w3.org/TR/html50/browsers.html#beforeunloadevent -declare class BeforeUnloadEvent extends Event { - returnValue: string, -} - -declare class SecurityPolicyViolationEvent extends Event { - +documentURI: string; - +referrer: string; - +blockedURI: string; - +effectiveDirective: string; - +violatedDirective: string; - +originalPolicy: string; - +sourceFile: string; - +sample: string; - +disposition: "enforce" | "report"; - +statusCode: number; - +lineNumber: number; - +columnNumber: number; -}; - -// https://developer.mozilla.org/en-US/docs/Web/API/USBConnectionEvent -declare class USBConnectionEvent extends Event { - device: USBDevice, -} - -// TODO: *Event - -declare class Node extends EventTarget { - baseURI: ?string; - childNodes: NodeList; - firstChild: ?Node; - +isConnected: boolean; - lastChild: ?Node; - nextSibling: ?Node; - nodeName: string; - nodeType: number; - nodeValue: string; - ownerDocument: Document; - parentElement: ?Element; - parentNode: ?Node; - previousSibling: ?Node; - rootNode: Node; - textContent: string; - appendChild(newChild: T): T; - cloneNode(deep?: boolean): this; - compareDocumentPosition(other: Node): number; - contains(other: ?Node): boolean; - getRootNode(options?: { composed: boolean, ... }): Node; - hasChildNodes(): boolean; - insertBefore(newChild: T, refChild?: ?Node): T; - isDefaultNamespace(namespaceURI: string): boolean; - isEqualNode(arg: Node): boolean; - isSameNode(other: Node): boolean; - lookupNamespaceURI(prefix: string): string; - lookupPrefix(namespaceURI: string): string; - normalize(): void; - removeChild(oldChild: T): T; - replaceChild(newChild: Node, oldChild: T): T; - replaceChildren(...nodes: $ReadOnlyArray): void; - static ATTRIBUTE_NODE: number; - static CDATA_SECTION_NODE: number; - static COMMENT_NODE: number; - static DOCUMENT_FRAGMENT_NODE: number; - static DOCUMENT_NODE: number; - static DOCUMENT_POSITION_CONTAINED_BY: number; - static DOCUMENT_POSITION_CONTAINS: number; - static DOCUMENT_POSITION_DISCONNECTED: number; - static DOCUMENT_POSITION_FOLLOWING: number; - static DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; - static DOCUMENT_POSITION_PRECEDING: number; - static DOCUMENT_TYPE_NODE: number; - static ELEMENT_NODE: number; - static ENTITY_NODE: number; - static ENTITY_REFERENCE_NODE: number; - static NOTATION_NODE: number; - static PROCESSING_INSTRUCTION_NODE: number; - static TEXT_NODE: number; - - // Non-standard - innerText?: string; - outerText?: string; -} - -declare class NodeList { - @@iterator(): Iterator; - length: number; - item(index: number): T; - [index: number]: T; - - forEach(callbackfn: (this : This, value: T, index: number, list: NodeList) => any, thisArg: This): void; - entries(): Iterator<[number, T]>; - keys(): Iterator; - values(): Iterator; -} - -declare class NamedNodeMap { - @@iterator(): Iterator; - length: number; - removeNamedItemNS(namespaceURI: string, localName: string): Attr; - item(index: number): Attr; - [index: number | string]: Attr; - removeNamedItem(name: string): Attr; - getNamedItem(name: string): Attr; - setNamedItem(arg: Attr): Attr; - getNamedItemNS(namespaceURI: string, localName: string): Attr; - setNamedItemNS(arg: Attr): Attr; -} - -declare class Attr extends Node { - isId: boolean; - specified: boolean; - ownerElement: Element | null; - value: string; - name: string; - namespaceURI: string | null; - prefix: string | null; - localName: string; -} - -declare class HTMLCollection<+Elem: HTMLElement> { - @@iterator(): Iterator; - length: number; - item(nameOrIndex?: any, optionalIndex?: any): Elem | null; - namedItem(name: string): Elem | null; - [index: number | string]: Elem; -} - -// from https://www.w3.org/TR/custom-elements/#extensions-to-document-interface-to-register -// See also https://github.com/w3c/webcomponents/ -type ElementRegistrationOptions = { - +prototype?: { - // from https://www.w3.org/TR/custom-elements/#types-of-callbacks - // See also https://github.com/w3c/webcomponents/ - +createdCallback?: () => mixed, - +attachedCallback?: () => mixed, - +detachedCallback?: () => mixed, - +attributeChangedCallback?: - // attribute is set - (( - attributeLocalName: string, - oldAttributeValue: null, - newAttributeValue: string, - attributeNamespace: string - ) => mixed) & - // attribute is changed - (( - attributeLocalName: string, - oldAttributeValue: string, - newAttributeValue: string, - attributeNamespace: string - ) => mixed) & - // attribute is removed - (( - attributeLocalName: string, - oldAttributeValue: string, - newAttributeValue: null, - attributeNamespace: string - ) => mixed), - ... - }, - +extends?: string, - ... -} - -type ElementCreationOptions = { is: string, ...} - -declare class Document extends Node { - +timeline: DocumentTimeline; - getAnimations(): Array; - +URL: string; - adoptNode(source: T): T; - anchors: HTMLCollection; - applets: HTMLCollection; - body: HTMLBodyElement | null; - +characterSet: string; - /** - * Legacy alias of `characterSet` - * @deprecated - */ - +charset: string; - close(): void; - +contentType: string; - cookie: string; - createAttribute(name: string): Attr; - createAttributeNS(namespaceURI: string | null, qualifiedName: string): Attr; - createCDATASection(data: string): Text; - createComment(data: string): Comment; - createDocumentFragment(): DocumentFragment; - createElement(tagName: 'a', options?: ElementCreationOptions): HTMLAnchorElement; - createElement(tagName: 'area', options?: ElementCreationOptions): HTMLAreaElement; - createElement(tagName: 'audio', options?: ElementCreationOptions): HTMLAudioElement; - createElement(tagName: 'blockquote', options?: ElementCreationOptions): HTMLQuoteElement; - createElement(tagName: 'body', options?: ElementCreationOptions): HTMLBodyElement; - createElement(tagName: 'br', options?: ElementCreationOptions): HTMLBRElement; - createElement(tagName: 'button', options?: ElementCreationOptions): HTMLButtonElement; - createElement(tagName: 'canvas', options?: ElementCreationOptions): HTMLCanvasElement; - createElement(tagName: 'col', options?: ElementCreationOptions): HTMLTableColElement; - createElement(tagName: 'colgroup', options?: ElementCreationOptions): HTMLTableColElement; - createElement(tagName: 'data', options?: ElementCreationOptions): HTMLDataElement; - createElement(tagName: 'datalist', options?: ElementCreationOptions): HTMLDataListElement; - createElement(tagName: 'del', options?: ElementCreationOptions): HTMLModElement; - createElement(tagName: 'details', options?: ElementCreationOptions): HTMLDetailsElement; - createElement(tagName: 'dialog', options?: ElementCreationOptions): HTMLDialogElement; - createElement(tagName: 'div', options?: ElementCreationOptions): HTMLDivElement; - createElement(tagName: 'dl', options?: ElementCreationOptions): HTMLDListElement; - createElement(tagName: 'embed', options?: ElementCreationOptions): HTMLEmbedElement; - createElement(tagName: 'fieldset', options?: ElementCreationOptions): HTMLFieldSetElement; - createElement(tagName: 'form', options?: ElementCreationOptions): HTMLFormElement; - createElement(tagName: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6', options?: ElementCreationOptions): HTMLHeadingElement; - createElement(tagName: 'head', options?: ElementCreationOptions): HTMLHeadElement; - createElement(tagName: 'hr', options?: ElementCreationOptions): HTMLHRElement; - createElement(tagName: 'html', options?: ElementCreationOptions): HTMLHtmlElement; - createElement(tagName: 'iframe', options?: ElementCreationOptions): HTMLIFrameElement; - createElement(tagName: 'img', options?: ElementCreationOptions): HTMLImageElement; - createElement(tagName: 'input', options?: ElementCreationOptions): HTMLInputElement; - createElement(tagName: 'ins', options?: ElementCreationOptions): HTMLModElement; - createElement(tagName: 'label', options?: ElementCreationOptions): HTMLLabelElement; - createElement(tagName: 'legend', options?: ElementCreationOptions): HTMLLegendElement; - createElement(tagName: 'li', options?: ElementCreationOptions): HTMLLIElement; - createElement(tagName: 'link', options?: ElementCreationOptions): HTMLLinkElement; - createElement(tagName: 'map', options?: ElementCreationOptions): HTMLMapElement; - createElement(tagName: 'meta', options?: ElementCreationOptions): HTMLMetaElement; - createElement(tagName: 'meter', options?: ElementCreationOptions): HTMLMeterElement; - createElement(tagName: 'object', options?: ElementCreationOptions): HTMLObjectElement; - createElement(tagName: 'ol', options?: ElementCreationOptions): HTMLOListElement; - createElement(tagName: 'optgroup', options?: ElementCreationOptions): HTMLOptGroupElement; - createElement(tagName: 'option', options?: ElementCreationOptions): HTMLOptionElement; - createElement(tagName: 'p', options?: ElementCreationOptions): HTMLParagraphElement; - createElement(tagName: 'param', options?: ElementCreationOptions): HTMLParamElement; - createElement(tagName: 'picture', options?: ElementCreationOptions): HTMLPictureElement; - createElement(tagName: 'pre', options?: ElementCreationOptions): HTMLPreElement; - createElement(tagName: 'progress', options?: ElementCreationOptions): HTMLProgressElement; - createElement(tagName: 'q', options?: ElementCreationOptions): HTMLQuoteElement; - createElement(tagName: 'script', options?: ElementCreationOptions): HTMLScriptElement; - createElement(tagName: 'select', options?: ElementCreationOptions): HTMLSelectElement; - createElement(tagName: 'source', options?: ElementCreationOptions): HTMLSourceElement; - createElement(tagName: 'span', options?: ElementCreationOptions): HTMLSpanElement; - createElement(tagName: 'style', options?: ElementCreationOptions): HTMLStyleElement; - createElement(tagName: 'textarea', options?: ElementCreationOptions): HTMLTextAreaElement; - createElement(tagName: 'time', options?: ElementCreationOptions): HTMLTimeElement; - createElement(tagName: 'title', options?: ElementCreationOptions): HTMLTitleElement; - createElement(tagName: 'track', options?: ElementCreationOptions): HTMLTrackElement; - createElement(tagName: 'video', options?: ElementCreationOptions): HTMLVideoElement; - createElement(tagName: 'table', options?: ElementCreationOptions): HTMLTableElement; - createElement(tagName: 'caption', options?: ElementCreationOptions): HTMLTableCaptionElement; - createElement(tagName: 'thead' | 'tfoot' | 'tbody', options?: ElementCreationOptions): HTMLTableSectionElement; - createElement(tagName: 'tr', options?: ElementCreationOptions): HTMLTableRowElement; - createElement(tagName: 'td' | 'th', options?: ElementCreationOptions): HTMLTableCellElement; - createElement(tagName: 'template', options?: ElementCreationOptions): HTMLTemplateElement; - createElement(tagName: 'ul', options?: ElementCreationOptions): HTMLUListElement; - createElement(tagName: string, options?: ElementCreationOptions): HTMLElement; - createElementNS(namespaceURI: string | null, qualifiedName: string, options?: ElementCreationOptions): Element; - createTextNode(data: string): Text; - currentScript: HTMLScriptElement | null; - dir: 'rtl' | 'ltr'; - +doctype: DocumentType | null; - +documentElement: HTMLElement | null; - documentMode: number; - +documentURI: string; - domain: string | null; - embeds: HTMLCollection; - exitFullscreen(): Promise, - queryCommandSupported(cmdID: string): boolean; - execCommand(cmdID: string, showUI?: boolean, value?: any): boolean; - forms: HTMLCollection; - fullscreenElement: Element | null; - fullscreenEnabled: boolean; - getElementsByClassName(classNames: string): HTMLCollection; - getElementsByName(elementName: string): HTMLCollection; - getElementsByTagName(name: 'a'): HTMLCollection; - getElementsByTagName(name: 'area'): HTMLCollection; - getElementsByTagName(name: 'audio'): HTMLCollection; - getElementsByTagName(name: 'blockquote'): HTMLCollection; - getElementsByTagName(name: 'body'): HTMLCollection; - getElementsByTagName(name: 'br'): HTMLCollection; - getElementsByTagName(name: 'button'): HTMLCollection; - getElementsByTagName(name: 'canvas'): HTMLCollection; - getElementsByTagName(name: 'col'): HTMLCollection; - getElementsByTagName(name: 'colgroup'): HTMLCollection; - getElementsByTagName(name: 'data'): HTMLCollection; - getElementsByTagName(name: 'datalist'): HTMLCollection; - getElementsByTagName(name: 'del'): HTMLCollection; - getElementsByTagName(name: 'details'): HTMLCollection; - getElementsByTagName(name: 'dialog'): HTMLCollection; - getElementsByTagName(name: 'div'): HTMLCollection; - getElementsByTagName(name: 'dl'): HTMLCollection; - getElementsByTagName(name: 'embed'): HTMLCollection; - getElementsByTagName(name: 'fieldset'): HTMLCollection; - getElementsByTagName(name: 'form'): HTMLCollection; - getElementsByTagName(name: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'): HTMLCollection; - getElementsByTagName(name: 'head'): HTMLCollection; - getElementsByTagName(name: 'hr'): HTMLCollection; - getElementsByTagName(name: 'html'): HTMLCollection; - getElementsByTagName(name: 'iframe'): HTMLCollection; - getElementsByTagName(name: 'img'): HTMLCollection; - getElementsByTagName(name: 'input'): HTMLCollection; - getElementsByTagName(name: 'ins'): HTMLCollection; - getElementsByTagName(name: 'label'): HTMLCollection; - getElementsByTagName(name: 'legend'): HTMLCollection; - getElementsByTagName(name: 'li'): HTMLCollection; - getElementsByTagName(name: 'link'): HTMLCollection; - getElementsByTagName(name: 'map'): HTMLCollection; - getElementsByTagName(name: 'meta'): HTMLCollection; - getElementsByTagName(name: 'meter'): HTMLCollection; - getElementsByTagName(name: 'object'): HTMLCollection; - getElementsByTagName(name: 'ol'): HTMLCollection; - getElementsByTagName(name: 'option'): HTMLCollection; - getElementsByTagName(name: 'optgroup'): HTMLCollection; - getElementsByTagName(name: 'p'): HTMLCollection; - getElementsByTagName(name: 'param'): HTMLCollection; - getElementsByTagName(name: 'picture'): HTMLCollection; - getElementsByTagName(name: 'pre'): HTMLCollection; - getElementsByTagName(name: 'progress'): HTMLCollection; - getElementsByTagName(name: 'q'): HTMLCollection; - getElementsByTagName(name: 'script'): HTMLCollection; - getElementsByTagName(name: 'select'): HTMLCollection; - getElementsByTagName(name: 'source'): HTMLCollection; - getElementsByTagName(name: 'span'): HTMLCollection; - getElementsByTagName(name: 'style'): HTMLCollection; - getElementsByTagName(name: 'textarea'): HTMLCollection; - getElementsByTagName(name: 'time'): HTMLCollection; - getElementsByTagName(name: 'title'): HTMLCollection; - getElementsByTagName(name: 'track'): HTMLCollection; - getElementsByTagName(name: 'video'): HTMLCollection; - getElementsByTagName(name: 'table'): HTMLCollection; - getElementsByTagName(name: 'caption'): HTMLCollection; - getElementsByTagName(name: 'thead' | 'tfoot' | 'tbody'): HTMLCollection; - getElementsByTagName(name: 'tr'): HTMLCollection; - getElementsByTagName(name: 'td' | 'th'): HTMLCollection; - getElementsByTagName(name: 'template'): HTMLCollection; - getElementsByTagName(name: 'ul'): HTMLCollection; - getElementsByTagName(name: string): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'a'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'area'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'audio'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'blockquote'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'body'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'br'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'button'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'canvas'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'col'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'colgroup'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'data'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'datalist'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'del'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'details'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'dialog'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'div'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'dl'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'embed'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'fieldset'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'form'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'head'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'hr'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'html'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'iframe'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'img'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'input'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'ins'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'label'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'legend'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'li'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'link'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'map'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'meta'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'meter'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'object'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'ol'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'option'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'optgroup'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'p'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'param'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'picture'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'pre'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'progress'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'q'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'script'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'select'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'source'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'span'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'style'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'textarea'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'time'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'title'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'track'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'video'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'table'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'caption'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'thead' | 'tfoot' | 'tbody'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'tr'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'td' | 'th'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'template'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'ul'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: string): HTMLCollection; - head: HTMLHeadElement | null; - images: HTMLCollection; - +implementation: DOMImplementation; - importNode(importedNode: T, deep: boolean): T; - /** - * Legacy alias of `characterSet` - * @deprecated - */ - +inputEncoding: string; - lastModified: string; - links: HTMLCollection; - media: string; - open(url?: string, name?: string, features?: string, replace?: boolean): any; - readyState: string; - referrer: string; - scripts: HTMLCollection; - scrollingElement: HTMLElement | null; - title: string; - visibilityState: 'visible' | 'hidden' | 'prerender' | 'unloaded'; - write(...content: Array): void; - writeln(...content: Array): void; - xmlEncoding: string; - xmlStandalone: boolean; - xmlVersion: string; - - registerElement(type: string, options?: ElementRegistrationOptions): any; - getSelection(): Selection | null; - - // 6.4.6 Focus management APIs - activeElement: HTMLElement | null; - hasFocus(): boolean; - - // extension - location: Location; - createEvent(eventInterface: 'CustomEvent'): CustomEvent; - createEvent(eventInterface: string): Event; - createRange(): Range; - elementFromPoint(x: number, y: number): HTMLElement | null; - elementsFromPoint(x: number, y: number): Array; - defaultView: any; - +compatMode: 'BackCompat' | 'CSS1Compat'; - hidden: boolean; - - // Pointer Lock specification - exitPointerLock(): void; - pointerLockElement: Element | null; - - // from ParentNode interface - childElementCount: number; - children: HTMLCollection; - firstElementChild: ?Element; - lastElementChild: ?Element; - append(...nodes: Array): void; - prepend(...nodes: Array): void; - - querySelector(selector: 'a'): HTMLAnchorElement | null; - querySelector(selector: 'area'): HTMLAreaElement | null; - querySelector(selector: 'audio'): HTMLAudioElement | null; - querySelector(selector: 'blockquote'): HTMLQuoteElement | null; - querySelector(selector: 'body'): HTMLBodyElement | null; - querySelector(selector: 'br'): HTMLBRElement | null; - querySelector(selector: 'button'): HTMLButtonElement | null; - querySelector(selector: 'canvas'): HTMLCanvasElement | null; - querySelector(selector: 'col'): HTMLTableColElement | null; - querySelector(selector: 'colgroup'): HTMLTableColElement | null; - querySelector(selector: 'data'): HTMLDataElement | null; - querySelector(selector: 'datalist'): HTMLDataListElement | null; - querySelector(selector: 'del'): HTMLModElement | null; - querySelector(selector: 'details'): HTMLDetailsElement | null; - querySelector(selector: 'dialog'): HTMLDialogElement | null; - querySelector(selector: 'div'): HTMLDivElement | null; - querySelector(selector: 'dl'): HTMLDListElement | null; - querySelector(selector: 'embed'): HTMLEmbedElement | null; - querySelector(selector: 'fieldset'): HTMLFieldSetElement | null; - querySelector(selector: 'form'): HTMLFormElement | null; - querySelector(selector: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'): HTMLHeadingElement; - querySelector(selector: 'head'): HTMLHeadElement | null; - querySelector(selector: 'hr'): HTMLHRElement | null; - querySelector(selector: 'html'): HTMLHtmlElement | null; - querySelector(selector: 'iframe'): HTMLIFrameElement | null; - querySelector(selector: 'img'): HTMLImageElement | null; - querySelector(selector: 'ins'): HTMLModElement | null; - querySelector(selector: 'input'): HTMLInputElement | null; - querySelector(selector: 'label'): HTMLLabelElement | null; - querySelector(selector: 'legend'): HTMLLegendElement | null; - querySelector(selector: 'li'): HTMLLIElement | null; - querySelector(selector: 'link'): HTMLLinkElement | null; - querySelector(selector: 'map'): HTMLMapElement | null; - querySelector(selector: 'meta'): HTMLMetaElement | null; - querySelector(selector: 'meter'): HTMLMeterElement | null; - querySelector(selector: 'object'): HTMLObjectElement | null; - querySelector(selector: 'ol'): HTMLOListElement | null; - querySelector(selector: 'option'): HTMLOptionElement | null; - querySelector(selector: 'optgroup'): HTMLOptGroupElement | null; - querySelector(selector: 'p'): HTMLParagraphElement | null; - querySelector(selector: 'param'): HTMLParamElement | null; - querySelector(selector: 'picture'): HTMLPictureElement | null; - querySelector(selector: 'pre'): HTMLPreElement | null; - querySelector(selector: 'progress'): HTMLProgressElement | null; - querySelector(selector: 'q'): HTMLQuoteElement | null; - querySelector(selector: 'script'): HTMLScriptElement | null; - querySelector(selector: 'select'): HTMLSelectElement | null; - querySelector(selector: 'source'): HTMLSourceElement | null; - querySelector(selector: 'span'): HTMLSpanElement | null; - querySelector(selector: 'style'): HTMLStyleElement | null; - querySelector(selector: 'textarea'): HTMLTextAreaElement | null; - querySelector(selector: 'time'): HTMLTimeElement | null; - querySelector(selector: 'title'): HTMLTitleElement | null; - querySelector(selector: 'track'): HTMLTrackElement | null; - querySelector(selector: 'video'): HTMLVideoElement | null; - querySelector(selector: 'table'): HTMLTableElement | null; - querySelector(selector: 'caption'): HTMLTableCaptionElement | null; - querySelector(selector: 'thead' | 'tfoot' | 'tbody'): HTMLTableSectionElement | null; - querySelector(selector: 'tr'): HTMLTableRowElement | null; - querySelector(selector: 'td' | 'th'): HTMLTableCellElement | null; - querySelector(selector: 'template'): HTMLTemplateElement | null; - querySelector(selector: 'ul'): HTMLUListElement | null; - querySelector(selector: string): HTMLElement | null; - - querySelectorAll(selector: 'a'): NodeList; - querySelectorAll(selector: 'area'): NodeList; - querySelectorAll(selector: 'audio'): NodeList; - querySelectorAll(selector: 'blockquote'): NodeList; - querySelectorAll(selector: 'body'): NodeList; - querySelectorAll(selector: 'br'): NodeList; - querySelectorAll(selector: 'button'): NodeList; - querySelectorAll(selector: 'canvas'): NodeList; - querySelectorAll(selector: 'col'): NodeList; - querySelectorAll(selector: 'colgroup'): NodeList; - querySelectorAll(selector: 'data'): NodeList; - querySelectorAll(selector: 'datalist'): NodeList; - querySelectorAll(selector: 'del'): NodeList; - querySelectorAll(selector: 'details'): NodeList; - querySelectorAll(selector: 'dialog'): NodeList; - querySelectorAll(selector: 'div'): NodeList; - querySelectorAll(selector: 'dl'): NodeList; - querySelectorAll(selector: 'embed'): NodeList; - querySelectorAll(selector: 'fieldset'): NodeList; - querySelectorAll(selector: 'form'): NodeList; - querySelectorAll(selector: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'): NodeList; - querySelectorAll(selector: 'head'): NodeList; - querySelectorAll(selector: 'hr'): NodeList; - querySelectorAll(selector: 'html'): NodeList; - querySelectorAll(selector: 'iframe'): NodeList; - querySelectorAll(selector: 'img'): NodeList; - querySelectorAll(selector: 'input'): NodeList; - querySelectorAll(selector: 'ins'): NodeList; - querySelectorAll(selector: 'label'): NodeList; - querySelectorAll(selector: 'legend'): NodeList; - querySelectorAll(selector: 'li'): NodeList; - querySelectorAll(selector: 'link'): NodeList; - querySelectorAll(selector: 'map'): NodeList; - querySelectorAll(selector: 'meta'): NodeList; - querySelectorAll(selector: 'meter'): NodeList; - querySelectorAll(selector: 'object'): NodeList; - querySelectorAll(selector: 'ol'): NodeList; - querySelectorAll(selector: 'option'): NodeList; - querySelectorAll(selector: 'optgroup'): NodeList; - querySelectorAll(selector: 'p'): NodeList; - querySelectorAll(selector: 'param'): NodeList; - querySelectorAll(selector: 'picture'): NodeList; - querySelectorAll(selector: 'pre'): NodeList; - querySelectorAll(selector: 'progress'): NodeList; - querySelectorAll(selector: 'q'): NodeList; - querySelectorAll(selector: 'script'): NodeList; - querySelectorAll(selector: 'select'): NodeList; - querySelectorAll(selector: 'source'): NodeList; - querySelectorAll(selector: 'span'): NodeList; - querySelectorAll(selector: 'style'): NodeList; - querySelectorAll(selector: 'textarea'): NodeList; - querySelectorAll(selector: 'time'): NodeList; - querySelectorAll(selector: 'title'): NodeList; - querySelectorAll(selector: 'track'): NodeList; - querySelectorAll(selector: 'video'): NodeList; - querySelectorAll(selector: 'table'): NodeList; - querySelectorAll(selector: 'caption'): NodeList; - querySelectorAll(selector: 'thead' | 'tfoot' | 'tbody'): NodeList; - querySelectorAll(selector: 'tr'): NodeList; - querySelectorAll(selector: 'td' | 'th'): NodeList; - querySelectorAll(selector: 'template'): NodeList; - querySelectorAll(selector: 'ul'): NodeList; - querySelectorAll(selector: string): NodeList; - - // Interface DocumentTraversal - // http://www.w3.org/TR/2000/REC-DOM-Level-2-Traversal-Range-20001113/traversal.html#Traversal-Document - - // Not all combinations of RootNodeT and whatToShow are logically possible. - // The bitmasks NodeFilter.SHOW_CDATA_SECTION, - // NodeFilter.SHOW_ENTITY_REFERENCE, NodeFilter.SHOW_ENTITY, and - // NodeFilter.SHOW_NOTATION are deprecated and do not correspond to types - // that Flow knows about. - - // NodeFilter.SHOW_ATTRIBUTE is also deprecated, but corresponds to the - // type Attr. While there is no reason to prefer it to Node.attributes, - // it does have meaning and can be typed: When (whatToShow & - // NodeFilter.SHOW_ATTRIBUTE === 1), RootNodeT must be Attr, and when - // RootNodeT is Attr, bitmasks other than NodeFilter.SHOW_ATTRIBUTE are - // meaningless. - createNodeIterator(root: RootNodeT, whatToShow: 2, filter?: NodeFilterInterface): NodeIterator; - createTreeWalker(root: RootNodeT, whatToShow: 2, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - - // NodeFilter.SHOW_PROCESSING_INSTRUCTION is not implemented because Flow - // does not currently define a ProcessingInstruction class. - - // When (whatToShow & NodeFilter.SHOW_DOCUMENT === 1 || whatToShow & - // NodeFilter.SHOW_DOCUMENT_TYPE === 1), RootNodeT must be Document. - createNodeIterator(root: RootNodeT, whatToShow: 256, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 257, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 260, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 261, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 384, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 385, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 388, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 389, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 512, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 513, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 516, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 517, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 640, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 641, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 644, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 645, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 768, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 769, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 772, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 773, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 896, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 897, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 900, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 901, filter?: NodeFilterInterface): NodeIterator; - createTreeWalker(root: RootNodeT, whatToShow: 256, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 257, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 260, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 261, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 384, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 385, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 388, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 389, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 512, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 513, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 516, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 517, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 640, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 641, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 644, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 645, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 768, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 769, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 772, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 773, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 896, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 897, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 900, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 901, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - - // When (whatToShow & NodeFilter.SHOW_DOCUMENT_FRAGMENT === 1), RootNodeT - // must be a DocumentFragment. - createNodeIterator(root: RootNodeT, whatToShow: 1024, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 1025, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 1028, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 1029, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 1152, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 1153, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 1156, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 1157, filter?: NodeFilterInterface): NodeIterator; - createTreeWalker(root: RootNodeT, whatToShow: 1024, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 1025, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 1028, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 1029, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 1152, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 1153, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 1156, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 1157, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - - // In the general case, RootNodeT may be any Node and whatToShow may be - // NodeFilter.SHOW_ALL or any combination of NodeFilter.SHOW_ELEMENT, - // NodeFilter.SHOW_TEXT and/or NodeFilter.SHOW_COMMENT - createNodeIterator(root: RootNodeT, whatToShow: 1, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 4, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 5, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 128, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 129, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 132, filter?: NodeFilterInterface): NodeIterator; - createNodeIterator(root: RootNodeT, whatToShow: 133, filter?: NodeFilterInterface): NodeIterator; - createTreeWalker(root: RootNodeT, whatToShow: 1, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 4, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 5, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 128, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 129, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 132, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - createTreeWalker(root: RootNodeT, whatToShow: 133, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - - // Catch all for when we don't know the value of `whatToShow` - // And for when whatToShow is not provided, it is assumed to be SHOW_ALL - createNodeIterator(root: RootNodeT, whatToShow?: number, filter?: NodeFilterInterface): NodeIterator; - createTreeWalker(root: RootNodeT, whatToShow?: number, filter?: NodeFilterInterface, entityReferenceExpansion?: boolean): TreeWalker; - - // From NonElementParentNode Mixin. - getElementById(elementId: string): HTMLElement | null; - - // From DocumentOrShadowRoot Mixin. - +styleSheets: StyleSheetList; - adoptedStyleSheets: Array; -} - -declare class DocumentFragment extends Node { - // from ParentNode interface - childElementCount: number; - children: HTMLCollection; - firstElementChild: ?Element; - lastElementChild: ?Element; - append(...nodes: Array): void; - prepend(...nodes: Array): void; - - querySelector(selector: string): HTMLElement | null; - querySelectorAll(selector: string): NodeList; - - // From NonElementParentNode Mixin. - getElementById(elementId: string): HTMLElement | null; -} - -declare class Selection { - anchorNode: Node | null; - anchorOffset: number; - focusNode: Node | null; - focusOffset: number; - isCollapsed: boolean; - rangeCount: number; - type: string; - addRange(range: Range): void; - getRangeAt(index: number): Range; - removeRange(range: Range): void; - removeAllRanges(): void; - collapse(parentNode: Node | null, offset?: number): void; - collapseToStart(): void; - collapseToEnd(): void; - containsNode(aNode: Node, aPartlyContained?: boolean): boolean; - deleteFromDocument(): void; - extend(parentNode: Node, offset?: number): void; - empty(): void; - selectAllChildren(parentNode: Node): void; - setPosition(aNode: Node | null, offset?: number): void; - setBaseAndExtent(anchorNode: Node, anchorOffset: number, focusNode: Node, focusOffset: number): void; - toString(): string; -} - -declare class Range { // extension - startOffset: number; - collapsed: boolean; - endOffset: number; - startContainer: Node; - endContainer: Node; - commonAncestorContainer: Node; - setStart(refNode: Node, offset: number): void; - setEndBefore(refNode: Node): void; - setStartBefore(refNode: Node): void; - selectNode(refNode: Node): void; - detach(): void; - getBoundingClientRect(): DOMRect; - toString(): string; - compareBoundaryPoints(how: number, sourceRange: Range): number; - insertNode(newNode: Node): void; - collapse(toStart: boolean): void; - selectNodeContents(refNode: Node): void; - cloneContents(): DocumentFragment; - setEnd(refNode: Node, offset: number): void; - cloneRange(): Range; - getClientRects(): DOMRectList; - surroundContents(newParent: Node): void; - deleteContents(): void; - setStartAfter(refNode: Node): void; - extractContents(): DocumentFragment; - setEndAfter(refNode: Node): void; - createContextualFragment(fragment: string | TrustedHTML): DocumentFragment; - intersectsNode(refNode: Node): boolean; - isPointInRange(refNode: Node, offset: number): boolean; - static END_TO_END: number; - static START_TO_START: number; - static START_TO_END: number; - static END_TO_START: number; -} - -declare var document: Document; - -// TODO: HTMLDocument -type FocusOptions = { preventScroll?: boolean, ... } - -declare class DOMTokenList { - @@iterator(): Iterator; - length: number; - item(index: number): string; - contains(token: string): boolean; - add(...token: Array): void; - remove(...token: Array): void; - toggle(token: string, force?: boolean): boolean; - replace(oldToken: string, newToken: string): boolean; - - forEach(callbackfn: (value: string, index: number, list: DOMTokenList) => any, thisArg?: any): void; - entries(): Iterator<[number, string]>; - keys(): Iterator; - values(): Iterator; - [index: number]: string; -} - - -declare class Element extends Node implements Animatable { - animate(keyframes: Keyframe[] | PropertyIndexedKeyframes | null, options?: number | KeyframeAnimationOptions): Animation; - getAnimations(options?: GetAnimationsOptions): Animation[]; - assignedSlot: ?HTMLSlotElement; - attachShadow(shadowRootInitDict: ShadowRootInit): ShadowRoot; - attributes: NamedNodeMap; - classList: DOMTokenList; - className: string; - clientHeight: number; - clientLeft: number; - clientTop: number; - clientWidth: number; - id: string; - // flowlint unsafe-getters-setters:off - get innerHTML(): string; - set innerHTML(value: string | TrustedHTML): void; - // flowlint unsafe-getters-setters:error - localName: string; - namespaceURI: ?string; - nextElementSibling: ?Element; - // flowlint unsafe-getters-setters:off - get outerHTML(): string; - set outerHTML(value: string | TrustedHTML): void; - // flowlint unsafe-getters-setters:error - prefix: string | null; - previousElementSibling: ?Element; - scrollHeight: number; - scrollLeft: number; - scrollTop: number; - scrollWidth: number; - +tagName: string; - - // TODO: a lot more ARIA properties - ariaHidden: void | 'true' | 'false'; - - closest(selectors: string): ?Element; - - getAttribute(name?: string): ?string; - getAttributeNames(): Array; - getAttributeNS(namespaceURI: string | null, localName: string): string | null; - getAttributeNode(name: string): Attr | null; - getAttributeNodeNS(namespaceURI: string | null, localName: string): Attr | null; - getBoundingClientRect(): DOMRect; - getClientRects(): DOMRectList; - getElementsByClassName(names: string): HTMLCollection; - getElementsByTagName(name: 'a'): HTMLCollection; - getElementsByTagName(name: 'audio'): HTMLCollection; - getElementsByTagName(name: 'br'): HTMLCollection; - getElementsByTagName(name: 'button'): HTMLCollection; - getElementsByTagName(name: 'canvas'): HTMLCollection; - getElementsByTagName(name: 'col'): HTMLCollection; - getElementsByTagName(name: 'colgroup'): HTMLCollection; - getElementsByTagName(name: 'data'): HTMLCollection; - getElementsByTagName(name: 'datalist'): HTMLCollection; - getElementsByTagName(name: 'del'): HTMLCollection; - getElementsByTagName(name: 'details'): HTMLCollection; - getElementsByTagName(name: 'dialog'): HTMLCollection; - getElementsByTagName(name: 'div'): HTMLCollection; - getElementsByTagName(name: 'dl'): HTMLCollection; - getElementsByTagName(name: 'fieldset'): HTMLCollection; - getElementsByTagName(name: 'form'): HTMLCollection; - getElementsByTagName(name: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'): HTMLCollection; - getElementsByTagName(name: 'head'): HTMLCollection; - getElementsByTagName(name: 'hr'): HTMLCollection; - getElementsByTagName(name: 'iframe'): HTMLCollection; - getElementsByTagName(name: 'img'): HTMLCollection; - getElementsByTagName(name: 'input'): HTMLCollection; - getElementsByTagName(name: 'ins'): HTMLCollection; - getElementsByTagName(name: 'label'): HTMLCollection; - getElementsByTagName(name: 'legend'): HTMLCollection; - getElementsByTagName(name: 'li'): HTMLCollection; - getElementsByTagName(name: 'link'): HTMLCollection; - getElementsByTagName(name: 'meta'): HTMLCollection; - getElementsByTagName(name: 'meter'): HTMLCollection; - getElementsByTagName(name: 'object'): HTMLCollection; - getElementsByTagName(name: 'ol'): HTMLCollection; - getElementsByTagName(name: 'option'): HTMLCollection; - getElementsByTagName(name: 'optgroup'): HTMLCollection; - getElementsByTagName(name: 'p'): HTMLCollection; - getElementsByTagName(name: 'param'): HTMLCollection; - getElementsByTagName(name: 'picture'): HTMLCollection; - getElementsByTagName(name: 'pre'): HTMLCollection; - getElementsByTagName(name: 'progress'): HTMLCollection; - getElementsByTagName(name: 'script'): HTMLCollection; - getElementsByTagName(name: 'select'): HTMLCollection; - getElementsByTagName(name: 'source'): HTMLCollection; - getElementsByTagName(name: 'span'): HTMLCollection; - getElementsByTagName(name: 'style'): HTMLCollection; - getElementsByTagName(name: 'textarea'): HTMLCollection; - getElementsByTagName(name: 'video'): HTMLCollection; - getElementsByTagName(name: 'table'): HTMLCollection; - getElementsByTagName(name: 'title'): HTMLCollection; - getElementsByTagName(name: 'caption'): HTMLCollection; - getElementsByTagName(name: 'thead' | 'tfoot' | 'tbody'): HTMLCollection; - getElementsByTagName(name: 'tr'): HTMLCollection; - getElementsByTagName(name: 'td' | 'th'): HTMLCollection; - getElementsByTagName(name: 'template'): HTMLCollection; - getElementsByTagName(name: 'ul'): HTMLCollection; - getElementsByTagName(name: string): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'a'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'audio'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'br'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'button'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'canvas'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'col'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'colgroup'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'data'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'datalist'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'del'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'details'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'dialog'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'div'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'dl'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'fieldset'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'form'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'head'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'hr'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'iframe'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'img'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'input'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'ins'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'label'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'legend'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'li'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'link'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'meta'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'meter'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'object'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'ol'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'option'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'optgroup'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'p'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'param'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'picture'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'pre'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'progress'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'script'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'select'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'source'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'span'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'style'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'textarea'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'video'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'table'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'title'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'caption'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'thead' | 'tfoot' | 'tbody'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'tr'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'td' | 'th'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'template'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: 'ul'): HTMLCollection; - getElementsByTagNameNS(namespaceURI: string | null, localName: string): HTMLCollection; - hasAttribute(name: string): boolean; - hasAttributeNS(namespaceURI: string | null, localName: string): boolean; - hasAttributes(): boolean; - hasPointerCapture(pointerId: number): boolean; - insertAdjacentElement(position: 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend', element: Element): void; - insertAdjacentHTML(position: 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend', html: string | TrustedHTML): void; - insertAdjacentText(position: 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend', text: string): void; - matches(selector: string): boolean; - releasePointerCapture(pointerId: number): void; - removeAttribute(name?: string): void; - removeAttributeNode(attributeNode: Attr): Attr; - removeAttributeNS(namespaceURI: string | null, localName: string): void; - requestFullscreen(options?: { navigationUI: 'auto' | 'show' | 'hide', ... }): Promise; - requestPointerLock(): void; - scrollIntoView(arg?: (boolean | { - behavior?: ('auto' | 'instant' | 'smooth'), - block?: ('start' | 'center' | 'end' | 'nearest'), - inline?: ('start' | 'center' | 'end' | 'nearest'), - ... - })): void; - scroll(x: number, y: number): void; - scroll(options: ScrollToOptions): void; - scrollTo(x: number, y: number): void; - scrollTo(options: ScrollToOptions): void; - scrollBy(x: number, y: number): void; - scrollBy(options: ScrollToOptions): void; - setAttribute(name?: string, value?: string): void; - toggleAttribute(name?: string, force?: boolean): void; - setAttributeNS(namespaceURI: string | null, qualifiedName: string, value: string): void; - setAttributeNode(newAttr: Attr): Attr | null; - setAttributeNodeNS(newAttr: Attr): Attr | null; - setPointerCapture(pointerId: number): void; - shadowRoot?: ShadowRoot; - slot?: string; - - // from ParentNode interface - childElementCount: number; - children: HTMLCollection; - firstElementChild: ?Element; - lastElementChild: ?Element; - append(...nodes: Array): void; - prepend(...nodes: Array): void; - - querySelector(selector: 'a'): HTMLAnchorElement | null; - querySelector(selector: 'area'): HTMLAreaElement | null; - querySelector(selector: 'audio'): HTMLAudioElement | null; - querySelector(selector: 'blockquote'): HTMLQuoteElement | null; - querySelector(selector: 'body'): HTMLBodyElement | null; - querySelector(selector: 'br'): HTMLBRElement | null; - querySelector(selector: 'button'): HTMLButtonElement | null; - querySelector(selector: 'canvas'): HTMLCanvasElement | null; - querySelector(selector: 'col'): HTMLTableColElement | null; - querySelector(selector: 'colgroup'): HTMLTableColElement | null; - querySelector(selector: 'data'): HTMLDataElement | null; - querySelector(selector: 'datalist'): HTMLDataListElement | null; - querySelector(selector: 'del'): HTMLModElement | null; - querySelector(selector: 'details'): HTMLDetailsElement | null; - querySelector(selector: 'dialog'): HTMLDialogElement | null; - querySelector(selector: 'div'): HTMLDivElement | null; - querySelector(selector: 'dl'): HTMLDListElement | null; - querySelector(selector: 'embed'): HTMLEmbedElement | null; - querySelector(selector: 'fieldset'): HTMLFieldSetElement | null; - querySelector(selector: 'form'): HTMLFormElement | null; - querySelector(selector: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'): HTMLHeadingElement; - querySelector(selector: 'head'): HTMLHeadElement | null; - querySelector(selector: 'hr'): HTMLHRElement | null; - querySelector(selector: 'html'): HTMLHtmlElement | null; - querySelector(selector: 'iframe'): HTMLIFrameElement | null; - querySelector(selector: 'img'): HTMLImageElement | null; - querySelector(selector: 'ins'): HTMLModElement | null; - querySelector(selector: 'input'): HTMLInputElement | null; - querySelector(selector: 'label'): HTMLLabelElement | null; - querySelector(selector: 'legend'): HTMLLegendElement | null; - querySelector(selector: 'li'): HTMLLIElement | null; - querySelector(selector: 'link'): HTMLLinkElement | null; - querySelector(selector: 'map'): HTMLMapElement | null; - querySelector(selector: 'meta'): HTMLMetaElement | null; - querySelector(selector: 'meter'): HTMLMeterElement | null; - querySelector(selector: 'object'): HTMLObjectElement | null; - querySelector(selector: 'ol'): HTMLOListElement | null; - querySelector(selector: 'option'): HTMLOptionElement | null; - querySelector(selector: 'optgroup'): HTMLOptGroupElement | null; - querySelector(selector: 'p'): HTMLParagraphElement | null; - querySelector(selector: 'param'): HTMLParamElement | null; - querySelector(selector: 'picture'): HTMLPictureElement | null; - querySelector(selector: 'pre'): HTMLPreElement | null; - querySelector(selector: 'progress'): HTMLProgressElement | null; - querySelector(selector: 'q'): HTMLQuoteElement | null; - querySelector(selector: 'script'): HTMLScriptElement | null; - querySelector(selector: 'select'): HTMLSelectElement | null; - querySelector(selector: 'source'): HTMLSourceElement | null; - querySelector(selector: 'span'): HTMLSpanElement | null; - querySelector(selector: 'style'): HTMLStyleElement | null; - querySelector(selector: 'textarea'): HTMLTextAreaElement | null; - querySelector(selector: 'time'): HTMLTimeElement | null; - querySelector(selector: 'title'): HTMLTitleElement | null; - querySelector(selector: 'track'): HTMLTrackElement | null; - querySelector(selector: 'video'): HTMLVideoElement | null; - querySelector(selector: 'table'): HTMLTableElement | null; - querySelector(selector: 'caption'): HTMLTableCaptionElement | null; - querySelector(selector: 'thead' | 'tfoot' | 'tbody'): HTMLTableSectionElement | null; - querySelector(selector: 'tr'): HTMLTableRowElement | null; - querySelector(selector: 'td' | 'th'): HTMLTableCellElement | null; - querySelector(selector: 'template'): HTMLTemplateElement | null; - querySelector(selector: 'ul'): HTMLUListElement | null; - querySelector(selector: string): HTMLElement | null; - - querySelectorAll(selector: 'a'): NodeList; - querySelectorAll(selector: 'area'): NodeList; - querySelectorAll(selector: 'audio'): NodeList; - querySelectorAll(selector: 'blockquote'): NodeList; - querySelectorAll(selector: 'body'): NodeList; - querySelectorAll(selector: 'br'): NodeList; - querySelectorAll(selector: 'button'): NodeList; - querySelectorAll(selector: 'canvas'): NodeList; - querySelectorAll(selector: 'col'): NodeList; - querySelectorAll(selector: 'colgroup'): NodeList; - querySelectorAll(selector: 'data'): NodeList; - querySelectorAll(selector: 'datalist'): NodeList; - querySelectorAll(selector: 'del'): NodeList; - querySelectorAll(selector: 'details'): NodeList; - querySelectorAll(selector: 'dialog'): NodeList; - querySelectorAll(selector: 'div'): NodeList; - querySelectorAll(selector: 'dl'): NodeList; - querySelectorAll(selector: 'embed'): NodeList; - querySelectorAll(selector: 'fieldset'): NodeList; - querySelectorAll(selector: 'form'): NodeList; - querySelectorAll(selector: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'): NodeList; - querySelectorAll(selector: 'head'): NodeList; - querySelectorAll(selector: 'hr'): NodeList; - querySelectorAll(selector: 'html'): NodeList; - querySelectorAll(selector: 'iframe'): NodeList; - querySelectorAll(selector: 'img'): NodeList; - querySelectorAll(selector: 'input'): NodeList; - querySelectorAll(selector: 'ins'): NodeList; - querySelectorAll(selector: 'label'): NodeList; - querySelectorAll(selector: 'legend'): NodeList; - querySelectorAll(selector: 'li'): NodeList; - querySelectorAll(selector: 'link'): NodeList; - querySelectorAll(selector: 'map'): NodeList; - querySelectorAll(selector: 'meta'): NodeList; - querySelectorAll(selector: 'meter'): NodeList; - querySelectorAll(selector: 'object'): NodeList; - querySelectorAll(selector: 'ol'): NodeList; - querySelectorAll(selector: 'option'): NodeList; - querySelectorAll(selector: 'optgroup'): NodeList; - querySelectorAll(selector: 'p'): NodeList; - querySelectorAll(selector: 'param'): NodeList; - querySelectorAll(selector: 'picture'): NodeList; - querySelectorAll(selector: 'pre'): NodeList; - querySelectorAll(selector: 'progress'): NodeList; - querySelectorAll(selector: 'q'): NodeList; - querySelectorAll(selector: 'script'): NodeList; - querySelectorAll(selector: 'select'): NodeList; - querySelectorAll(selector: 'source'): NodeList; - querySelectorAll(selector: 'span'): NodeList; - querySelectorAll(selector: 'style'): NodeList; - querySelectorAll(selector: 'textarea'): NodeList; - querySelectorAll(selector: 'time'): NodeList; - querySelectorAll(selector: 'title'): NodeList; - querySelectorAll(selector: 'track'): NodeList; - querySelectorAll(selector: 'video'): NodeList; - querySelectorAll(selector: 'table'): NodeList; - querySelectorAll(selector: 'caption'): NodeList; - querySelectorAll(selector: 'thead' | 'tfoot' | 'tbody'): NodeList; - querySelectorAll(selector: 'tr'): NodeList; - querySelectorAll(selector: 'td' | 'th'): NodeList; - querySelectorAll(selector: 'template'): NodeList; - querySelectorAll(selector: 'ul'): NodeList; - querySelectorAll(selector: string): NodeList; - - // from ChildNode interface - after(...nodes: Array): void; - before(...nodes: Array): void; - replaceWith(...nodes: Array): void; - remove(): void; -} - -declare class HTMLElement extends Element { - blur(): void; - click(): void; - focus(options?: FocusOptions): void; - getBoundingClientRect(): DOMRect; - forceSpellcheck(): void; - accessKey: string; - accessKeyLabel: string; - contentEditable: string; - contextMenu: ?HTMLMenuElement; - dataset: DOMStringMap; - dir: 'ltr' | 'rtl' | 'auto'; - draggable: boolean; - dropzone: any; - hidden: boolean; - inert: boolean; - isContentEditable: boolean; - itemProp: any; - itemScope: boolean; - itemType: any; - itemValue: Object; - lang: string; - offsetHeight: number; - offsetLeft: number; - offsetParent: ?Element; - offsetTop: number; - offsetWidth: number; - onabort: ?Function; - onblur: ?Function; - oncancel: ?Function; - oncanplay: ?Function; - oncanplaythrough: ?Function; - onchange: ?Function; - onclick: ?Function; - oncontextmenu: ?Function; - oncuechange: ?Function; - ondblclick: ?Function; - ondurationchange: ?Function; - onemptied: ?Function; - onended: ?Function; - onerror: ?Function; - onfocus: ?Function; - onfullscreenchange: ?Function; - onfullscreenerror: ?Function; - ongotpointercapture: ?Function, - oninput: ?Function; - oninvalid: ?Function; - onkeydown: ?Function; - onkeypress: ?Function; - onkeyup: ?Function; - onload: ?Function; - onloadeddata: ?Function; - onloadedmetadata: ?Function; - onloadstart: ?Function; - onlostpointercapture: ?Function, - onmousedown: ?Function; - onmouseenter: ?Function; - onmouseleave: ?Function; - onmousemove: ?Function; - onmouseout: ?Function; - onmouseover: ?Function; - onmouseup: ?Function; - onmousewheel: ?Function; - onpause: ?Function; - onplay: ?Function; - onplaying: ?Function; - onpointercancel: ?Function, - onpointerdown: ?Function, - onpointerenter: ?Function, - onpointerleave: ?Function, - onpointermove: ?Function, - onpointerout: ?Function, - onpointerover: ?Function, - onpointerup: ?Function, - onprogress: ?Function; - onratechange: ?Function; - onreadystatechange: ?Function; - onreset: ?Function; - onresize: ?Function; - onscroll: ?Function; - onseeked: ?Function; - onseeking: ?Function; - onselect: ?Function; - onshow: ?Function; - onstalled: ?Function; - onsubmit: ?Function; - onsuspend: ?Function; - ontimeupdate: ?Function; - ontoggle: ?Function; - onvolumechange: ?Function; - onwaiting: ?Function; - properties: any; - spellcheck: boolean; - style: CSSStyleDeclaration; - tabIndex: number; - title: string; - translate: boolean; -} - -declare class HTMLSlotElement extends HTMLElement { - name: string; - assignedNodes(options?: { flatten: boolean, ... }): Node[]; -} - -declare class HTMLTableElement extends HTMLElement { - tagName: 'TABLE'; - caption: HTMLTableCaptionElement | null; - tHead: HTMLTableSectionElement | null; - tFoot: HTMLTableSectionElement | null; - +tBodies: HTMLCollection; - +rows: HTMLCollection; - createTHead(): HTMLTableSectionElement; - deleteTHead(): void; - createTFoot(): HTMLTableSectionElement; - deleteTFoot(): void; - createCaption(): HTMLTableCaptionElement; - deleteCaption(): void; - insertRow(index?: number): HTMLTableRowElement; - deleteRow(index: number): void; -} - -declare class HTMLTableCaptionElement extends HTMLElement { - tagName: 'CAPTION'; -} - -declare class HTMLTableColElement extends HTMLElement { - tagName: 'COL' | 'COLGROUP'; - span: number; -} - -declare class HTMLTableSectionElement extends HTMLElement { - tagName: 'THEAD' | 'TFOOT' | 'TBODY'; - +rows: HTMLCollection; - insertRow(index?: number): HTMLTableRowElement; - deleteRow(index: number): void; -} - -declare class HTMLTableCellElement extends HTMLElement { - tagName: 'TD' | 'TH'; - colSpan: number; - rowSpan: number; - +cellIndex: number; -} - -declare class HTMLTableRowElement extends HTMLElement { - tagName: 'TR'; - align: 'left' | 'right' | 'center'; - +rowIndex: number; - +sectionRowIndex: number; - +cells: HTMLCollection; - deleteCell(index: number): void; - insertCell(index?: number): HTMLTableCellElement; -} - -declare class HTMLMenuElement extends HTMLElement { - getCompact(): boolean; - setCompact(compact: boolean): void; -} - -declare class HTMLBaseElement extends HTMLElement { - href: string; - target: string; -} - -declare class HTMLTemplateElement extends HTMLElement { - content: DocumentFragment; -} - -declare class CanvasGradient { - addColorStop(offset: number, color: string): void; -} - -declare class CanvasPattern { - setTransform(matrix: SVGMatrix): void; -} - -declare class ImageBitmap { - close(): void; - width: number; - height: number; -} - -type CanvasFillRule = string; - -type CanvasImageSource = HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | CanvasRenderingContext2D | ImageBitmap; - -declare class HitRegionOptions { - path?: Path2D, - fillRule?: CanvasFillRule, - id?: string, - parentID?: string; - cursor?: string; - control?: Element; - label: ?string; - role: ?string; -}; - -declare class CanvasDrawingStyles { - lineWidth: number; - lineCap: string; - lineJoin: string; - miterLimit: number; - - // dashed lines - setLineDash(segments: Array): void; - getLineDash(): Array; - lineDashOffset: number; - - // text - font: string; - textAlign: string; - textBaseline: string; - direction: string; -}; - -declare class SVGMatrix { - getComponent(index: number): number; - mMultiply(secondMatrix: SVGMatrix): SVGMatrix; - inverse(): SVGMatrix; - mTranslate(x: number, y: number): SVGMatrix; - mScale(scaleFactor: number): SVGMatrix; - mRotate(angle: number): SVGMatrix; -}; - -declare class TextMetrics { - // x-direction - width: number; - actualBoundingBoxLeft: number; - actualBoundingBoxRight: number; - - // y-direction - fontBoundingBoxAscent: number; - fontBoundingBoxDescent: number; - actualBoundingBoxAscent: number; - actualBoundingBoxDescent: number; - emHeightAscent: number; - emHeightDescent: number; - hangingBaseline: number; - alphabeticBaseline: number; - ideographicBaseline: number; -}; - -declare class Path2D { - constructor(path?: Path2D | string): void; - - addPath(path: Path2D, transformation?: ?SVGMatrix): void; - addPathByStrokingPath(path: Path2D, styles: CanvasDrawingStyles, transformation?: ?SVGMatrix): void; - addText(text: string, styles: CanvasDrawingStyles, transformation: ?SVGMatrix, x: number, y: number, maxWidth?: number): void; - addPathByStrokingText(text: string, styles: CanvasDrawingStyles, transformation: ?SVGMatrix, x: number, y: number, maxWidth?: number): void; - addText(text: string, styles: CanvasDrawingStyles, transformation: ?SVGMatrix, path: Path2D, maxWidth?: number): void; - addPathByStrokingText(text: string, styles: CanvasDrawingStyles, transformation: ?SVGMatrix, path: Path2D, maxWidth?: number): void; - - // CanvasPathMethods - // shared path API methods - arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; - arcTo(x1: number, y1: number, x2: number, y2: number, radius: number, _: void, _: void): void; - arcTo(x1: number, y1: number, x2: number, y2: number, radiusX: number, radiusY: number, rotation: number): void; - bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void; - closePath(): void; - ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; - lineTo(x: number, y: number): void; - moveTo(x: number, y: number): void; - quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void; - rect(x: number, y: number, w: number, h: number): void; -}; - -declare class ImageData { - width: number; - height: number; - data: Uint8ClampedArray; - - // constructor methods are used in Worker where CanvasRenderingContext2D - // is unavailable. - // https://html.spec.whatwg.org/multipage/scripting.html#dom-imagedata - constructor(data: Uint8ClampedArray, width: number, height: number): void; - constructor(width: number, height: number): void; -}; - -interface DOMPointInit { - w?: number; - x?: number; - y?: number; - z?: number; -} - -declare class CanvasRenderingContext2D { - canvas: HTMLCanvasElement; - - // canvas dimensions - width: number; - height: number; - - // for contexts that aren't directly fixed to a specific canvas - commit(): void; - - // state - save(): void; - restore(): void; - - // transformations - currentTransform: SVGMatrix; - scale(x: number, y: number): void; - rotate(angle: number): void; - translate(x: number, y: number): void; - transform(a: number, b: number, c: number, d: number, e: number, f: number): void; - setTransform(a: number, b: number, c: number, d: number, e: number, f: number): void; - resetTransform(): void; - - // compositing - globalAlpha: number; - globalCompositeOperation: string; - - // image smoothing - imageSmoothingEnabled: boolean; - imageSmoothingQuality: 'low' | 'medium' | 'high'; - - // filters - filter: string; - - // colours and styles - strokeStyle: string | CanvasGradient | CanvasPattern; - fillStyle: string | CanvasGradient | CanvasPattern; - createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient; - createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; - createPattern(image: CanvasImageSource, repetition: ?string): CanvasPattern; - - // shadows - shadowOffsetX: number; - shadowOffsetY: number; - shadowBlur: number; - shadowColor: string; - - // rects - clearRect(x: number, y: number, w: number, h: number): void; - fillRect(x: number, y: number, w: number, h: number): void; - roundRect(x: number, y: number, w: number, h: number, radii?: number | DOMPointInit | $ReadOnlyArray): void; - strokeRect(x: number, y: number, w: number, h: number): void; - - // path API - beginPath(): void; - fill(fillRule?: CanvasFillRule): void; - fill(path: Path2D, fillRule?: CanvasFillRule): void; - stroke(): void; - stroke(path: Path2D): void; - drawFocusIfNeeded(element: Element): void; - drawFocusIfNeeded(path: Path2D, element: Element): void; - scrollPathIntoView(): void; - scrollPathIntoView(path: Path2D): void; - clip(fillRule?: CanvasFillRule): void; - clip(path: Path2D, fillRule?: CanvasFillRule): void; - resetClip(): void; - isPointInPath(x: number, y: number, fillRule?: CanvasFillRule): boolean; - isPointInPath(path: Path2D, x: number, y: number, fillRule?: CanvasFillRule): boolean; - isPointInStroke(x: number, y: number): boolean; - isPointInStroke(path: Path2D, x: number, y: number): boolean; - - // text (see also the CanvasDrawingStyles interface) - fillText(text: string, x: number, y: number, maxWidth?: number): void; - strokeText(text: string, x: number, y: number, maxWidth?: number): void; - measureText(text: string): TextMetrics; - - // drawing images - drawImage(image: CanvasImageSource, dx: number, dy: number): void; - drawImage(image: CanvasImageSource, dx: number, dy: number, dw: number, dh: number): void; - drawImage(image: CanvasImageSource, sx: number, sy: number, sw: number, sh: number, dx: number, dy: number, dw: number, dh: number): void; - - // hit regions - addHitRegion(options?: HitRegionOptions): void; - removeHitRegion(id: string): void; - clearHitRegions(): void; - - // pixel manipulation - createImageData(sw: number, sh: number): ImageData; - createImageData(imagedata: ImageData): ImageData; - getImageData(sx: number, sy: number, sw: number, sh: number): ImageData; - putImageData(imagedata: ImageData, dx: number, dy: number): void; - putImageData(imagedata: ImageData, dx: number, dy: number, dirtyX: number, dirtyY: number, dirtyWidth: number, dirtyHeight: number): void; - - // CanvasDrawingStyles - // line caps/joins - lineWidth: number; - lineCap: string; - lineJoin: string; - miterLimit: number; - - // dashed lines - setLineDash(segments: Array): void; - getLineDash(): Array; - lineDashOffset: number; - - // text - font: string; - textAlign: string; - textBaseline: string; - direction: string; - - // CanvasPathMethods - // shared path API methods - closePath(): void; - moveTo(x: number, y: number): void; - lineTo(x: number, y: number): void; - quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void; - bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void; - arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void; - arcTo(x1: number, y1: number, x2: number, y2: number, radiusX: number, radiusY: number, rotation: number): void; - rect(x: number, y: number, w: number, h: number): void; - arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; - ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; -} - - -// WebGL idl: https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl - -type WebGLContextAttributes = { - alpha: boolean, - depth: boolean, - stencil: boolean, - antialias: boolean, - premultipliedAlpha: boolean, - preserveDrawingBuffer: boolean, - preferLowPowerToHighPerformance: boolean, - failIfMajorPerformanceCaveat: boolean, - ... -}; - -interface WebGLObject { -}; - -interface WebGLBuffer extends WebGLObject { -}; - -interface WebGLFramebuffer extends WebGLObject { -}; - -interface WebGLProgram extends WebGLObject { -}; - -interface WebGLRenderbuffer extends WebGLObject { -}; - -interface WebGLShader extends WebGLObject { -}; - -interface WebGLTexture extends WebGLObject { -}; - -interface WebGLUniformLocation { -}; - -interface WebGLActiveInfo { - size: number; - type: number; - name: string; -}; - -interface WebGLShaderPrecisionFormat { - rangeMin: number; - rangeMax: number; - precision: number; -}; - -type BufferDataSource = ArrayBuffer | $ArrayBufferView; - -type TexImageSource = - ImageBitmap | - ImageData | - HTMLImageElement | - HTMLCanvasElement | - HTMLVideoElement; - -type VertexAttribFVSource = - Float32Array | - Array; - -/* flow */ -declare class WebGLRenderingContext { - static DEPTH_BUFFER_BIT : 0x00000100; - DEPTH_BUFFER_BIT : 0x00000100; - static STENCIL_BUFFER_BIT : 0x00000400; - STENCIL_BUFFER_BIT : 0x00000400; - static COLOR_BUFFER_BIT : 0x00004000; - COLOR_BUFFER_BIT : 0x00004000; - static POINTS : 0x0000; - POINTS : 0x0000; - static LINES : 0x0001; - LINES : 0x0001; - static LINE_LOOP : 0x0002; - LINE_LOOP : 0x0002; - static LINE_STRIP : 0x0003; - LINE_STRIP : 0x0003; - static TRIANGLES : 0x0004; - TRIANGLES : 0x0004; - static TRIANGLE_STRIP : 0x0005; - TRIANGLE_STRIP : 0x0005; - static TRIANGLE_FAN : 0x0006; - TRIANGLE_FAN : 0x0006; - static ZERO : 0; - ZERO : 0; - static ONE : 1; - ONE : 1; - static SRC_COLOR : 0x0300; - SRC_COLOR : 0x0300; - static ONE_MINUS_SRC_COLOR : 0x0301; - ONE_MINUS_SRC_COLOR : 0x0301; - static SRC_ALPHA : 0x0302; - SRC_ALPHA : 0x0302; - static ONE_MINUS_SRC_ALPHA : 0x0303; - ONE_MINUS_SRC_ALPHA : 0x0303; - static DST_ALPHA : 0x0304; - DST_ALPHA : 0x0304; - static ONE_MINUS_DST_ALPHA : 0x0305; - ONE_MINUS_DST_ALPHA : 0x0305; - static DST_COLOR : 0x0306; - DST_COLOR : 0x0306; - static ONE_MINUS_DST_COLOR : 0x0307; - ONE_MINUS_DST_COLOR : 0x0307; - static SRC_ALPHA_SATURATE : 0x0308; - SRC_ALPHA_SATURATE : 0x0308; - static FUNC_ADD : 0x8006; - FUNC_ADD : 0x8006; - static BLEND_EQUATION : 0x8009; - BLEND_EQUATION : 0x8009; - static BLEND_EQUATION_RGB : 0x8009; - BLEND_EQUATION_RGB : 0x8009; - static BLEND_EQUATION_ALPHA : 0x883D; - BLEND_EQUATION_ALPHA : 0x883D; - static FUNC_SUBTRACT : 0x800A; - FUNC_SUBTRACT : 0x800A; - static FUNC_REVERSE_SUBTRACT : 0x800B; - FUNC_REVERSE_SUBTRACT : 0x800B; - static BLEND_DST_RGB : 0x80C8; - BLEND_DST_RGB : 0x80C8; - static BLEND_SRC_RGB : 0x80C9; - BLEND_SRC_RGB : 0x80C9; - static BLEND_DST_ALPHA : 0x80CA; - BLEND_DST_ALPHA : 0x80CA; - static BLEND_SRC_ALPHA : 0x80CB; - BLEND_SRC_ALPHA : 0x80CB; - static CONSTANT_COLOR : 0x8001; - CONSTANT_COLOR : 0x8001; - static ONE_MINUS_CONSTANT_COLOR : 0x8002; - ONE_MINUS_CONSTANT_COLOR : 0x8002; - static CONSTANT_ALPHA : 0x8003; - CONSTANT_ALPHA : 0x8003; - static ONE_MINUS_CONSTANT_ALPHA : 0x8004; - ONE_MINUS_CONSTANT_ALPHA : 0x8004; - static BLEND_COLOR : 0x8005; - BLEND_COLOR : 0x8005; - static ARRAY_BUFFER : 0x8892; - ARRAY_BUFFER : 0x8892; - static ELEMENT_ARRAY_BUFFER : 0x8893; - ELEMENT_ARRAY_BUFFER : 0x8893; - static ARRAY_BUFFER_BINDING : 0x8894; - ARRAY_BUFFER_BINDING : 0x8894; - static ELEMENT_ARRAY_BUFFER_BINDING : 0x8895; - ELEMENT_ARRAY_BUFFER_BINDING : 0x8895; - static STREAM_DRAW : 0x88E0; - STREAM_DRAW : 0x88E0; - static STATIC_DRAW : 0x88E4; - STATIC_DRAW : 0x88E4; - static DYNAMIC_DRAW : 0x88E8; - DYNAMIC_DRAW : 0x88E8; - static BUFFER_SIZE : 0x8764; - BUFFER_SIZE : 0x8764; - static BUFFER_USAGE : 0x8765; - BUFFER_USAGE : 0x8765; - static CURRENT_VERTEX_ATTRIB : 0x8626; - CURRENT_VERTEX_ATTRIB : 0x8626; - static FRONT : 0x0404; - FRONT : 0x0404; - static BACK : 0x0405; - BACK : 0x0405; - static FRONT_AND_BACK : 0x0408; - FRONT_AND_BACK : 0x0408; - static CULL_FACE : 0x0B44; - CULL_FACE : 0x0B44; - static BLEND : 0x0BE2; - BLEND : 0x0BE2; - static DITHER : 0x0BD0; - DITHER : 0x0BD0; - static STENCIL_TEST : 0x0B90; - STENCIL_TEST : 0x0B90; - static DEPTH_TEST : 0x0B71; - DEPTH_TEST : 0x0B71; - static SCISSOR_TEST : 0x0C11; - SCISSOR_TEST : 0x0C11; - static POLYGON_OFFSET_FILL : 0x8037; - POLYGON_OFFSET_FILL : 0x8037; - static SAMPLE_ALPHA_TO_COVERAGE : 0x809E; - SAMPLE_ALPHA_TO_COVERAGE : 0x809E; - static SAMPLE_COVERAGE : 0x80A0; - SAMPLE_COVERAGE : 0x80A0; - static NO_ERROR : 0; - NO_ERROR : 0; - static INVALID_ENUM : 0x0500; - INVALID_ENUM : 0x0500; - static INVALID_VALUE : 0x0501; - INVALID_VALUE : 0x0501; - static INVALID_OPERATION : 0x0502; - INVALID_OPERATION : 0x0502; - static OUT_OF_MEMORY : 0x0505; - OUT_OF_MEMORY : 0x0505; - static CW : 0x0900; - CW : 0x0900; - static CCW : 0x0901; - CCW : 0x0901; - static LINE_WIDTH : 0x0B21; - LINE_WIDTH : 0x0B21; - static ALIASED_POINT_SIZE_RANGE : 0x846D; - ALIASED_POINT_SIZE_RANGE : 0x846D; - static ALIASED_LINE_WIDTH_RANGE : 0x846E; - ALIASED_LINE_WIDTH_RANGE : 0x846E; - static CULL_FACE_MODE : 0x0B45; - CULL_FACE_MODE : 0x0B45; - static FRONT_FACE : 0x0B46; - FRONT_FACE : 0x0B46; - static DEPTH_RANGE : 0x0B70; - DEPTH_RANGE : 0x0B70; - static DEPTH_WRITEMASK : 0x0B72; - DEPTH_WRITEMASK : 0x0B72; - static DEPTH_CLEAR_VALUE : 0x0B73; - DEPTH_CLEAR_VALUE : 0x0B73; - static DEPTH_FUNC : 0x0B74; - DEPTH_FUNC : 0x0B74; - static STENCIL_CLEAR_VALUE : 0x0B91; - STENCIL_CLEAR_VALUE : 0x0B91; - static STENCIL_FUNC : 0x0B92; - STENCIL_FUNC : 0x0B92; - static STENCIL_FAIL : 0x0B94; - STENCIL_FAIL : 0x0B94; - static STENCIL_PASS_DEPTH_FAIL : 0x0B95; - STENCIL_PASS_DEPTH_FAIL : 0x0B95; - static STENCIL_PASS_DEPTH_PASS : 0x0B96; - STENCIL_PASS_DEPTH_PASS : 0x0B96; - static STENCIL_REF : 0x0B97; - STENCIL_REF : 0x0B97; - static STENCIL_VALUE_MASK : 0x0B93; - STENCIL_VALUE_MASK : 0x0B93; - static STENCIL_WRITEMASK : 0x0B98; - STENCIL_WRITEMASK : 0x0B98; - static STENCIL_BACK_FUNC : 0x8800; - STENCIL_BACK_FUNC : 0x8800; - static STENCIL_BACK_FAIL : 0x8801; - STENCIL_BACK_FAIL : 0x8801; - static STENCIL_BACK_PASS_DEPTH_FAIL : 0x8802; - STENCIL_BACK_PASS_DEPTH_FAIL : 0x8802; - static STENCIL_BACK_PASS_DEPTH_PASS : 0x8803; - STENCIL_BACK_PASS_DEPTH_PASS : 0x8803; - static STENCIL_BACK_REF : 0x8CA3; - STENCIL_BACK_REF : 0x8CA3; - static STENCIL_BACK_VALUE_MASK : 0x8CA4; - STENCIL_BACK_VALUE_MASK : 0x8CA4; - static STENCIL_BACK_WRITEMASK : 0x8CA5; - STENCIL_BACK_WRITEMASK : 0x8CA5; - static VIEWPORT : 0x0BA2; - VIEWPORT : 0x0BA2; - static SCISSOR_BOX : 0x0C10; - SCISSOR_BOX : 0x0C10; - static COLOR_CLEAR_VALUE : 0x0C22; - COLOR_CLEAR_VALUE : 0x0C22; - static COLOR_WRITEMASK : 0x0C23; - COLOR_WRITEMASK : 0x0C23; - static UNPACK_ALIGNMENT : 0x0CF5; - UNPACK_ALIGNMENT : 0x0CF5; - static PACK_ALIGNMENT : 0x0D05; - PACK_ALIGNMENT : 0x0D05; - static MAX_TEXTURE_SIZE : 0x0D33; - MAX_TEXTURE_SIZE : 0x0D33; - static MAX_VIEWPORT_DIMS : 0x0D3A; - MAX_VIEWPORT_DIMS : 0x0D3A; - static SUBPIXEL_BITS : 0x0D50; - SUBPIXEL_BITS : 0x0D50; - static RED_BITS : 0x0D52; - RED_BITS : 0x0D52; - static GREEN_BITS : 0x0D53; - GREEN_BITS : 0x0D53; - static BLUE_BITS : 0x0D54; - BLUE_BITS : 0x0D54; - static ALPHA_BITS : 0x0D55; - ALPHA_BITS : 0x0D55; - static DEPTH_BITS : 0x0D56; - DEPTH_BITS : 0x0D56; - static STENCIL_BITS : 0x0D57; - STENCIL_BITS : 0x0D57; - static POLYGON_OFFSET_UNITS : 0x2A00; - POLYGON_OFFSET_UNITS : 0x2A00; - static POLYGON_OFFSET_FACTOR : 0x8038; - POLYGON_OFFSET_FACTOR : 0x8038; - static TEXTURE_BINDING_2D : 0x8069; - TEXTURE_BINDING_2D : 0x8069; - static SAMPLE_BUFFERS : 0x80A8; - SAMPLE_BUFFERS : 0x80A8; - static SAMPLES : 0x80A9; - SAMPLES : 0x80A9; - static SAMPLE_COVERAGE_VALUE : 0x80AA; - SAMPLE_COVERAGE_VALUE : 0x80AA; - static SAMPLE_COVERAGE_INVERT : 0x80AB; - SAMPLE_COVERAGE_INVERT : 0x80AB; - static COMPRESSED_TEXTURE_FORMATS : 0x86A3; - COMPRESSED_TEXTURE_FORMATS : 0x86A3; - static DONT_CARE : 0x1100; - DONT_CARE : 0x1100; - static FASTEST : 0x1101; - FASTEST : 0x1101; - static NICEST : 0x1102; - NICEST : 0x1102; - static GENERATE_MIPMAP_HINT : 0x8192; - GENERATE_MIPMAP_HINT : 0x8192; - static BYTE : 0x1400; - BYTE : 0x1400; - static UNSIGNED_BYTE : 0x1401; - UNSIGNED_BYTE : 0x1401; - static SHORT : 0x1402; - SHORT : 0x1402; - static UNSIGNED_SHORT : 0x1403; - UNSIGNED_SHORT : 0x1403; - static INT : 0x1404; - INT : 0x1404; - static UNSIGNED_INT : 0x1405; - UNSIGNED_INT : 0x1405; - static FLOAT : 0x1406; - FLOAT : 0x1406; - static DEPTH_COMPONENT : 0x1902; - DEPTH_COMPONENT : 0x1902; - static ALPHA : 0x1906; - ALPHA : 0x1906; - static RGB : 0x1907; - RGB : 0x1907; - static RGBA : 0x1908; - RGBA : 0x1908; - static LUMINANCE : 0x1909; - LUMINANCE : 0x1909; - static LUMINANCE_ALPHA : 0x190A; - LUMINANCE_ALPHA : 0x190A; - static UNSIGNED_SHORT_4_4_4_4 : 0x8033; - UNSIGNED_SHORT_4_4_4_4 : 0x8033; - static UNSIGNED_SHORT_5_5_5_1 : 0x8034; - UNSIGNED_SHORT_5_5_5_1 : 0x8034; - static UNSIGNED_SHORT_5_6_5 : 0x8363; - UNSIGNED_SHORT_5_6_5 : 0x8363; - static FRAGMENT_SHADER : 0x8B30; - FRAGMENT_SHADER : 0x8B30; - static VERTEX_SHADER : 0x8B31; - VERTEX_SHADER : 0x8B31; - static MAX_VERTEX_ATTRIBS : 0x8869; - MAX_VERTEX_ATTRIBS : 0x8869; - static MAX_VERTEX_UNIFORM_VECTORS : 0x8DFB; - MAX_VERTEX_UNIFORM_VECTORS : 0x8DFB; - static MAX_VARYING_VECTORS : 0x8DFC; - MAX_VARYING_VECTORS : 0x8DFC; - static MAX_COMBINED_TEXTURE_IMAGE_UNITS : 0x8B4D; - MAX_COMBINED_TEXTURE_IMAGE_UNITS : 0x8B4D; - static MAX_VERTEX_TEXTURE_IMAGE_UNITS : 0x8B4C; - MAX_VERTEX_TEXTURE_IMAGE_UNITS : 0x8B4C; - static MAX_TEXTURE_IMAGE_UNITS : 0x8872; - MAX_TEXTURE_IMAGE_UNITS : 0x8872; - static MAX_FRAGMENT_UNIFORM_VECTORS : 0x8DFD; - MAX_FRAGMENT_UNIFORM_VECTORS : 0x8DFD; - static SHADER_TYPE : 0x8B4F; - SHADER_TYPE : 0x8B4F; - static DELETE_STATUS : 0x8B80; - DELETE_STATUS : 0x8B80; - static LINK_STATUS : 0x8B82; - LINK_STATUS : 0x8B82; - static VALIDATE_STATUS : 0x8B83; - VALIDATE_STATUS : 0x8B83; - static ATTACHED_SHADERS : 0x8B85; - ATTACHED_SHADERS : 0x8B85; - static ACTIVE_UNIFORMS : 0x8B86; - ACTIVE_UNIFORMS : 0x8B86; - static ACTIVE_ATTRIBUTES : 0x8B89; - ACTIVE_ATTRIBUTES : 0x8B89; - static SHADING_LANGUAGE_VERSION : 0x8B8C; - SHADING_LANGUAGE_VERSION : 0x8B8C; - static CURRENT_PROGRAM : 0x8B8D; - CURRENT_PROGRAM : 0x8B8D; - static NEVER : 0x0200; - NEVER : 0x0200; - static LESS : 0x0201; - LESS : 0x0201; - static EQUAL : 0x0202; - EQUAL : 0x0202; - static LEQUAL : 0x0203; - LEQUAL : 0x0203; - static GREATER : 0x0204; - GREATER : 0x0204; - static NOTEQUAL : 0x0205; - NOTEQUAL : 0x0205; - static GEQUAL : 0x0206; - GEQUAL : 0x0206; - static ALWAYS : 0x0207; - ALWAYS : 0x0207; - static KEEP : 0x1E00; - KEEP : 0x1E00; - static REPLACE : 0x1E01; - REPLACE : 0x1E01; - static INCR : 0x1E02; - INCR : 0x1E02; - static DECR : 0x1E03; - DECR : 0x1E03; - static INVERT : 0x150A; - INVERT : 0x150A; - static INCR_WRAP : 0x8507; - INCR_WRAP : 0x8507; - static DECR_WRAP : 0x8508; - DECR_WRAP : 0x8508; - static VENDOR : 0x1F00; - VENDOR : 0x1F00; - static RENDERER : 0x1F01; - RENDERER : 0x1F01; - static VERSION : 0x1F02; - VERSION : 0x1F02; - static NEAREST : 0x2600; - NEAREST : 0x2600; - static LINEAR : 0x2601; - LINEAR : 0x2601; - static NEAREST_MIPMAP_NEAREST : 0x2700; - NEAREST_MIPMAP_NEAREST : 0x2700; - static LINEAR_MIPMAP_NEAREST : 0x2701; - LINEAR_MIPMAP_NEAREST : 0x2701; - static NEAREST_MIPMAP_LINEAR : 0x2702; - NEAREST_MIPMAP_LINEAR : 0x2702; - static LINEAR_MIPMAP_LINEAR : 0x2703; - LINEAR_MIPMAP_LINEAR : 0x2703; - static TEXTURE_MAG_FILTER : 0x2800; - TEXTURE_MAG_FILTER : 0x2800; - static TEXTURE_MIN_FILTER : 0x2801; - TEXTURE_MIN_FILTER : 0x2801; - static TEXTURE_WRAP_S : 0x2802; - TEXTURE_WRAP_S : 0x2802; - static TEXTURE_WRAP_T : 0x2803; - TEXTURE_WRAP_T : 0x2803; - static TEXTURE_2D : 0x0DE1; - TEXTURE_2D : 0x0DE1; - static TEXTURE : 0x1702; - TEXTURE : 0x1702; - static TEXTURE_CUBE_MAP : 0x8513; - TEXTURE_CUBE_MAP : 0x8513; - static TEXTURE_BINDING_CUBE_MAP : 0x8514; - TEXTURE_BINDING_CUBE_MAP : 0x8514; - static TEXTURE_CUBE_MAP_POSITIVE_X : 0x8515; - TEXTURE_CUBE_MAP_POSITIVE_X : 0x8515; - static TEXTURE_CUBE_MAP_NEGATIVE_X : 0x8516; - TEXTURE_CUBE_MAP_NEGATIVE_X : 0x8516; - static TEXTURE_CUBE_MAP_POSITIVE_Y : 0x8517; - TEXTURE_CUBE_MAP_POSITIVE_Y : 0x8517; - static TEXTURE_CUBE_MAP_NEGATIVE_Y : 0x8518; - TEXTURE_CUBE_MAP_NEGATIVE_Y : 0x8518; - static TEXTURE_CUBE_MAP_POSITIVE_Z : 0x8519; - TEXTURE_CUBE_MAP_POSITIVE_Z : 0x8519; - static TEXTURE_CUBE_MAP_NEGATIVE_Z : 0x851A; - TEXTURE_CUBE_MAP_NEGATIVE_Z : 0x851A; - static MAX_CUBE_MAP_TEXTURE_SIZE : 0x851C; - MAX_CUBE_MAP_TEXTURE_SIZE : 0x851C; - static TEXTURE0 : 0x84C0; - TEXTURE0 : 0x84C0; - static TEXTURE1 : 0x84C1; - TEXTURE1 : 0x84C1; - static TEXTURE2 : 0x84C2; - TEXTURE2 : 0x84C2; - static TEXTURE3 : 0x84C3; - TEXTURE3 : 0x84C3; - static TEXTURE4 : 0x84C4; - TEXTURE4 : 0x84C4; - static TEXTURE5 : 0x84C5; - TEXTURE5 : 0x84C5; - static TEXTURE6 : 0x84C6; - TEXTURE6 : 0x84C6; - static TEXTURE7 : 0x84C7; - TEXTURE7 : 0x84C7; - static TEXTURE8 : 0x84C8; - TEXTURE8 : 0x84C8; - static TEXTURE9 : 0x84C9; - TEXTURE9 : 0x84C9; - static TEXTURE10 : 0x84CA; - TEXTURE10 : 0x84CA; - static TEXTURE11 : 0x84CB; - TEXTURE11 : 0x84CB; - static TEXTURE12 : 0x84CC; - TEXTURE12 : 0x84CC; - static TEXTURE13 : 0x84CD; - TEXTURE13 : 0x84CD; - static TEXTURE14 : 0x84CE; - TEXTURE14 : 0x84CE; - static TEXTURE15 : 0x84CF; - TEXTURE15 : 0x84CF; - static TEXTURE16 : 0x84D0; - TEXTURE16 : 0x84D0; - static TEXTURE17 : 0x84D1; - TEXTURE17 : 0x84D1; - static TEXTURE18 : 0x84D2; - TEXTURE18 : 0x84D2; - static TEXTURE19 : 0x84D3; - TEXTURE19 : 0x84D3; - static TEXTURE20 : 0x84D4; - TEXTURE20 : 0x84D4; - static TEXTURE21 : 0x84D5; - TEXTURE21 : 0x84D5; - static TEXTURE22 : 0x84D6; - TEXTURE22 : 0x84D6; - static TEXTURE23 : 0x84D7; - TEXTURE23 : 0x84D7; - static TEXTURE24 : 0x84D8; - TEXTURE24 : 0x84D8; - static TEXTURE25 : 0x84D9; - TEXTURE25 : 0x84D9; - static TEXTURE26 : 0x84DA; - TEXTURE26 : 0x84DA; - static TEXTURE27 : 0x84DB; - TEXTURE27 : 0x84DB; - static TEXTURE28 : 0x84DC; - TEXTURE28 : 0x84DC; - static TEXTURE29 : 0x84DD; - TEXTURE29 : 0x84DD; - static TEXTURE30 : 0x84DE; - TEXTURE30 : 0x84DE; - static TEXTURE31 : 0x84DF; - TEXTURE31 : 0x84DF; - static ACTIVE_TEXTURE : 0x84E0; - ACTIVE_TEXTURE : 0x84E0; - static REPEAT : 0x2901; - REPEAT : 0x2901; - static CLAMP_TO_EDGE : 0x812F; - CLAMP_TO_EDGE : 0x812F; - static MIRRORED_REPEAT : 0x8370; - MIRRORED_REPEAT : 0x8370; - static FLOAT_VEC2 : 0x8B50; - FLOAT_VEC2 : 0x8B50; - static FLOAT_VEC3 : 0x8B51; - FLOAT_VEC3 : 0x8B51; - static FLOAT_VEC4 : 0x8B52; - FLOAT_VEC4 : 0x8B52; - static INT_VEC2 : 0x8B53; - INT_VEC2 : 0x8B53; - static INT_VEC3 : 0x8B54; - INT_VEC3 : 0x8B54; - static INT_VEC4 : 0x8B55; - INT_VEC4 : 0x8B55; - static BOOL : 0x8B56; - BOOL : 0x8B56; - static BOOL_VEC2 : 0x8B57; - BOOL_VEC2 : 0x8B57; - static BOOL_VEC3 : 0x8B58; - BOOL_VEC3 : 0x8B58; - static BOOL_VEC4 : 0x8B59; - BOOL_VEC4 : 0x8B59; - static FLOAT_MAT2 : 0x8B5A; - FLOAT_MAT2 : 0x8B5A; - static FLOAT_MAT3 : 0x8B5B; - FLOAT_MAT3 : 0x8B5B; - static FLOAT_MAT4 : 0x8B5C; - FLOAT_MAT4 : 0x8B5C; - static SAMPLER_2D : 0x8B5E; - SAMPLER_2D : 0x8B5E; - static SAMPLER_CUBE : 0x8B60; - SAMPLER_CUBE : 0x8B60; - static VERTEX_ATTRIB_ARRAY_ENABLED : 0x8622; - VERTEX_ATTRIB_ARRAY_ENABLED : 0x8622; - static VERTEX_ATTRIB_ARRAY_SIZE : 0x8623; - VERTEX_ATTRIB_ARRAY_SIZE : 0x8623; - static VERTEX_ATTRIB_ARRAY_STRIDE : 0x8624; - VERTEX_ATTRIB_ARRAY_STRIDE : 0x8624; - static VERTEX_ATTRIB_ARRAY_TYPE : 0x8625; - VERTEX_ATTRIB_ARRAY_TYPE : 0x8625; - static VERTEX_ATTRIB_ARRAY_NORMALIZED : 0x886A; - VERTEX_ATTRIB_ARRAY_NORMALIZED : 0x886A; - static VERTEX_ATTRIB_ARRAY_POINTER : 0x8645; - VERTEX_ATTRIB_ARRAY_POINTER : 0x8645; - static VERTEX_ATTRIB_ARRAY_BUFFER_BINDING : 0x889F; - VERTEX_ATTRIB_ARRAY_BUFFER_BINDING : 0x889F; - static IMPLEMENTATION_COLOR_READ_TYPE : 0x8B9A; - IMPLEMENTATION_COLOR_READ_TYPE : 0x8B9A; - static IMPLEMENTATION_COLOR_READ_FORMAT : 0x8B9B; - IMPLEMENTATION_COLOR_READ_FORMAT : 0x8B9B; - static COMPILE_STATUS : 0x8B81; - COMPILE_STATUS : 0x8B81; - static LOW_FLOAT : 0x8DF0; - LOW_FLOAT : 0x8DF0; - static MEDIUM_FLOAT : 0x8DF1; - MEDIUM_FLOAT : 0x8DF1; - static HIGH_FLOAT : 0x8DF2; - HIGH_FLOAT : 0x8DF2; - static LOW_INT : 0x8DF3; - LOW_INT : 0x8DF3; - static MEDIUM_INT : 0x8DF4; - MEDIUM_INT : 0x8DF4; - static HIGH_INT : 0x8DF5; - HIGH_INT : 0x8DF5; - static FRAMEBUFFER : 0x8D40; - FRAMEBUFFER : 0x8D40; - static RENDERBUFFER : 0x8D41; - RENDERBUFFER : 0x8D41; - static RGBA4 : 0x8056; - RGBA4 : 0x8056; - static RGB5_A1 : 0x8057; - RGB5_A1 : 0x8057; - static RGB565 : 0x8D62; - RGB565 : 0x8D62; - static DEPTH_COMPONENT16 : 0x81A5; - DEPTH_COMPONENT16 : 0x81A5; - static STENCIL_INDEX : 0x1901; - STENCIL_INDEX : 0x1901; - static STENCIL_INDEX8 : 0x8D48; - STENCIL_INDEX8 : 0x8D48; - static DEPTH_STENCIL : 0x84F9; - DEPTH_STENCIL : 0x84F9; - static RENDERBUFFER_WIDTH : 0x8D42; - RENDERBUFFER_WIDTH : 0x8D42; - static RENDERBUFFER_HEIGHT : 0x8D43; - RENDERBUFFER_HEIGHT : 0x8D43; - static RENDERBUFFER_INTERNAL_FORMAT : 0x8D44; - RENDERBUFFER_INTERNAL_FORMAT : 0x8D44; - static RENDERBUFFER_RED_SIZE : 0x8D50; - RENDERBUFFER_RED_SIZE : 0x8D50; - static RENDERBUFFER_GREEN_SIZE : 0x8D51; - RENDERBUFFER_GREEN_SIZE : 0x8D51; - static RENDERBUFFER_BLUE_SIZE : 0x8D52; - RENDERBUFFER_BLUE_SIZE : 0x8D52; - static RENDERBUFFER_ALPHA_SIZE : 0x8D53; - RENDERBUFFER_ALPHA_SIZE : 0x8D53; - static RENDERBUFFER_DEPTH_SIZE : 0x8D54; - RENDERBUFFER_DEPTH_SIZE : 0x8D54; - static RENDERBUFFER_STENCIL_SIZE : 0x8D55; - RENDERBUFFER_STENCIL_SIZE : 0x8D55; - static FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE : 0x8CD0; - FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE : 0x8CD0; - static FRAMEBUFFER_ATTACHMENT_OBJECT_NAME : 0x8CD1; - FRAMEBUFFER_ATTACHMENT_OBJECT_NAME : 0x8CD1; - static FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL : 0x8CD2; - FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL : 0x8CD2; - static FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE : 0x8CD3; - FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE : 0x8CD3; - static COLOR_ATTACHMENT0 : 0x8CE0; - COLOR_ATTACHMENT0 : 0x8CE0; - static DEPTH_ATTACHMENT : 0x8D00; - DEPTH_ATTACHMENT : 0x8D00; - static STENCIL_ATTACHMENT : 0x8D20; - STENCIL_ATTACHMENT : 0x8D20; - static DEPTH_STENCIL_ATTACHMENT : 0x821A; - DEPTH_STENCIL_ATTACHMENT : 0x821A; - static NONE : 0; - NONE : 0; - static FRAMEBUFFER_COMPLETE : 0x8CD5; - FRAMEBUFFER_COMPLETE : 0x8CD5; - static FRAMEBUFFER_INCOMPLETE_ATTACHMENT : 0x8CD6; - FRAMEBUFFER_INCOMPLETE_ATTACHMENT : 0x8CD6; - static FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT : 0x8CD7; - FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT : 0x8CD7; - static FRAMEBUFFER_INCOMPLETE_DIMENSIONS : 0x8CD9; - FRAMEBUFFER_INCOMPLETE_DIMENSIONS : 0x8CD9; - static FRAMEBUFFER_UNSUPPORTED : 0x8CDD; - FRAMEBUFFER_UNSUPPORTED : 0x8CDD; - static FRAMEBUFFER_BINDING : 0x8CA6; - FRAMEBUFFER_BINDING : 0x8CA6; - static RENDERBUFFER_BINDING : 0x8CA7; - RENDERBUFFER_BINDING : 0x8CA7; - static MAX_RENDERBUFFER_SIZE : 0x84E8; - MAX_RENDERBUFFER_SIZE : 0x84E8; - static INVALID_FRAMEBUFFER_OPERATION : 0x0506; - INVALID_FRAMEBUFFER_OPERATION : 0x0506; - static UNPACK_FLIP_Y_WEBGL : 0x9240; - UNPACK_FLIP_Y_WEBGL : 0x9240; - static UNPACK_PREMULTIPLY_ALPHA_WEBGL : 0x9241; - UNPACK_PREMULTIPLY_ALPHA_WEBGL : 0x9241; - static CONTEXT_LOST_WEBGL : 0x9242; - CONTEXT_LOST_WEBGL : 0x9242; - static UNPACK_COLORSPACE_CONVERSION_WEBGL : 0x9243; - UNPACK_COLORSPACE_CONVERSION_WEBGL : 0x9243; - static BROWSER_DEFAULT_WEBGL : 0x9244; - BROWSER_DEFAULT_WEBGL : 0x9244; - - canvas: HTMLCanvasElement; - drawingBufferWidth: number; - drawingBufferHeight: number; - - getContextAttributes(): ?WebGLContextAttributes; - isContextLost(): boolean; - - getSupportedExtensions(): ?Array; - getExtension(name: string): any; - - activeTexture(texture: number): void; - attachShader(program: WebGLProgram, shader: WebGLShader): void; - bindAttribLocation(program: WebGLProgram, index: number, name: string): void; - bindBuffer(target: number, buffer: ?WebGLBuffer): void; - bindFramebuffer(target: number, framebuffer: ?WebGLFramebuffer): void; - bindRenderbuffer(target: number, renderbuffer: ?WebGLRenderbuffer): void; - bindTexture(target: number, texture: ?WebGLTexture): void; - blendColor(red: number, green: number, blue: number, alpha: number): void; - blendEquation(mode: number): void; - blendEquationSeparate(modeRGB: number, modeAlpha: number): void; - blendFunc(sfactor: number, dfactor: number): void; - blendFuncSeparate(srcRGB: number, dstRGB: number, srcAlpha: number, dstAlpha: number): void; - - bufferData(target: number, size: number, usage: number): void; - bufferData(target: number, data: ?ArrayBuffer, usage: number): void; - bufferData(target: number, data: $ArrayBufferView, usage: number): void; - bufferSubData(target: number, offset: number, data: BufferDataSource): void; - - checkFramebufferStatus(target: number): number; - clear(mask: number): void; - clearColor(red: number, green: number, blue: number, alpha: number): void; - clearDepth(depth: number): void; - clearStencil(s: number): void; - colorMask(red: boolean, green: boolean, blue: boolean, alpha: boolean): void; - compileShader(shader: WebGLShader): void; - - compressedTexImage2D(target: number, level: number, internalformat: number, - width: number, height: number, border: number, - data: $ArrayBufferView): void; - - compressedTexSubImage2D(target: number, level: number, - xoffset: number, yoffset: number, - width: number, height: number, format: number, - data: $ArrayBufferView): void; - - copyTexImage2D(target: number, level: number, internalformat: number, - x: number, y: number, width: number, height: number, - border: number): void; - copyTexSubImage2D(target: number, level: number, xoffset: number, yoffset: number, - x: number, y: number, width: number, height: number): void; - - createBuffer(): ?WebGLBuffer; - createFramebuffer(): ?WebGLFramebuffer; - createProgram(): ?WebGLProgram; - createRenderbuffer(): ?WebGLRenderbuffer; - createShader(type: number): ?WebGLShader; - createTexture(): ?WebGLTexture; - - cullFace(mode: number): void; - - deleteBuffer(buffer: ?WebGLBuffer): void; - deleteFramebuffer(framebuffer: ?WebGLFramebuffer): void; - deleteProgram(program: ?WebGLProgram): void; - deleteRenderbuffer(renderbuffer: ?WebGLRenderbuffer): void; - deleteShader(shader: ?WebGLShader): void; - deleteTexture(texture: ?WebGLTexture): void; - - depthFunc(func: number): void; - depthMask(flag: boolean): void; - depthRange(zNear: number, zFar: number): void; - detachShader(program: WebGLProgram, shader: WebGLShader): void; - disable(cap: number): void; - disableVertexAttribArray(index: number): void; - drawArrays(mode: number, first: number, count: number): void; - drawElements(mode: number, count: number, type: number, offset: number): void; - - enable(cap: number): void; - enableVertexAttribArray(index: number): void; - finish(): void; - flush(): void; - framebufferRenderbuffer(target: number, attachment: number, - renderbuffertarget: number, - renderbuffer: ?WebGLRenderbuffer): void; - framebufferTexture2D(target: number, attachment: number, textarget: number, - texture: ?WebGLTexture, level: number): void; - frontFace(mode: number): void; - - generateMipmap(target: number): void; - - getActiveAttrib(program: WebGLProgram, index: number): ?WebGLActiveInfo; - getActiveUniform(program: WebGLProgram, index: number): ?WebGLActiveInfo; - getAttachedShaders(program: WebGLProgram): ?Array; - - getAttribLocation(program: WebGLProgram, name: string): number; - - getBufferParameter(target: number, pname: number): any; - getParameter(pname: number): any; - - getError(): number; - - getFramebufferAttachmentParameter(target: number, attachment: number, - pname: number): any; - getProgramParameter(program: WebGLProgram, pname: number): any; - getProgramInfoLog(program: WebGLProgram): ?string; - getRenderbufferParameter(target: number, pname: number): any; - getShaderParameter(shader: WebGLShader, pname: number): any; - getShaderPrecisionFormat(shadertype: number, precisiontype: number): ?WebGLShaderPrecisionFormat; - getShaderInfoLog(shader: WebGLShader): ?string; - - getShaderSource(shader: WebGLShader): ?string; - - getTexParameter(target: number, pname: number): any; - - getUniform(program: WebGLProgram, location: WebGLUniformLocation): any; - - getUniformLocation(program: WebGLProgram, name: string): ?WebGLUniformLocation; - - getVertexAttrib(index: number, pname: number): any; - - getVertexAttribOffset(index: number, pname: number): number; - - hint(target: number, mode: number): void; - isBuffer(buffer: ?WebGLBuffer): boolean; - isEnabled(cap: number): boolean; - isFramebuffer(framebuffer: ?WebGLFramebuffer): boolean; - isProgram(program: ?WebGLProgram): boolean; - isRenderbuffer(renderbuffer: ?WebGLRenderbuffer): boolean; - isShader(shader: ?WebGLShader): boolean; - isTexture(texture: ?WebGLTexture): boolean; - lineWidth(width: number): void; - linkProgram(program: WebGLProgram): void; - pixelStorei(pname: number, param: number): void; - polygonOffset(factor: number, units: number): void; - - readPixels(x: number, y: number, width: number, height: number, - format: number, type: number, pixels: ?$ArrayBufferView): void; - - renderbufferStorage(target: number, internalformat: number, - width: number, height: number): void; - sampleCoverage(value: number, invert: boolean): void; - scissor(x: number, y: number, width: number, height: number): void; - - shaderSource(shader: WebGLShader, source: string): void; - - stencilFunc(func: number, ref: number, mask: number): void; - stencilFuncSeparate(face: number, func: number, ref: number, mask: number): void; - stencilMask(mask: number): void; - stencilMaskSeparate(face: number, mask: number): void; - stencilOp(fail: number, zfail: number, zpass: number): void; - stencilOpSeparate(face: number, fail: number, zfail: number, zpass: number): void; - - texImage2D(target: number, level: number, internalformat: number, - width: number, height: number, border: number, format: number, - type: number, pixels: ?$ArrayBufferView): void; - texImage2D(target: number, level: number, internalformat: number, - format: number, type: number, source: TexImageSource): void; - - texParameterf(target: number, pname: number, param: number): void; - texParameteri(target: number, pname: number, param: number): void; - - texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, - width: number, height: number, - format: number, type: number, pixels: ?$ArrayBufferView): void; - texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, - format: number, type: number, source: TexImageSource): void; - - uniform1f(location: ?WebGLUniformLocation, x: number): void; - uniform1fv(location: ?WebGLUniformLocation, v: Float32Array): void; - uniform1fv(location: ?WebGLUniformLocation, v: Array): void; - uniform1fv(location: ?WebGLUniformLocation, v: [number]): void; - uniform1i(location: ?WebGLUniformLocation, x: number): void; - uniform1iv(location: ?WebGLUniformLocation, v: Int32Array): void; - uniform1iv(location: ?WebGLUniformLocation, v: Array): void; - uniform1iv(location: ?WebGLUniformLocation, v: [number]): void; - uniform2f(location: ?WebGLUniformLocation, x: number, y: number): void; - uniform2fv(location: ?WebGLUniformLocation, v: Float32Array): void; - uniform2fv(location: ?WebGLUniformLocation, v: Array): void; - uniform2fv(location: ?WebGLUniformLocation, v: [number, number]): void; - uniform2i(location: ?WebGLUniformLocation, x: number, y: number): void; - uniform2iv(location: ?WebGLUniformLocation, v: Int32Array): void; - uniform2iv(location: ?WebGLUniformLocation, v: Array): void; - uniform2iv(location: ?WebGLUniformLocation, v: [number, number]): void; - uniform3f(location: ?WebGLUniformLocation, x: number, y: number, z: number): void; - uniform3fv(location: ?WebGLUniformLocation, v: Float32Array): void; - uniform3fv(location: ?WebGLUniformLocation, v: Array): void; - uniform3fv(location: ?WebGLUniformLocation, v: [number, number, number]): void; - uniform3i(location: ?WebGLUniformLocation, x: number, y: number, z: number): void; - uniform3iv(location: ?WebGLUniformLocation, v: Int32Array): void; - uniform3iv(location: ?WebGLUniformLocation, v: Array): void; - uniform3iv(location: ?WebGLUniformLocation, v: [number, number, number]): void; - uniform4f(location: ?WebGLUniformLocation, x: number, y: number, z: number, w: number): void; - uniform4fv(location: ?WebGLUniformLocation, v: Float32Array): void; - uniform4fv(location: ?WebGLUniformLocation, v: Array): void; - uniform4fv(location: ?WebGLUniformLocation, v: [number, number, number, number]): void; - uniform4i(location: ?WebGLUniformLocation, x: number, y: number, z: number, w: number): void; - uniform4iv(location: ?WebGLUniformLocation, v: Int32Array): void; - uniform4iv(location: ?WebGLUniformLocation, v: Array): void; - uniform4iv(location: ?WebGLUniformLocation, v: [number, number, number, number]): void; - - uniformMatrix2fv(location: ?WebGLUniformLocation, transpose: boolean, - value: Float32Array): void; - uniformMatrix2fv(location: ?WebGLUniformLocation, transpose: boolean, - value: Array): void; - uniformMatrix3fv(location: ?WebGLUniformLocation, transpose: boolean, - value: Float32Array): void; - uniformMatrix3fv(location: ?WebGLUniformLocation, transpose: boolean, - value: Array): void; - uniformMatrix4fv(location: ?WebGLUniformLocation, transpose: boolean, - value: Float32Array): void; - uniformMatrix4fv(location: ?WebGLUniformLocation, transpose: boolean, - value: Array): void; - - useProgram(program: ?WebGLProgram): void; - validateProgram(program: WebGLProgram): void; - - vertexAttrib1f(index: number, x: number): void; - vertexAttrib1fv(index: number, values: VertexAttribFVSource): void; - vertexAttrib2f(index: number, x: number, y: number): void; - vertexAttrib2fv(index: number, values: VertexAttribFVSource): void; - vertexAttrib3f(index: number, x: number, y: number, z: number): void; - vertexAttrib3fv(index: number, values: VertexAttribFVSource): void; - vertexAttrib4f(index: number, x: number, y: number, z: number, w: number): void; - vertexAttrib4fv(index: number, values: VertexAttribFVSource): void; - vertexAttribPointer(index: number, size: number, type: number, - normalized: boolean, stride: number, offset: number): void; - - viewport(x: number, y: number, width: number, height: number): void; -}; - -declare class WebGLContextEvent extends Event { - statusMessage: string; -}; - -// http://www.w3.org/TR/html5/scripting-1.html#renderingcontext -type RenderingContext = CanvasRenderingContext2D | WebGLRenderingContext; - -// https://www.w3.org/TR/html5/scripting-1.html#htmlcanvaselement -declare class HTMLCanvasElement extends HTMLElement { - tagName: 'CANVAS'; - width: number; - height: number; - getContext(contextId: "2d", ...args: any): CanvasRenderingContext2D; - getContext(contextId: "webgl", contextAttributes?: Partial): ?WebGLRenderingContext; - // IE currently only supports "experimental-webgl" - getContext(contextId: "experimental-webgl", contextAttributes?: Partial): ?WebGLRenderingContext; - getContext(contextId: string, ...args: any): ?RenderingContext; // fallback - toDataURL(type?: string, ...args: any): string; - toBlob(callback: (v: File) => void, type?: string, ...args: any): void; - captureStream(frameRate?: number): CanvasCaptureMediaStream; -} - -// https://html.spec.whatwg.org/multipage/forms.html#the-details-element -declare class HTMLDetailsElement extends HTMLElement { - tagName: 'DETAILS'; - open: boolean; -} - -declare class HTMLFormElement extends HTMLElement { - tagName: 'FORM'; - @@iterator(): Iterator; - [index: number | string]: HTMLElement | null; - acceptCharset: string; - action: string; - elements: HTMLCollection; - encoding: string; - enctype: string; - length: number; - method: string; - name: string; - rel: string; - target: string; - - checkValidity(): boolean; - reportValidity(): boolean; - reset(): void; - submit(): void; -} - -// https://www.w3.org/TR/html5/forms.html#the-fieldset-element -declare class HTMLFieldSetElement extends HTMLElement { - tagName: 'FIELDSET'; - disabled: boolean; - elements: HTMLCollection; // readonly - form: HTMLFormElement | null; // readonly - name: string; - type: string; // readonly - - checkValidity(): boolean; - setCustomValidity(error: string): void; -} - -declare class HTMLLegendElement extends HTMLElement { - tagName: 'LEGEND'; - form: HTMLFormElement | null; // readonly -} - -declare class HTMLIFrameElement extends HTMLElement { - tagName: 'IFRAME'; - allowFullScreen: boolean; - contentDocument: Document; - contentWindow: any; - frameBorder: string; - height: string; - marginHeight: string; - marginWidth: string; - name: string; - scrolling: string; - sandbox: DOMTokenList; - src: string; - // flowlint unsafe-getters-setters:off - get srcdoc(): string; - set srcdoc(value: string | TrustedHTML): void; - // flowlint unsafe-getters-setters:error - width: string; -} - -declare class HTMLImageElement extends HTMLElement { - tagName: 'IMG'; - alt: string; - complete: boolean; // readonly - crossOrigin: ?string; - currentSrc: string; // readonly - height: number; - decode(): Promise; - isMap: boolean; - naturalHeight: number; // readonly - naturalWidth: number; // readonly - sizes: string; - src: string; - srcset: string; - useMap: string; - width: number; -} - -declare class Image extends HTMLImageElement { - constructor(width?: number, height?: number): void; -} - -declare class MediaError { - MEDIA_ERR_ABORTED: number; - MEDIA_ERR_NETWORK: number; - MEDIA_ERR_DECODE: number; - MEDIA_ERR_SRC_NOT_SUPPORTED: number; - code: number; - message: ?string; -} - -declare class TimeRanges { - length: number; - start(index: number): number; - end(index: number): number; -} -declare class Audio extends HTMLAudioElement { - constructor(URLString?: string): void; -} - -declare class AudioTrack { - id: string; - kind: string; - label: string; - language: string; - enabled: boolean; -} - -declare class AudioTrackList extends EventTarget { - length: number; - [index: number]: AudioTrack; - - getTrackById(id: string): ?AudioTrack; - - onchange: (ev: any) => any; - onaddtrack: (ev: any) => any; - onremovetrack: (ev: any) => any; -} - -declare class VideoTrack { - id: string; - kind: string; - label: string; - language: string; - selected: boolean; -} - -declare class VideoTrackList extends EventTarget { - length: number; - [index: number]: VideoTrack; - getTrackById(id: string): ?VideoTrack; - selectedIndex: number; - - onchange: (ev: any) => any; - onaddtrack: (ev: any) => any; - onremovetrack: (ev: any) => any; -} - -declare class TextTrackCue extends EventTarget { - constructor(startTime: number, endTime: number, text: string): void; - - track: TextTrack; - id: string; - startTime: number; - endTime: number; - pauseOnExit: boolean; - vertical: string; - snapToLines: boolean; - lines: number; - position: number; - size: number; - align: string; - text: string; - - getCueAsHTML(): Node; - onenter: (ev: any) => any; - onexit: (ev: any) => any; -} - -declare class TextTrackCueList { - @@iterator(): Iterator; - length: number; - [index: number]: TextTrackCue; - getCueById(id: string): ?TextTrackCue; -} - -declare class TextTrack extends EventTarget { - kind: string; - label: string; - language: string; - - mode: string; - - cues: TextTrackCueList; - activeCues: TextTrackCueList; - - addCue(cue: TextTrackCue): void; - removeCue(cue: TextTrackCue): void; - - oncuechange: (ev: any) => any; -} - -declare class TextTrackList extends EventTarget { - length: number; - [index: number]: TextTrack; - - onaddtrack: (ev: any) => any; - onremovetrack: (ev: any) => any; -} - -declare class MediaKeyStatusMap { - @@iterator(): Iterator<[BufferDataSource, MediaKeyStatus]>; - size: number; - entries(): Iterator<[BufferDataSource, MediaKeyStatus]>; - forEach(callbackfn: (value: MediaKeyStatus, key: BufferDataSource, map: MediaKeyStatusMap) => any, thisArg?: any): void; - get(key: BufferDataSource): MediaKeyStatus; - has(key: BufferDataSource): boolean; - keys(): Iterator; - values(): Iterator; -} - -declare class MediaKeySession extends EventTarget { - sessionId: string; - expiration: number; - closed: Promise; - keyStatuses: MediaKeyStatusMap; - - generateRequest(initDataType: string, initData: BufferDataSource): Promise; - load(sessionId: string): Promise; - update(response: BufferDataSource): Promise; - close(): Promise; - remove(): Promise; - - onkeystatuschange: (ev: any) => any; - onmessage: (ev: any) => any; -} - -declare class MediaKeys { - createSession(mediaKeySessionType: MediaKeySessionType): MediaKeySession; - setServerCertificate(serverCertificate: BufferDataSource): Promise; -} - -declare class HTMLMediaElement extends HTMLElement { - // error state - error: ?MediaError; - - // network state - src: string; - srcObject: ?any; - currentSrc: string; - crossOrigin: ?string; - NETWORK_EMPTY: number; - NETWORK_IDLE: number; - NETWORK_LOADING: number; - NETWORK_NO_SOURCE: number; - networkState: number; - preload: string; - buffered: TimeRanges; - load(): void; - canPlayType(type: string): string; - - // ready state - HAVE_NOTHING: number; - HAVE_METADATA: number; - HAVE_CURRENT_DATA: number; - HAVE_FUTURE_DATA: number; - HAVE_ENOUGH_DATA: number; - readyState: number; - seeking: boolean; - - // playback state - currentTime: number; - duration: number; - startDate: Date; - paused: boolean; - defaultPlaybackRate: number; - playbackRate: number; - played: TimeRanges; - seekable: TimeRanges; - ended: boolean; - autoplay: boolean; - loop: boolean; - play(): Promise; - pause(): void; - fastSeek(): void; - captureStream(): MediaStream; - - // media controller - mediaGroup: string; - controller: ?any; - - // controls - controls: boolean; - volume: number; - muted: boolean; - defaultMuted: boolean; - controlsList?: DOMTokenList; - - // tracks - audioTracks: AudioTrackList; - videoTracks: VideoTrackList; - textTracks: TextTrackList; - addTextTrack(kind: string, label?: string, language?: string): TextTrack; - - // media keys - mediaKeys?: ?MediaKeys; - setMediakeys?: (mediakeys: ?MediaKeys) => Promise; -} - -declare class HTMLAudioElement extends HTMLMediaElement { - tagName: 'AUDIO'; -} - -declare class HTMLVideoElement extends HTMLMediaElement { - tagName: 'VIDEO'; - width: number; - height: number; - videoWidth: number; - videoHeight: number; - poster: string; -} - -declare class HTMLSourceElement extends HTMLElement { - tagName: 'SOURCE'; - src: string; - type: string; - - //when used with the picture element - srcset: string; - sizes: string; - media: string; -} - -declare class ValidityState { - badInput: boolean; - customError: boolean; - patternMismatch: boolean; - rangeOverflow: boolean; - rangeUnderflow: boolean; - stepMismatch: boolean; - tooLong: boolean; - tooShort: boolean; - typeMismatch: boolean; - valueMissing: boolean; - valid: boolean; -} - -// https://w3c.github.io/html/sec-forms.html#dom-selectionapielements-setselectionrange -type SelectionDirection = 'backward' | 'forward' | 'none'; -type SelectionMode = 'select' | 'start' | 'end' | 'preserve'; -declare class HTMLInputElement extends HTMLElement { - tagName: 'INPUT'; - accept: string; - align: string; - alt: string; - autocomplete: string; - autofocus: boolean; - border: string; - checked: boolean; - complete: boolean; - defaultChecked: boolean; - defaultValue: string; - dirname: string; - disabled: boolean; - dynsrc: string; - files: FileList; - form: HTMLFormElement | null; - formAction: string; - formEncType: string; - formMethod: string; - formNoValidate: boolean; - formTarget: string; - height: string; - hspace: number; - indeterminate: boolean; - labels: NodeList; - list: HTMLElement | null; - loop: number; - lowsrc: string; - max: string; - maxLength: number; - min: string; - multiple: boolean; - name: string; - pattern: string; - placeholder: string; - readOnly: boolean; - required: boolean; - selectionDirection: SelectionDirection; - selectionEnd: number; - selectionStart: number; - size: number; - src: string; - start: string; - status: boolean; - step: string; - type: string; - useMap: string; - validationMessage: string; - validity: ValidityState; - value: string; - valueAsDate: Date; - valueAsNumber: number; - vrml: string; - vspace: number; - width: string; - willValidate: boolean; - - checkValidity(): boolean; - reportValidity(): boolean; - setCustomValidity(error: string): void; - createTextRange(): TextRange; - select(): void; - setRangeText(replacement: string, start?: void, end?: void, selectMode?: void): void; - setRangeText(replacement: string, start: number, end: number, selectMode?: SelectionMode): void; - setSelectionRange(start: number, end: number, direction?: SelectionDirection): void; - showPicker(): void; - stepDown(stepDecrement?: number): void; - stepUp(stepIncrement?: number): void; -} - -declare class HTMLButtonElement extends HTMLElement { - tagName: 'BUTTON'; - autofocus: boolean; - disabled: boolean; - form: HTMLFormElement | null; - labels: NodeList | null; - name: string; - type: string; - validationMessage: string; - validity: ValidityState; - value: string; - willValidate: boolean; - - checkValidity(): boolean; - reportValidity(): boolean; - setCustomValidity(error: string): void; -} - -// https://w3c.github.io/html/sec-forms.html#the-textarea-element -declare class HTMLTextAreaElement extends HTMLElement { - tagName: 'TEXTAREA'; - autofocus: boolean; - cols: number; - dirName: string; - disabled: boolean; - form: HTMLFormElement | null; - maxLength: number; - name: string; - placeholder: string; - readOnly: boolean; - required: boolean; - rows: number; - wrap: string; - - type: string; - defaultValue: string; - value: string; - textLength: number; - - willValidate: boolean; - validity: ValidityState; - validationMessage: string; - checkValidity(): boolean; - setCustomValidity(error: string): void; - - labels: NodeList; - - select(): void; - selectionStart: number; - selectionEnd: number; - selectionDirection: SelectionDirection; - setSelectionRange(start: number, end: number, direction?: SelectionDirection): void; -} - -declare class HTMLSelectElement extends HTMLElement { - tagName: 'SELECT'; - autocomplete: string; - autofocus: boolean; - disabled: boolean; - form: HTMLFormElement | null; - labels: NodeList; - length: number; - multiple: boolean; - name: string; - options: HTMLOptionsCollection; - required: boolean; - selectedIndex: number; - selectedOptions: HTMLCollection; - size: number; - type: string; - validationMessage: string; - validity: ValidityState; - value: string; - willValidate: boolean; - - add(element: HTMLElement, before?: HTMLElement): void; - checkValidity(): boolean; - item(index: number): HTMLOptionElement | null; - namedItem(name: string): HTMLOptionElement | null; - remove(index?: number): void; - setCustomValidity(error: string): void; -} - -declare class HTMLOptionsCollection extends HTMLCollection { - selectedIndex: number; - add(element: HTMLOptionElement | HTMLOptGroupElement, before?: HTMLElement | number): void; - remove(index: number): void; -} - -declare class HTMLOptionElement extends HTMLElement { - tagName: 'OPTION'; - defaultSelected: boolean; - disabled: boolean; - form: HTMLFormElement | null; - index: number; - label: string; - selected: boolean; - text: string; - value: string; -} - -declare class HTMLOptGroupElement extends HTMLElement { - tagName: 'OPTGROUP'; - disabled: boolean; - label: string; -} - -declare class HTMLAnchorElement extends HTMLElement { - tagName: 'A'; - charset: string; - coords: string; - download: string; - hash: string; - host: string; - hostname: string; - href: string; - hreflang: string; - media: string; - name: string; - origin: string; - password: string; - pathname: string; - port: string; - protocol: string; - rel: string; - rev: string; - search: string; - shape: string; - target: string; - text: string; - type: string; - username: string; -} - -// https://w3c.github.io/html/sec-forms.html#the-label-element -declare class HTMLLabelElement extends HTMLElement { - tagName: 'LABEL'; - form: HTMLFormElement | null; - htmlFor: string; - control: HTMLElement | null; -} - -declare class HTMLLinkElement extends HTMLElement { - tagName: 'LINK'; - crossOrigin: ?('anonymous' | 'use-credentials'); - href: string; - hreflang: string; - media: string; - rel: string; - sizes: DOMTokenList; - type: string; - as: string; -} - -declare class HTMLScriptElement extends HTMLElement { - tagName: 'SCRIPT'; - async: boolean; - charset: string; - crossOrigin?: string; - defer: boolean; - // flowlint unsafe-getters-setters:off - get src(): string; - set src(value: string | TrustedScriptURL): void; - get text(): string; - set text(value: string | TrustedScript): void; - // flowlint unsafe-getters-setters:error - type: string; -} - -declare class HTMLStyleElement extends HTMLElement { - tagName: 'STYLE'; - disabled: boolean; - media: string; - scoped: boolean; - sheet: ?CSSStyleSheet; - type: string; -} - -declare class HTMLParagraphElement extends HTMLElement { - tagName: 'P'; - align: 'left' | 'center' | 'right' | 'justify'; // deprecated in HTML 4.01 -} - -declare class HTMLHtmlElement extends HTMLElement { - tagName: 'HTML'; -} - -declare class HTMLBodyElement extends HTMLElement { - tagName: 'BODY'; -} - -declare class HTMLHeadElement extends HTMLElement { - tagName: 'HEAD'; -} - -declare class HTMLDivElement extends HTMLElement { - tagName: 'DIV'; -} - -declare class HTMLSpanElement extends HTMLElement { - tagName: 'SPAN'; -} - -declare class HTMLAppletElement extends HTMLElement {} - -declare class HTMLHeadingElement extends HTMLElement { - tagName: 'H1' | 'H2' | 'H3' | 'H4' | 'H5' | 'H6'; -} - -declare class HTMLHRElement extends HTMLElement { - tagName: 'HR'; -} - -declare class HTMLBRElement extends HTMLElement { - tagName: 'BR'; -} - -declare class HTMLDListElement extends HTMLElement { - tagName: 'DL'; -} - -declare class HTMLAreaElement extends HTMLElement { - tagName: 'AREA'; - alt: string; - coords: string; - shape: string; - target: string; - download: string; - ping: string; - rel: string; - relList: DOMTokenList; - referrerPolicy: string; -} - -declare class HTMLDataElement extends HTMLElement { - tagName: 'DATA'; - value: string; -} - -declare class HTMLDataListElement extends HTMLElement { - tagName: 'DATALIST'; - options: HTMLCollection; -} - -declare class HTMLDialogElement extends HTMLElement { - tagName: 'DIALOG'; - open: boolean; - returnValue: string; - show(): void; - showModal(): void; - close(returnValue: ?string): void; -} - -declare class HTMLEmbedElement extends HTMLElement { - tagName: 'EMBED'; - src: string; - type: string; - width: string; - height: string; - getSVGDocument(): ?Document; -} - -declare class HTMLMapElement extends HTMLElement { - tagName: 'MAP'; - areas: HTMLCollection; - images: HTMLCollection; - name: string; -} - -declare class HTMLMeterElement extends HTMLElement { - tagName: 'METER'; - high: number; - low: number; - max: number; - min: number; - optimum: number; - value: number; - labels: NodeList; -} - -declare class HTMLModElement extends HTMLElement { - tagName: 'DEL' | 'INS'; - cite: string; - dateTime: string; -} - -declare class HTMLObjectElement extends HTMLElement { - tagName: 'OBJECT'; - contentDocument: ?Document; - contentWindow: ?WindowProxy; - data: string; - form: ?HTMLFormElement; - height: string; - name: string; - type: string; - typeMustMatch: boolean; - useMap: string; - validationMessage: string; - validity: ValidityState; - width: string; - willValidate: boolean; - checkValidity(): boolean; - getSVGDocument(): ?Document; - reportValidity(): boolean; - setCustomValidity(error: string): void; -} - -declare class HTMLOutputElement extends HTMLElement { - defaultValue: string; - form: ?HTMLFormElement; - htmlFor: DOMTokenList; - labels: NodeList; - name: string; - type: string; - validationMessage: string; - validity: ValidityState; - value: string; - willValidate: boolean; - checkValidity(): boolean; - reportValidity(): boolean; - setCustomValidity(error: string): void; -} - -declare class HTMLParamElement extends HTMLElement { - tagName: 'PARAM'; - name: string; - value: string; -} - -declare class HTMLProgressElement extends HTMLElement { - tagName: 'PROGRESS'; - labels: NodeList; - max: number; - position: number; - value: number; -} - -declare class HTMLPictureElement extends HTMLElement { - tagName: 'PICTURE'; -} - -declare class HTMLTimeElement extends HTMLElement { - tagName: 'TIME'; - dateTime: string; -} - -declare class HTMLTitleElement extends HTMLElement { - tagName: 'TITLE'; - text: string; -} - -declare class HTMLTrackElement extends HTMLElement { - tagName: 'TRACK'; - static NONE: 0; - static LOADING: 1; - static LOADED: 2; - static ERROR: 3; - - default: boolean; - kind: string; - label: string; - readyState: 0 | 1 | 2 | 3; - src: string; - srclang: string; - track: TextTrack; -} - -declare class HTMLQuoteElement extends HTMLElement { - tagName: 'BLOCKQUOTE' | 'Q'; - cite: string; -} - -declare class HTMLOListElement extends HTMLElement { - tagName: 'OL'; - reversed: boolean; - start: number; - type: string; -} - -declare class HTMLUListElement extends HTMLElement { - tagName: 'UL'; -} - -declare class HTMLLIElement extends HTMLElement { - tagName: 'LI'; - value: number; -} - -declare class HTMLPreElement extends HTMLElement { - tagName: 'PRE'; -} - -declare class HTMLMetaElement extends HTMLElement { - tagName: 'META'; - content: string; - httpEquiv: string; - name: string; -} - -declare class HTMLUnknownElement extends HTMLElement {} - -declare class TextRange { - boundingLeft: number; - htmlText: string; - offsetLeft: number; - boundingWidth: number; - boundingHeight: number; - boundingTop: number; - text: string; - offsetTop: number; - moveToPoint(x: number, y: number): void; - queryCommandValue(cmdID: string): any; - getBookmark(): string; - move(unit: string, count?: number): number; - queryCommandIndeterm(cmdID: string): boolean; - scrollIntoView(fStart?: boolean): void; - findText(string: string, count?: number, flags?: number): boolean; - execCommand(cmdID: string, showUI?: boolean, value?: any): boolean; - getBoundingClientRect(): DOMRect; - moveToBookmark(bookmark: string): boolean; - isEqual(range: TextRange): boolean; - duplicate(): TextRange; - collapse(start?: boolean): void; - queryCommandText(cmdID: string): string; - select(): void; - pasteHTML(html: string): void; - inRange(range: TextRange): boolean; - moveEnd(unit: string, count?: number): number; - getClientRects(): DOMRectList; - moveStart(unit: string, count?: number): number; - parentElement(): Element; - queryCommandState(cmdID: string): boolean; - compareEndPoints(how: string, sourceRange: TextRange): number; - execCommandShowHelp(cmdID: string): boolean; - moveToElementText(element: Element): void; - expand(Unit: string): boolean; - queryCommandSupported(cmdID: string): boolean; - setEndPoint(how: string, SourceRange: TextRange): void; - queryCommandEnabled(cmdID: string): boolean; -} - -// These types used to exist as a copy of DOMRect/DOMRectList, which is -// incorrect because there are no ClientRect/ClientRectList globals on the DOM. -// Keep these as type aliases for backwards compatibility. -declare type ClientRect = DOMRect; -declare type ClientRectList = DOMRectList; - -// TODO: HTML*Element - -declare class DOMImplementation { - createDocumentType(qualifiedName: string, publicId: string, systemId: string): DocumentType; - createDocument(namespaceURI: string | null, qualifiedName: string, doctype?: DocumentType | null): Document; - hasFeature(feature: string, version?: string): boolean; - - // non-standard - createHTMLDocument(title?: string): Document; -} - -declare class DocumentType extends Node { - name: string; - notations: NamedNodeMap; - systemId: string; - internalSubset: string; - entities: NamedNodeMap; - publicId: string; - - // from ChildNode interface - after(...nodes: Array): void; - before(...nodes: Array): void; - replaceWith(...nodes: Array): void; - remove(): void; -} - -declare class CharacterData extends Node { - length: number; - data: string; - deleteData(offset: number, count: number): void; - replaceData(offset: number, count: number, arg: string): void; - appendData(arg: string): void; - insertData(offset: number, arg: string): void; - substringData(offset: number, count: number): string; - - // from ChildNode interface - after(...nodes: Array): void; - before(...nodes: Array): void; - replaceWith(...nodes: Array): void; - remove(): void; -} - -declare class Text extends CharacterData { - assignedSlot?: HTMLSlotElement; - wholeText: string; - splitText(offset: number): Text; - replaceWholeText(content: string): Text; -} - -declare class Comment extends CharacterData { - text: string; -} - -declare class URL { - static canParse(url: string, base?: string): boolean; - static createObjectURL(blob: Blob): string; - static createObjectURL(mediaSource: MediaSource): string; - static revokeObjectURL(url: string): void; - constructor(url: string, base?: string | URL): void; - hash: string; - host: string; - hostname: string; - href: string; - +origin: string; - password: string; - pathname: string; - port: string; - protocol: string; - search: string; - +searchParams: URLSearchParams; - username: string; - toString(): string; - toJSON(): string; -} - -declare interface MediaSourceHandle { -} - -declare class MediaSource extends EventTarget { - sourceBuffers: SourceBufferList; - activeSourceBuffers: SourceBufferList; - // https://w3c.github.io/media-source/#dom-readystate - readyState: "closed" | "open" | "ended"; - duration: number; - handle: MediaSourceHandle; - addSourceBuffer(type: string): SourceBuffer; - removeSourceBuffer(sourceBuffer: SourceBuffer): void; - endOfStream(error?: string): void; - static isTypeSupported(type: string): boolean; -} - -declare class SourceBuffer extends EventTarget { - mode: "segments" | "sequence"; - updating: boolean; - buffered: TimeRanges; - timestampOffset: number; - audioTracks: AudioTrackList; - videoTracks: VideoTrackList; - textTracks: TextTrackList; - appendWindowStart: number; - appendWindowEnd: number; - - appendBuffer(data: ArrayBuffer | $ArrayBufferView): void; - // TODO: Add ReadableStream - // appendStream(stream: ReadableStream, maxSize?: number): void; - abort(): void; - remove(start: number, end: number): void; - - trackDefaults: TrackDefaultList; -} - -declare class SourceBufferList extends EventTarget { - @@iterator(): Iterator; - [index: number]: SourceBuffer; - length: number; -} - -declare class Storage { - length: number; - getItem(key: string): ?string; - setItem(key: string, data: string): void; - clear(): void; - removeItem(key: string): void; - key(index: number): ?string; - [name: string]: ?string; -} - -declare class TrackDefaultList { - [index: number]: TrackDefault; - length: number; -} - -declare class TrackDefault { - type: "audio" | "video" | "text"; - byteStreamTrackID: string; - language: string; - label: string; - kinds: Array; -} - -// TODO: The use of `typeof` makes this function signature effectively -// (node: Node) => number, but it should be (node: Node) => 1|2|3 -type NodeFilterCallback = (node: Node) => -typeof NodeFilter.FILTER_ACCEPT | -typeof NodeFilter.FILTER_REJECT | -typeof NodeFilter.FILTER_SKIP; - -type NodeFilterInterface = NodeFilterCallback | { acceptNode: NodeFilterCallback, ... } - -// TODO: window.NodeFilter exists at runtime and behaves as a constructor -// as far as `instanceof` is concerned, but it is not callable. -declare class NodeFilter { - static SHOW_ALL: -1; - static SHOW_ELEMENT: 1; - static SHOW_ATTRIBUTE: 2; // deprecated - static SHOW_TEXT: 4; - static SHOW_CDATA_SECTION: 8; // deprecated - static SHOW_ENTITY_REFERENCE: 16; // deprecated - static SHOW_ENTITY: 32; // deprecated - static SHOW_PROCESSING_INSTRUCTION: 64; - static SHOW_COMMENT: 128; - static SHOW_DOCUMENT: 256; - static SHOW_DOCUMENT_TYPE: 512; - static SHOW_DOCUMENT_FRAGMENT: 1024; - static SHOW_NOTATION: 2048; // deprecated - static FILTER_ACCEPT: 1; - static FILTER_REJECT: 2; - static FILTER_SKIP: 3; - acceptNode: NodeFilterCallback; -} - -// TODO: window.NodeIterator exists at runtime and behaves as a constructor -// as far as `instanceof` is concerned, but it is not callable. -declare class NodeIterator { - root: RootNodeT; - whatToShow: number; - filter: NodeFilter; - expandEntityReferences: boolean; - referenceNode: RootNodeT | WhatToShowT; - pointerBeforeReferenceNode: boolean; - detach(): void; - previousNode(): WhatToShowT | null; - nextNode(): WhatToShowT | null; -} - -// TODO: window.TreeWalker exists at runtime and behaves as a constructor -// as far as `instanceof` is concerned, but it is not callable. -declare class TreeWalker { - root: RootNodeT; - whatToShow: number; - filter: NodeFilter; - expandEntityReferences: boolean; - currentNode: RootNodeT | WhatToShowT; - parentNode(): WhatToShowT | null; - firstChild(): WhatToShowT | null; - lastChild(): WhatToShowT | null; - previousSibling(): WhatToShowT | null; - nextSibling(): WhatToShowT | null; - previousNode(): WhatToShowT | null; - nextNode(): WhatToShowT | null; -} - -/* window */ - -declare type WindowProxy = any; diff --git a/lib/streams.js b/lib/streams.js deleted file mode 100644 index 7d418cb4bc6..00000000000 --- a/lib/streams.js +++ /dev/null @@ -1,127 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -type TextEncodeOptions = { options?: boolean, ... }; - -declare class TextEncoder { - encode(buffer: string, options?: TextEncodeOptions): Uint8Array, -} - -declare class ReadableStreamController { - constructor( - stream: ReadableStream, - underlyingSource: UnderlyingSource, - size: number, - highWaterMark: number, - ): void, - - desiredSize: number, - - close(): void, - enqueue(chunk: any): void, - error(error: Error): void, -} - -declare class ReadableStreamReader { - constructor(stream: ReadableStream): void, - - closed: boolean, - - cancel(reason: string): void, - read(): Promise<{ - value: ?any, - done: boolean, - ... - }>, - releaseLock(): void, -} - -declare interface UnderlyingSource { - autoAllocateChunkSize?: number, - type?: string, - - start?: (controller: ReadableStreamController) => ?Promise, - pull?: (controller: ReadableStreamController) => ?Promise, - cancel?: (reason: string) => ?Promise, -} - -declare class TransformStream { - readable: ReadableStream, - writable: WritableStream, -}; - -interface PipeThroughTransformStream { - readable: ReadableStream, - writable: WritableStream, -} - -type PipeToOptions = { - preventClose?: boolean, - preventAbort?: boolean, - preventCancel?: boolean, - ... -}; - -type QueuingStrategy = { - highWaterMark: number, - size(chunk: ?any): number, - ... -}; - -declare class ReadableStream { - constructor( - underlyingSource: ?UnderlyingSource, - queuingStrategy: ?QueuingStrategy, - ): void, - - locked: boolean, - - cancel(reason: string): void, - getReader(): ReadableStreamReader, - pipeThrough(transform: PipeThroughTransformStream, options: ?any): void, - pipeTo(dest: WritableStream, options: ?PipeToOptions): Promise, - tee(): [ReadableStream, ReadableStream], -}; - -declare interface WritableStreamController { - error(error: Error): void, -} - -declare interface UnderlyingSink { - autoAllocateChunkSize?: number, - type?: string, - - abort?: (reason: string) => ?Promise, - close?: (controller: WritableStreamController) => ?Promise, - start?: (controller: WritableStreamController) => ?Promise, - write?: (chunk: any, controller: WritableStreamController) => ?Promise, -} - -declare interface WritableStreamWriter { - closed: Promise, - desiredSize?: number, - ready: Promise, - - abort(reason: string): ?Promise, - close(): Promise, - releaseLock(): void, - write(chunk: any): Promise, -} - -declare class WritableStream { - constructor( - underlyingSink: ?UnderlyingSink, - queuingStrategy: QueuingStrategy, - ): void, - - locked: boolean, - - abort(reason: string): void, - getWriter(): WritableStreamWriter, -} diff --git a/newtests/lsp/queries/test.js b/newtests/lsp/queries/test.js index 9eb46f58651..566d46be6de 100644 --- a/newtests/lsp/queries/test.js +++ b/newtests/lsp/queries/test.js @@ -310,7 +310,7 @@ module.exports = (suite( [ [ 'telemetry/rage', - '{Focused: 8,LSP adapter state: Connected,.monitor_log,.log}', + '{Focused: 4,LSP adapter state: Connected,.monitor_log,.log}', ], ], [...lspIgnoreStatusAndCancellation], diff --git a/tests/arrows/arrows.js b/tests/arrows/arrows.js index f25cc0fb3c4..5a69c07f78c 100644 --- a/tests/arrows/arrows.js +++ b/tests/arrows/arrows.js @@ -8,3 +8,7 @@ function selectBestEffortImageForWidth( return images.find(image => image.width >= maxPixelWidth) || images[images.length - 1]; } + +declare class Image { + width: number +} diff --git a/tests/autocomplete_from_m_to_q/autocomplete_from_m_to_q.exp b/tests/autocomplete_from_m_to_q/autocomplete_from_m_to_q.exp index b74419039aa..fb4fe31dfee 100644 --- a/tests/autocomplete_from_m_to_q/autocomplete_from_m_to_q.exp +++ b/tests/autocomplete_from_m_to_q/autocomplete_from_m_to_q.exp @@ -326,13 +326,7 @@ namespace.js:12:12 Flags: --pretty { "result":[ - {"name":"AbortSignal","type":"typeof AbortSignal"}, {"name":"AggregateError","type":"typeof AggregateError"}, - {"name":"Animation","type":"typeof Animation"}, - {"name":"AnimationEffect","type":"typeof AnimationEffect"}, - {"name":"AnimationEvent","type":"typeof AnimationEvent"}, - {"name":"AnimationPlaybackEvent","type":"typeof AnimationPlaybackEvent"}, - {"name":"AnimationTimeline","type":"typeof AnimationTimeline"}, {"name":"Array","type":"typeof Array"}, {"name":"ArrayBuffer","type":"typeof ArrayBuffer"}, {"name":"atob","type":"(encodedString: string) => string"}, @@ -340,170 +334,35 @@ Flags: --pretty "name":"Atomics", "type":"{+[key: $SymbolToStringTag]: \"Atomics\", add(typedArray: $SharedIntegerTypedArray, index: number, value: number): number, and(typedArray: $SharedIntegerTypedArray, index: number, value: number): number, compareExchange(typedArray: $SharedIntegerTypedArray, index: number, expectedValue: number, replacementValue: number): number, exchange(typedArray: $SharedIntegerTypedArray, index: number, value: number): number, isLockFree(size: number): boolean, load(typedArray: $SharedIntegerTypedArray, index: number): number, notify(typedArray: Int32Array, index: number, count: number): number, or(typedArray: $SharedIntegerTypedArray, index: number, value: number): number, store(typedArray: $SharedIntegerTypedArray, index: number, value: number): number, sub(typedArray: $SharedIntegerTypedArray, index: number, value: number): number, wait(typedArray: Int32Array, index: number, value: number, timeout?: number): \"ok\" | \"not-equal\" | \"timed-out\", xor(typedArray: $SharedIntegerTypedArray, index: number, value: number): number}" }, - {"name":"Attr","type":"typeof Attr"}, - {"name":"Audio","type":"typeof Audio"}, - {"name":"AudioTrack","type":"typeof AudioTrack"}, - {"name":"AudioTrackList","type":"typeof AudioTrackList"}, - {"name":"BeforeUnloadEvent","type":"typeof BeforeUnloadEvent"}, {"name":"BigInt","type":"typeof BigInt"}, {"name":"BigInt64Array","type":"typeof BigInt64Array"}, {"name":"BigUint64Array","type":"typeof BigUint64Array"}, - {"name":"Blob","type":"typeof Blob"}, {"name":"Boolean","type":"typeof Boolean"}, - {"name":"BroadcastChannel","type":"typeof BroadcastChannel"}, {"name":"btoa","type":"(rawString: string) => string"}, {"name":"CallSite","type":"typeof CallSite"}, - {"name":"CanvasCaptureMediaStream","type":"typeof CanvasCaptureMediaStream"}, - {"name":"CanvasDrawingStyles","type":"typeof CanvasDrawingStyles"}, - {"name":"CanvasGradient","type":"typeof CanvasGradient"}, - {"name":"CanvasPattern","type":"typeof CanvasPattern"}, - {"name":"CanvasRenderingContext2D","type":"typeof CanvasRenderingContext2D"}, - {"name":"CharacterData","type":"typeof CharacterData"}, {"name":"clearInterval","type":"(intervalId: ?IntervalID) => void"}, {"name":"clearTimeout","type":"(timeoutId: ?TimeoutID) => void"}, - {"name":"ClipboardEvent","type":"typeof ClipboardEvent"}, - {"name":"ClipboardItem","type":"typeof ClipboardItem"}, - {"name":"Comment","type":"typeof Comment"}, - {"name":"CompositionEvent","type":"typeof CompositionEvent"}, { "name":"console", "type":"{_exception(...data: Array): void, assert(condition: mixed, ...data: Array): void, clear(): void, count(label?: string): void, countReset(label?: string): void, debug(...data: Array): void, dir(...data: Array): void, dirxml(...data: Array): void, error(...data: Array): void, group(...data: Array): void, groupCollapsed(...data: Array): void, groupEnd(): void, info(...data: Array): void, log(...data: Array): void, profile(name?: string): void, profileEnd(name?: string): void, table(tabularData: {[key: string]: any} | Array<{[key: string]: any}> | Array>): void, time(label?: string): void, timeEnd(label: string): void, timeLog(label?: string, ...data: Array): void, timeStamp(label?: string): void, trace(...data: Array): void, warn(...data: Array): void, ...}" }, - {"name":"CSSKeyframeRule","type":"typeof CSSKeyframeRule"}, - {"name":"CSSKeyframesRule","type":"typeof CSSKeyframesRule"}, - {"name":"CSSRule","type":"typeof CSSRule"}, - {"name":"CSSRuleList","type":"typeof CSSRuleList"}, - {"name":"CSSStyleDeclaration","type":"typeof CSSStyleDeclaration"}, - {"name":"CSSStyleSheet","type":"typeof CSSStyleSheet"}, - {"name":"CustomEvent","type":"typeof CustomEvent"}, - {"name":"DataTransfer","type":"typeof DataTransfer"}, - {"name":"DataTransferItem","type":"typeof DataTransferItem"}, - {"name":"DataTransferItemList","type":"typeof DataTransferItemList"}, {"name":"DataView","type":"typeof DataView"}, {"name":"Date","type":"typeof Date"}, {"name":"decodeURI","type":"(encodedURI: string) => string"}, {"name":"decodeURIComponent","type":"(encodedURIComponent: string) => string"}, - {"name":"Document","type":"typeof Document"}, - {"name":"document","type":"Document"}, - {"name":"DocumentFragment","type":"typeof DocumentFragment"}, - {"name":"DocumentTimeline","type":"typeof DocumentTimeline"}, - {"name":"DocumentType","type":"typeof DocumentType"}, - {"name":"DOMError","type":"typeof DOMError"}, - {"name":"DOMImplementation","type":"typeof DOMImplementation"}, - {"name":"DOMRect","type":"typeof DOMRect"}, - {"name":"DOMRectList","type":"typeof DOMRectList"}, - {"name":"DOMRectReadOnly","type":"typeof DOMRectReadOnly"}, - {"name":"DOMStringList","type":"typeof DOMStringList"}, - {"name":"DOMTokenList","type":"typeof DOMTokenList"}, - {"name":"DragEvent","type":"typeof DragEvent"}, - {"name":"Element","type":"typeof Element"}, {"name":"encodeURI","type":"(uri: string) => string"}, {"name":"encodeURIComponent","type":"(uriComponent: string) => string"}, {"name":"Error","type":"typeof Error"}, - {"name":"ErrorEvent","type":"typeof ErrorEvent"}, {"name":"escape","type":"(str: string) => string"}, {"name":"EvalError","type":"typeof EvalError"}, - {"name":"Event","type":"typeof Event"}, - {"name":"EventSource","type":"typeof EventSource"}, - {"name":"EventTarget","type":"typeof EventTarget"}, {"name":"exports","type":"{-[key: string]: mixed}"}, - {"name":"File","type":"typeof File"}, - {"name":"FileList","type":"typeof FileList"}, - {"name":"FileReader","type":"typeof FileReader"}, - {"name":"FileSystemDirectoryHandle","type":"typeof FileSystemDirectoryHandle"}, - {"name":"FileSystemFileHandle","type":"typeof FileSystemFileHandle"}, - {"name":"FileSystemHandle","type":"typeof FileSystemHandle"}, - { - "name":"FileSystemSyncAccessHandle", - "type":"typeof FileSystemSyncAccessHandle" - }, - { - "name":"FileSystemWritableFileStream", - "type":"typeof FileSystemWritableFileStream" - }, {"name":"FinalizationRegistry","type":"typeof FinalizationRegistry"}, {"name":"Float32Array","type":"typeof Float32Array"}, {"name":"Float64Array","type":"typeof Float64Array"}, - {"name":"FocusEvent","type":"typeof FocusEvent"}, - {"name":"FormData","type":"typeof FormData"}, {"name":"Function","type":"typeof Function"}, {"name":"global","type":"any"}, {"name":"globalThis","type":"typeof globalThis"}, - {"name":"HitRegionOptions","type":"typeof HitRegionOptions"}, - {"name":"HTMLAnchorElement","type":"typeof HTMLAnchorElement"}, - {"name":"HTMLAppletElement","type":"typeof HTMLAppletElement"}, - {"name":"HTMLAreaElement","type":"typeof HTMLAreaElement"}, - {"name":"HTMLAudioElement","type":"typeof HTMLAudioElement"}, - {"name":"HTMLBaseElement","type":"typeof HTMLBaseElement"}, - {"name":"HTMLBodyElement","type":"typeof HTMLBodyElement"}, - {"name":"HTMLBRElement","type":"typeof HTMLBRElement"}, - {"name":"HTMLButtonElement","type":"typeof HTMLButtonElement"}, - {"name":"HTMLCanvasElement","type":"typeof HTMLCanvasElement"}, - {"name":"HTMLCollection","type":"typeof HTMLCollection"}, - {"name":"HTMLDataElement","type":"typeof HTMLDataElement"}, - {"name":"HTMLDataListElement","type":"typeof HTMLDataListElement"}, - {"name":"HTMLDetailsElement","type":"typeof HTMLDetailsElement"}, - {"name":"HTMLDialogElement","type":"typeof HTMLDialogElement"}, - {"name":"HTMLDivElement","type":"typeof HTMLDivElement"}, - {"name":"HTMLDListElement","type":"typeof HTMLDListElement"}, - {"name":"HTMLElement","type":"typeof HTMLElement"}, - {"name":"HTMLEmbedElement","type":"typeof HTMLEmbedElement"}, - {"name":"HTMLFieldSetElement","type":"typeof HTMLFieldSetElement"}, - {"name":"HTMLFormElement","type":"typeof HTMLFormElement"}, - {"name":"HTMLHeadElement","type":"typeof HTMLHeadElement"}, - {"name":"HTMLHeadingElement","type":"typeof HTMLHeadingElement"}, - {"name":"HTMLHRElement","type":"typeof HTMLHRElement"}, - {"name":"HTMLHtmlElement","type":"typeof HTMLHtmlElement"}, - {"name":"HTMLIFrameElement","type":"typeof HTMLIFrameElement"}, - {"name":"HTMLImageElement","type":"typeof HTMLImageElement"}, - {"name":"HTMLInputElement","type":"typeof HTMLInputElement"}, - {"name":"HTMLLabelElement","type":"typeof HTMLLabelElement"}, - {"name":"HTMLLegendElement","type":"typeof HTMLLegendElement"}, - {"name":"HTMLLIElement","type":"typeof HTMLLIElement"}, - {"name":"HTMLLinkElement","type":"typeof HTMLLinkElement"}, - {"name":"HTMLMapElement","type":"typeof HTMLMapElement"}, - {"name":"HTMLMediaElement","type":"typeof HTMLMediaElement"}, - {"name":"HTMLMenuElement","type":"typeof HTMLMenuElement"}, - {"name":"HTMLMetaElement","type":"typeof HTMLMetaElement"}, - {"name":"HTMLMeterElement","type":"typeof HTMLMeterElement"}, - {"name":"HTMLModElement","type":"typeof HTMLModElement"}, - {"name":"HTMLObjectElement","type":"typeof HTMLObjectElement"}, - {"name":"HTMLOListElement","type":"typeof HTMLOListElement"}, - {"name":"HTMLOptGroupElement","type":"typeof HTMLOptGroupElement"}, - {"name":"HTMLOptionElement","type":"typeof HTMLOptionElement"}, - {"name":"HTMLOptionsCollection","type":"typeof HTMLOptionsCollection"}, - {"name":"HTMLOutputElement","type":"typeof HTMLOutputElement"}, - {"name":"HTMLParagraphElement","type":"typeof HTMLParagraphElement"}, - {"name":"HTMLParamElement","type":"typeof HTMLParamElement"}, - {"name":"HTMLPictureElement","type":"typeof HTMLPictureElement"}, - {"name":"HTMLPreElement","type":"typeof HTMLPreElement"}, - {"name":"HTMLProgressElement","type":"typeof HTMLProgressElement"}, - {"name":"HTMLQuoteElement","type":"typeof HTMLQuoteElement"}, - {"name":"HTMLScriptElement","type":"typeof HTMLScriptElement"}, - {"name":"HTMLSelectElement","type":"typeof HTMLSelectElement"}, - {"name":"HTMLSlotElement","type":"typeof HTMLSlotElement"}, - {"name":"HTMLSourceElement","type":"typeof HTMLSourceElement"}, - {"name":"HTMLSpanElement","type":"typeof HTMLSpanElement"}, - {"name":"HTMLStyleElement","type":"typeof HTMLStyleElement"}, - {"name":"HTMLTableCaptionElement","type":"typeof HTMLTableCaptionElement"}, - {"name":"HTMLTableCellElement","type":"typeof HTMLTableCellElement"}, - {"name":"HTMLTableColElement","type":"typeof HTMLTableColElement"}, - {"name":"HTMLTableElement","type":"typeof HTMLTableElement"}, - {"name":"HTMLTableRowElement","type":"typeof HTMLTableRowElement"}, - {"name":"HTMLTableSectionElement","type":"typeof HTMLTableSectionElement"}, - {"name":"HTMLTemplateElement","type":"typeof HTMLTemplateElement"}, - {"name":"HTMLTextAreaElement","type":"typeof HTMLTextAreaElement"}, - {"name":"HTMLTimeElement","type":"typeof HTMLTimeElement"}, - {"name":"HTMLTitleElement","type":"typeof HTMLTitleElement"}, - {"name":"HTMLTrackElement","type":"typeof HTMLTrackElement"}, - {"name":"HTMLUListElement","type":"typeof HTMLUListElement"}, - {"name":"HTMLUnknownElement","type":"typeof HTMLUnknownElement"}, - {"name":"HTMLVideoElement","type":"typeof HTMLVideoElement"}, - {"name":"Image","type":"typeof Image"}, - {"name":"ImageBitmap","type":"typeof ImageBitmap"}, - {"name":"ImageData","type":"typeof ImageData"}, {"name":"Infinity","type":"number"}, - {"name":"InputEvent","type":"typeof InputEvent"}, {"name":"Int16Array","type":"typeof Int16Array"}, {"name":"Int32Array","type":"typeof Int32Array"}, {"name":"Int8Array","type":"typeof Int8Array"}, @@ -514,57 +373,27 @@ Flags: --pretty "name":"JSON", "type":"{|+parse: (text: string, reviver?: (key: any, value: any) => any) => any, +stringify: ((value: null | string | number | boolean | interface {} | $ReadOnlyArray, replacer?: ?((key: string, value: any) => any) | Array, space?: string | number) => string) & ((value: mixed, replacer?: ?((key: string, value: any) => any) | Array, space?: string | number) => string | void)|}" }, - {"name":"KeyboardEvent","type":"typeof KeyboardEvent"}, - {"name":"KeyframeEffect","type":"typeof KeyframeEffect"}, - {"name":"Location","type":"typeof Location"}, {"name":"Map","type":"typeof Map"}, { "name":"Math", "type":"{E: number, LN10: number, LN2: number, LOG10E: number, LOG2E: number, PI: number, SQRT1_2: number, SQRT2: number, abs(x: number): number, acos(x: number): number, acosh(x: number): number, asin(x: number): number, asinh(x: number): number, atan(x: number): number, atan2(y: number, x: number): number, atanh(x: number): number, cbrt(x: number): number, ceil(x: number): number, clz32(x: number): number, cos(x: number): number, cosh(x: number): number, exp(x: number): number, expm1(x: number): number, floor(x: number): number, fround(x: number): number, hypot(...values: Array): number, imul(x: number, y: number): number, log(x: number): number, log10(x: number): number, log1p(x: number): number, log2(x: number): number, max(...values: Array): number, min(...values: Array): number, pow(x: number, y: number): number, random(): number, round(x: number): number, sign(x: number): number, sin(x: number): number, sinh(x: number): number, sqrt(x: number): number, tan(x: number): number, tanh(x: number): number, trunc(x: number): number, ...}" }, - {"name":"MediaError","type":"typeof MediaError"}, - {"name":"MediaKeys","type":"typeof MediaKeys"}, - {"name":"MediaKeySession","type":"typeof MediaKeySession"}, - {"name":"MediaKeyStatusMap","type":"typeof MediaKeyStatusMap"}, - {"name":"MediaList","type":"typeof MediaList"}, - {"name":"MediaQueryListEvent","type":"typeof MediaQueryListEvent"}, - {"name":"MediaSource","type":"typeof MediaSource"}, - {"name":"MediaStream","type":"typeof MediaStream"}, - {"name":"MediaStreamTrack","type":"typeof MediaStreamTrack"}, - {"name":"MediaStreamTrackEvent","type":"typeof MediaStreamTrackEvent"}, - {"name":"MessageEvent","type":"typeof MessageEvent"}, { "name":"module", "type":"{children: Array, exports: any, filename: string, id: string, isPreloading: boolean, loaded: boolean, parent: any, path: string, paths: Array, require(id: string): any, ...}" }, - {"name":"MouseEvent","type":"typeof MouseEvent"}, - {"name":"NamedNodeMap","type":"typeof NamedNodeMap"}, {"name":"NaN","type":"number"}, - {"name":"Node","type":"typeof Node"}, - {"name":"NodeFilter","type":"typeof NodeFilter"}, - {"name":"NodeIterator","type":"typeof NodeIterator"}, - {"name":"NodeList","type":"typeof NodeList"}, {"name":"Number","type":"typeof Number"}, {"name":"Object","type":"typeof Object"}, - {"name":"PageTransitionEvent","type":"typeof PageTransitionEvent"}, {"name":"parseFloat","type":"(string: mixed) => number"}, {"name":"parseInt","type":"(string: mixed, radix?: number) => number"}, - {"name":"Path2D","type":"typeof Path2D"}, - {"name":"PermissionStatus","type":"typeof PermissionStatus"}, - {"name":"PointerEvent","type":"typeof PointerEvent"}, - {"name":"ProgressEvent","type":"typeof ProgressEvent"}, {"name":"Promise","type":"typeof Promise"}, - {"name":"PromiseRejectionEvent","type":"typeof PromiseRejectionEvent"}, {"name":"Proxy","type":"typeof Proxy"}, { "name":"queueMicrotask", "type":">(callback: (...args: TArguments) => mixed) => void" }, - {"name":"Range","type":"typeof Range"}, {"name":"RangeError","type":"typeof RangeError"}, - {"name":"ReadableStream","type":"typeof ReadableStream"}, - {"name":"ReadableStreamController","type":"typeof ReadableStreamController"}, - {"name":"ReadableStreamReader","type":"typeof ReadableStreamReader"}, {"name":"ReferenceError","type":"typeof ReferenceError"}, { "name":"Reflect", @@ -575,11 +404,6 @@ Flags: --pretty "name":"require", "type":"{(id: string): any, cache: any, main: {children: Array, exports: any, filename: string, id: string, isPreloading: boolean, loaded: boolean, parent: any, path: string, paths: Array, require(id: string): any, ...}, resolve: (id: string, options?: {paths?: Array, ...}) => string, ...}" }, - { - "name":"SecurityPolicyViolationEvent", - "type":"typeof SecurityPolicyViolationEvent" - }, - {"name":"Selection","type":"typeof Selection"}, {"name":"Set","type":"typeof Set"}, { "name":"setInterval", @@ -590,38 +414,10 @@ Flags: --pretty "type":">(callback: (...args: TArguments) => mixed, ms?: number, ...args: TArguments) => TimeoutID" }, {"name":"SharedArrayBuffer","type":"typeof SharedArrayBuffer"}, - {"name":"SourceBuffer","type":"typeof SourceBuffer"}, - {"name":"SourceBufferList","type":"typeof SourceBufferList"}, - {"name":"Storage","type":"typeof Storage"}, - {"name":"StorageEvent","type":"typeof StorageEvent"}, {"name":"String","type":"typeof String"}, - {"name":"StyleSheet","type":"typeof StyleSheet"}, - {"name":"StyleSheetList","type":"typeof StyleSheetList"}, - {"name":"SVGMatrix","type":"typeof SVGMatrix"}, {"name":"Symbol","type":"typeof Symbol"}, {"name":"SyntaxError","type":"typeof SyntaxError"}, - {"name":"Text","type":"typeof Text"}, - {"name":"TextEncoder","type":"typeof TextEncoder"}, - {"name":"TextMetrics","type":"typeof TextMetrics"}, - {"name":"TextRange","type":"typeof TextRange"}, - {"name":"TextTrack","type":"typeof TextTrack"}, - {"name":"TextTrackCue","type":"typeof TextTrackCue"}, - {"name":"TextTrackCueList","type":"typeof TextTrackCueList"}, - {"name":"TextTrackList","type":"typeof TextTrackList"}, - {"name":"TimeRanges","type":"typeof TimeRanges"}, - {"name":"Touch","type":"typeof Touch"}, - {"name":"TouchEvent","type":"typeof TouchEvent"}, - {"name":"TouchList","type":"typeof TouchList"}, - {"name":"TrackDefault","type":"typeof TrackDefault"}, - {"name":"TrackDefaultList","type":"typeof TrackDefaultList"}, - {"name":"TransformStream","type":"typeof TransformStream"}, - {"name":"TransitionEvent","type":"typeof TransitionEvent"}, - {"name":"TreeWalker","type":"typeof TreeWalker"}, - {"name":"TrustedHTML","type":"typeof TrustedHTML"}, - {"name":"TrustedScript","type":"typeof TrustedScript"}, - {"name":"TrustedScriptURL","type":"typeof TrustedScriptURL"}, {"name":"TypeError","type":"typeof TypeError"}, - {"name":"UIEvent","type":"typeof UIEvent"}, {"name":"Uint16Array","type":"typeof Uint16Array"}, {"name":"Uint32Array","type":"typeof Uint32Array"}, {"name":"Uint8Array","type":"typeof Uint8Array"}, @@ -629,47 +425,9 @@ Flags: --pretty {"name":"undefined","type":"void"}, {"name":"unescape","type":"(str: string) => string"}, {"name":"URIError","type":"typeof URIError"}, - {"name":"URL","type":"typeof URL"}, - {"name":"URLSearchParams","type":"typeof URLSearchParams"}, - {"name":"USBAlternateInterface","type":"typeof USBAlternateInterface"}, - {"name":"USBConfiguration","type":"typeof USBConfiguration"}, - {"name":"USBConnectionEvent","type":"typeof USBConnectionEvent"}, - {"name":"USBDevice","type":"typeof USBDevice"}, - {"name":"USBEndpoint","type":"typeof USBEndpoint"}, - {"name":"USBInterface","type":"typeof USBInterface"}, - {"name":"USBInTransferResult","type":"typeof USBInTransferResult"}, - { - "name":"USBIsochronousInTransferPacket", - "type":"typeof USBIsochronousInTransferPacket" - }, - { - "name":"USBIsochronousInTransferResult", - "type":"typeof USBIsochronousInTransferResult" - }, - { - "name":"USBIsochronousOutTransferPacket", - "type":"typeof USBIsochronousOutTransferPacket" - }, - { - "name":"USBIsochronousOutTransferResult", - "type":"typeof USBIsochronousOutTransferResult" - }, - {"name":"USBOutTransferResult","type":"typeof USBOutTransferResult"}, - {"name":"ValidityState","type":"typeof ValidityState"}, - {"name":"VideoTrack","type":"typeof VideoTrack"}, - {"name":"VideoTrackList","type":"typeof VideoTrackList"}, {"name":"WeakMap","type":"typeof WeakMap"}, {"name":"WeakRef","type":"typeof WeakRef"}, - {"name":"WeakSet","type":"typeof WeakSet"}, - {"name":"WebGLContextEvent","type":"typeof WebGLContextEvent"}, - {"name":"WebGLRenderingContext","type":"typeof WebGLRenderingContext"}, - {"name":"WheelEvent","type":"typeof WheelEvent"}, - {"name":"WritableStream","type":"typeof WritableStream"}, - { - "name":"WritableStreamDefaultWriter", - "type":"typeof WritableStreamDefaultWriter" - }, - {"name":"WriteableStream","type":"typeof WriteableStream"} + {"name":"WeakSet","type":"typeof WeakSet"} ] } diff --git a/tests/component_syntax/component_syntax.exp b/tests/component_syntax/component_syntax.exp index 0f4b080ef0c..73ee101ce9d 100644 --- a/tests/component_syntax/component_syntax.exp +++ b/tests/component_syntax/component_syntax.exp @@ -3196,13 +3196,12 @@ References: Error --------------------------------------------------------------------------------------------------- refs.js:105:23 Cannot create `GenericRef1` element because in property `ref`: [incompatible-type] - - Either `HTMLElement` [1] is not a subtype of object type [2]. Class instances are not subtypes of object types; - consider rewriting object type [2] as an interface. - - Or `HTMLElement` [1] is incompatible with function type [3]. Non-callable objects are not compatible with functions. + - Either number [1] is incompatible with object type [2]. + - Or number [1] is incompatible with function type [3]. refs.js:105:23 - 105| ; // error - ^^^^^^^^^^^^^^^^^ [1] + 105| ; // error + ^ [1] References: /react.js:113:5 diff --git a/tests/component_syntax/refs.js b/tests/component_syntax/refs.js index 4de27ce1159..64ded3df250 100644 --- a/tests/component_syntax/refs.js +++ b/tests/component_syntax/refs.js @@ -102,7 +102,7 @@ import * as React from 'react'; {}} />; // ok {}} />; // ok - ; // error + ; // error >> | null) => {}} />; // ok >> | null) => {}} />; // ok {}} />; // error diff --git a/tests/declare_namespace/declare_namespace.exp b/tests/declare_namespace/declare_namespace.exp index 251a66ba4db..9b8b35090c8 100644 --- a/tests/declare_namespace/declare_namespace.exp +++ b/tests/declare_namespace/declare_namespace.exp @@ -471,48 +471,54 @@ Cannot resolve name `React`. [cannot-resolve-name] Error --------------------------------------------------------------------------------- type_only_react_namespace.js:5:3 -Cannot cast `new HTMLAnchorElement()` to `Node` because: [incompatible-cast] - - Either `HTMLAnchorElement` [1] is incompatible with `React.Element` [2]. - - Or `HTMLAnchorElement` [1] is incompatible with `React.Portal` [3]. - - Or property `@@iterator` is missing in `HTMLAnchorElement` [1] but exists in `$Iterable` [4]. +Cannot cast `Array` to `Node` because: [incompatible-cast] + - Either class `Array` [1] is incompatible with `React.Element` [2]. + - Or class `Array` [1] is incompatible with `React.Portal` [3]. + - Or property `@@iterator` is missing in class `Array` [1] but exists in `$Iterable` [4]. type_only_react_namespace.js:5:3 - 5| new HTMLAnchorElement() as React.Node; // error - ^^^^^^^^^^^^^^^^^^^^^^^ [1] + 5| Array as React.Node; // error + ^^^^^ References: + /core.js:946:15 + 946| declare class Array extends $ReadOnlyArray { + ^^^^^ [1] /react.js:21:5 - 21| | React$Element - ^^^^^^^^^^^^^^^^^^ [2] + 21| | React$Element + ^^^^^^^^^^^^^^^^^^ [2] /react.js:22:5 - 22| | React$Portal - ^^^^^^^^^^^^ [3] + 22| | React$Portal + ^^^^^^^^^^^^ [3] /react.js:23:5 - 23| | Iterable; - ^^^^^^^^^^^^^^^^^^^^^ [4] + 23| | Iterable; + ^^^^^^^^^^^^^^^^^^^^^ [4] Error -------------------------------------------------------------------------------- type_only_react_namespace.js:12:3 -Cannot cast `new HTMLAnchorElement()` to `Node` because: [incompatible-cast] - - Either `HTMLAnchorElement` [1] is incompatible with `React.Element` [2]. - - Or `HTMLAnchorElement` [1] is incompatible with `React.Portal` [3]. - - Or property `@@iterator` is missing in `HTMLAnchorElement` [1] but exists in `$Iterable` [4]. +Cannot cast `Array` to `Node` because: [incompatible-cast] + - Either class `Array` [1] is incompatible with `React.Element` [2]. + - Or class `Array` [1] is incompatible with `React.Portal` [3]. + - Or property `@@iterator` is missing in class `Array` [1] but exists in `$Iterable` [4]. type_only_react_namespace.js:12:3 - 12| new HTMLAnchorElement() as React.Node; // error - ^^^^^^^^^^^^^^^^^^^^^^^ [1] + 12| Array as React.Node; // error + ^^^^^ References: + /core.js:946:15 + 946| declare class Array extends $ReadOnlyArray { + ^^^^^ [1] /react.js:21:5 - 21| | React$Element - ^^^^^^^^^^^^^^^^^^ [2] + 21| | React$Element + ^^^^^^^^^^^^^^^^^^ [2] /react.js:22:5 - 22| | React$Portal - ^^^^^^^^^^^^ [3] + 22| | React$Portal + ^^^^^^^^^^^^ [3] /react.js:23:5 - 23| | Iterable; - ^^^^^^^^^^^^^^^^^^^^^ [4] + 23| | Iterable; + ^^^^^^^^^^^^^^^^^^^^^ [4] Error ----------------------------------------------------------------------------------------------- typing_test.js:7:1 diff --git a/tests/declare_namespace/type_only_react_namespace.js b/tests/declare_namespace/type_only_react_namespace.js index 1ae06fbf56f..42cfe145a30 100644 --- a/tests/declare_namespace/type_only_react_namespace.js +++ b/tests/declare_namespace/type_only_react_namespace.js @@ -2,12 +2,12 @@
; // ok React; // error 1 as React.Node; - new HTMLAnchorElement() as React.Node; // error + Array as React.Node; // error } { const React = require('react');
as React.Node; // ok React; // error 1 as React.Node; - new HTMLAnchorElement() as React.Node; // error + Array as React.Node; // error } diff --git a/tests/global_this/global_this.exp b/tests/global_this/global_this.exp index dffc71eb8c4..c6115b376bf 100644 --- a/tests/global_this/global_this.exp +++ b/tests/global_this/global_this.exp @@ -69,28 +69,28 @@ References: Error ----------------------------------------------------------------------------------------------------- test.js:10:1 -Cannot cast `HTMLElement` to `Node` because: [incompatible-cast] - - Either class `HTMLElement` [1] is incompatible with `React.Element` [2]. - - Or class `HTMLElement` [1] is incompatible with `React.Portal` [3]. - - Or property `@@iterator` is missing in class `HTMLElement` [1] but exists in `$Iterable` [4]. +Cannot cast `Array` to `Node` because: [incompatible-cast] + - Either class `Array` [1] is incompatible with `React.Element` [2]. + - Or class `Array` [1] is incompatible with `React.Portal` [3]. + - Or property `@@iterator` is missing in class `Array` [1] but exists in `$Iterable` [4]. test.js:10:1 - 10| HTMLElement as globalThis.React.Node; // error - ^^^^^^^^^^^ + 10| Array as globalThis.React.Node; // error + ^^^^^ References: - /dom.js:2092:15 - 2092| declare class HTMLElement extends Element { - ^^^^^^^^^^^ [1] + /core.js:946:15 + 946| declare class Array extends $ReadOnlyArray { + ^^^^^ [1] /react.js:21:5 - 21| | React$Element - ^^^^^^^^^^^^^^^^^^ [2] + 21| | React$Element + ^^^^^^^^^^^^^^^^^^ [2] /react.js:22:5 - 22| | React$Portal - ^^^^^^^^^^^^ [3] + 22| | React$Portal + ^^^^^^^^^^^^ [3] /react.js:23:5 - 23| | Iterable; - ^^^^^^^^^^^^^^^^^^^^^ [4] + 23| | Iterable; + ^^^^^^^^^^^^^^^^^^^^^ [4] diff --git a/tests/global_this/test.js b/tests/global_this/test.js index b423372f85c..0f7607fc707 100644 --- a/tests/global_this/test.js +++ b/tests/global_this/test.js @@ -7,4 +7,4 @@ window.myGlobal as globalThis.Opaque; // ok: this is weird, but TS also supports window.myGlobal as empty; // error globalThis.myGlobal as empty; // error -HTMLElement as globalThis.React.Node; // error +Array as globalThis.React.Node; // error diff --git a/tests/new_merge_diff/new_merge_diff.exp b/tests/new_merge_diff/new_merge_diff.exp index 3dfb1fee99b..bd8fca82857 100644 --- a/tests/new_merge_diff/new_merge_diff.exp +++ b/tests/new_merge_diff/new_merge_diff.exp @@ -78,6 +78,11 @@ Error -------------------------------------------------------------------------- Invalid trivially recursive definition of exports. [recursive-definition] +Error ---------------------------------------------------------------------------------- recursive_module_cycle_B.js:0:1 + +Invalid trivially recursive definition of exports. [recursive-definition] + + Error ------------------------------------------------------------------------------------------ recursive_types.js:1:14 Invalid type annotation for `x`. It contains a reference [1] to the binding being declared. [recursive-definition] @@ -169,7 +174,7 @@ Invalid trivially recursive definition of object type. [recursive-definition] -Found 15 errors +Found 16 errors Only showing the most relevant union/intersection branches. To see all branches, re-run Flow with --show-all-branches diff --git a/tests/quick_start/quick_start.exp b/tests/quick_start/quick_start.exp index 3331c37487f..fe46419033c 100644 --- a/tests/quick_start/quick_start.exp +++ b/tests/quick_start/quick_start.exp @@ -6,7 +6,7 @@ Quick start. Expect no errors. No errors! -The Flow server is currently in lazy mode and is only checking 7/8 files. +The Flow server is currently in lazy mode and is only checking 3/4 files. To learn more, visit flow.org/en/docs/lang/lazy-modes Change @flow file, expect error. @@ -27,13 +27,13 @@ References: Found 1 error -The Flow server is currently in lazy mode and is only checking 8/8 files. +The Flow server is currently in lazy mode and is only checking 4/4 files. To learn more, visit flow.org/en/docs/lang/lazy-modes Make file @noflow, expect error to go away. No errors! -The Flow server is currently in lazy mode and is only checking 7/7 files. +The Flow server is currently in lazy mode and is only checking 3/3 files. To learn more, visit flow.org/en/docs/lang/lazy-modes Revert file, expect error again. @@ -54,7 +54,7 @@ References: Found 1 error -The Flow server is currently in lazy mode and is only checking 8/8 files. +The Flow server is currently in lazy mode and is only checking 4/4 files. To learn more, visit flow.org/en/docs/lang/lazy-modes Done! diff --git a/tests/quick_start_add_dependency/quick_start_add_dependency.exp b/tests/quick_start_add_dependency/quick_start_add_dependency.exp index 2ec44930a5c..1cd00aa68b9 100644 --- a/tests/quick_start_add_dependency/quick_start_add_dependency.exp +++ b/tests/quick_start_add_dependency/quick_start_add_dependency.exp @@ -6,13 +6,13 @@ Quick start. Expect no errors. No errors! -The Flow server is currently in lazy mode and is only checking 7/9 files. +The Flow server is currently in lazy mode and is only checking 3/5 files. To learn more, visit flow.org/en/docs/lang/lazy-modes Change @flow file with dependency on a @flow file, expect no error. No errors! -The Flow server is currently in lazy mode and is only checking 9/9 files. +The Flow server is currently in lazy mode and is only checking 5/5 files. To learn more, visit flow.org/en/docs/lang/lazy-modes Done! diff --git a/tests/quick_start_add_dependency_on_cycle/quick_start_add_dependency_on_cycle.exp b/tests/quick_start_add_dependency_on_cycle/quick_start_add_dependency_on_cycle.exp index 57134574218..052201d82a9 100644 --- a/tests/quick_start_add_dependency_on_cycle/quick_start_add_dependency_on_cycle.exp +++ b/tests/quick_start_add_dependency_on_cycle/quick_start_add_dependency_on_cycle.exp @@ -6,13 +6,13 @@ Quick start. Expect no errors. No errors! -The Flow server is currently in lazy mode and is only checking 7/10 files. +The Flow server is currently in lazy mode and is only checking 3/6 files. To learn more, visit flow.org/en/docs/lang/lazy-modes Change @flow file with dependency on a @flow file in a cycle, expect no error. No errors! -The Flow server is currently in lazy mode and is only checking 9/10 files. +The Flow server is currently in lazy mode and is only checking 5/6 files. To learn more, visit flow.org/en/docs/lang/lazy-modes Done! diff --git a/tests/quick_start_check_contents/quick_start_check_contents.exp b/tests/quick_start_check_contents/quick_start_check_contents.exp index 9cea0ce7c39..1262e30fa42 100644 --- a/tests/quick_start_check_contents/quick_start_check_contents.exp +++ b/tests/quick_start_check_contents/quick_start_check_contents.exp @@ -6,7 +6,7 @@ Quick start. Expect no errors. No errors! -The Flow server is currently in lazy mode and is only checking 7/12 files. +The Flow server is currently in lazy mode and is only checking 3/8 files. To learn more, visit flow.org/en/docs/lang/lazy-modes Check contents with dependency, expect errors in contents. @@ -33,7 +33,7 @@ Found 1 error No error in dependency (it is not checked). No errors! -The Flow server is currently in lazy mode and is only checking 8/12 files. +The Flow server is currently in lazy mode and is only checking 4/8 files. To learn more, visit flow.org/en/docs/lang/lazy-modes Unsaved files don't have dependents, as in non-lazy mode. diff --git a/tests/quick_start_delete_dependency/quick_start_delete_dependency.exp b/tests/quick_start_delete_dependency/quick_start_delete_dependency.exp index 3e86e0a7ed9..32e5f9acb37 100644 --- a/tests/quick_start_delete_dependency/quick_start_delete_dependency.exp +++ b/tests/quick_start_delete_dependency/quick_start_delete_dependency.exp @@ -6,7 +6,7 @@ Quick start. Expect no errors. No errors! -The Flow server is currently in lazy mode and is only checking 7/9 files. +The Flow server is currently in lazy mode and is only checking 3/5 files. To learn more, visit flow.org/en/docs/lang/lazy-modes Delete @flow file with a @flow dependent file, expect error. @@ -21,13 +21,13 @@ Cannot resolve module `./a`. [cannot-resolve-module] Found 1 error -The Flow server is currently in lazy mode and is only checking 8/8 files. +The Flow server is currently in lazy mode and is only checking 4/4 files. To learn more, visit flow.org/en/docs/lang/lazy-modes Revert file, expect no errors. No errors! -The Flow server is currently in lazy mode and is only checking 9/9 files. +The Flow server is currently in lazy mode and is only checking 5/5 files. To learn more, visit flow.org/en/docs/lang/lazy-modes Done! diff --git a/tests/quick_start_unchecked_dependency/quick_start_unchecked_dependency.exp b/tests/quick_start_unchecked_dependency/quick_start_unchecked_dependency.exp index c036d7dc4b6..05b1b2141c6 100644 --- a/tests/quick_start_unchecked_dependency/quick_start_unchecked_dependency.exp +++ b/tests/quick_start_unchecked_dependency/quick_start_unchecked_dependency.exp @@ -6,25 +6,25 @@ Quick start. Expect no errors. No errors! -The Flow server is currently in lazy mode and is only checking 7/12 files. +The Flow server is currently in lazy mode and is only checking 3/8 files. To learn more, visit flow.org/en/docs/lang/lazy-modes "Warm up" a dependency. No errors! -The Flow server is currently in lazy mode and is only checking 9/12 files. +The Flow server is currently in lazy mode and is only checking 5/8 files. To learn more, visit flow.org/en/docs/lang/lazy-modes "Perturb" a dependent that depends on the warmed up, but unchanged dependency. No errors! -The Flow server is currently in lazy mode and is only checking 10/12 files. +The Flow server is currently in lazy mode and is only checking 6/8 files. To learn more, visit flow.org/en/docs/lang/lazy-modes Test that the perturbed dependent is actually known (expecting a crash otherwise). No errors! -The Flow server is currently in lazy mode and is only checking 12/12 files. +The Flow server is currently in lazy mode and is only checking 8/8 files. To learn more, visit flow.org/en/docs/lang/lazy-modes Done! diff --git a/tests/react_ref_as_prop/react_ref_as_prop.exp b/tests/react_ref_as_prop/react_ref_as_prop.exp index 3db894db99c..f1839969fbf 100644 --- a/tests/react_ref_as_prop/react_ref_as_prop.exp +++ b/tests/react_ref_as_prop/react_ref_as_prop.exp @@ -1,3 +1,35 @@ +Error ------------------------------------------------------------------------------ component_syntax_components.js:2:85 + +Cannot resolve name `HTMLElement`. [cannot-resolve-name] + + 2| declare export component CompWithOptionalRefProp(foo: string, ref?: React.RefSetter); + ^^^^^^^^^^^ + + +Error ------------------------------------------------------------------------------ component_syntax_components.js:3:84 + +Cannot resolve name `HTMLElement`. [cannot-resolve-name] + + 3| declare export component CompWithRequiredRefProp(foo: string, ref: React.RefSetter); + ^^^^^^^^^^^ + + +Error -------------------------------------------------------------------------------------------- fn_components.js:2:90 + +Cannot resolve name `HTMLElement`. [cannot-resolve-name] + + 2| declare export function FnWithOptionalRefProp(props: {foo: string, ref?: React.RefSetter}): React.Node; + ^^^^^^^^^^^ + + +Error -------------------------------------------------------------------------------------------- fn_components.js:3:89 + +Cannot resolve name `HTMLElement`. [cannot-resolve-name] + + 3| declare export function FnWithRequiredRefProp(props: {foo: string, ref: React.RefSetter}): React.Node; + ^^^^^^^^^^^ + + Error ----------------------------------------------------------------------------------- implicit_instantiation.js:14:2 Cannot cast object literal to `React.ElementConfig` because property `foo` is missing in object literal [1] but exists @@ -57,32 +89,20 @@ References: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [2] -Error ----------------------------------------------------------------------------------- implicit_instantiation.js:20:1 - -Cannot cast `null` to `React.ElementRef` because null [1] is incompatible with `HTMLElement` [2]. [incompatible-cast] +Error ----------------------------------------------------------------------------------- implicit_instantiation.js:19:5 - implicit_instantiation.js:20:1 - 20| null as React.ElementRef; // error: null ~> HTMLElement - ^^^^ [1] - -References: - implicit_instantiation.js:20:9 - 20| null as React.ElementRef; // error: null ~> HTMLElement - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [2] +Cannot resolve name `HTMLElement`. [cannot-resolve-name] + 19| new HTMLElement() as React.ElementRef; // ok + ^^^^^^^^^^^ -Error ----------------------------------------------------------------------------------- implicit_instantiation.js:22:1 -Cannot cast `null` to `React.ElementRef` because null [1] is incompatible with `HTMLElement` [2]. [incompatible-cast] +Error ----------------------------------------------------------------------------------- implicit_instantiation.js:21:5 - implicit_instantiation.js:22:1 - 22| null as React.ElementRef; // error: null ~> HTMLElement - ^^^^ [1] +Cannot resolve name `HTMLElement`. [cannot-resolve-name] -References: - implicit_instantiation.js:22:9 - 22| null as React.ElementRef; // error: null ~> HTMLElement - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [2] + 21| new HTMLElement() as React.ElementRef; // ok + ^^^^^^^^^^^ Error ----------------------------------------------------------------------------------- implicit_instantiation.js:33:2 @@ -145,32 +165,20 @@ References: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [2] -Error ----------------------------------------------------------------------------------- implicit_instantiation.js:39:1 +Error ----------------------------------------------------------------------------------- implicit_instantiation.js:38:5 -Cannot cast `null` to `React.ElementRef` because null [1] is incompatible with `HTMLElement` [2]. [incompatible-cast] +Cannot resolve name `HTMLElement`. [cannot-resolve-name] - implicit_instantiation.js:39:1 - 39| null as React.ElementRef; // error: null ~> HTMLElement - ^^^^ [1] + 38| new HTMLElement() as React.ElementRef; // ok + ^^^^^^^^^^^ -References: - implicit_instantiation.js:39:9 - 39| null as React.ElementRef; // error: null ~> HTMLElement - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [2] +Error ----------------------------------------------------------------------------------- implicit_instantiation.js:40:5 -Error ----------------------------------------------------------------------------------- implicit_instantiation.js:41:1 +Cannot resolve name `HTMLElement`. [cannot-resolve-name] -Cannot cast `null` to `React.ElementRef` because null [1] is incompatible with `HTMLElement` [2]. [incompatible-cast] - - implicit_instantiation.js:41:1 - 41| null as React.ElementRef; // error: null ~> HTMLElement - ^^^^ [1] - -References: - implicit_instantiation.js:41:9 - 41| null as React.ElementRef; // error: null ~> HTMLElement - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [2] + 40| new HTMLElement() as React.ElementRef; // ok + ^^^^^^^^^^^ Error ---------------------------------------------------------------------------------------------- jsx_checking.js:6:2 @@ -224,48 +232,28 @@ References: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [2] -Error -------------------------------------------------------------------------------------------- jsx_checking.js:10:39 +Error --------------------------------------------------------------------------------------------- jsx_checking.js:8:39 -Cannot create `FnWithOptionalRefProp` element because in property `ref`: [incompatible-type] - - Either string [1] is incompatible with `HTMLElement` [2] in the first parameter. - - Or function [3] is incompatible with object type [4]. Functions without statics are not compatible with objects. +Cannot resolve name `HTMLElement`. [cannot-resolve-name] - jsx_checking.js:10:39 - 10| {}} />; // error: string ~> HTMLElement, ref checking still works - ^^^^^^^^^^^^^^^^^^ [3] + 8| {}} />; // error: extra ref prop + ^^^^^^^^^^^ -References: - jsx_checking.js:10:44 - 10| {}} />; // error: string ~> HTMLElement, ref checking still works - ^^^^^^ [1] - fn_components.js:2:90 - 2| declare export function FnWithOptionalRefProp(props: {foo: string, ref?: React.RefSetter}): React.Node; - ^^^^^^^^^^^ [2] - /react.js:113:5 - 113| | { -current: T | null, ... } - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ [4] +Error --------------------------------------------------------------------------------------------- jsx_checking.js:9:44 -Error -------------------------------------------------------------------------------------------- jsx_checking.js:12:39 +Cannot resolve name `HTMLElement`. [cannot-resolve-name] -Cannot create `FnWithRequiredRefProp` element because in property `ref`: [incompatible-type] - - Either string [1] is incompatible with `HTMLElement` [2] in the first parameter. - - Or function [3] is incompatible with object type [4]. Functions without statics are not compatible with objects. + 9| {}} />; // ok + ^^^^^^^^^^^ - jsx_checking.js:12:39 - 12| {}} />; // error: string ~> HTMLElement, ref checking still works - ^^^^^^^^^^^^^^^^^^ [3] -References: - jsx_checking.js:12:44 - 12| {}} />; // error: string ~> HTMLElement, ref checking still works - ^^^^^^ [1] - fn_components.js:3:89 - 3| declare export function FnWithRequiredRefProp(props: {foo: string, ref: React.RefSetter}): React.Node; - ^^^^^^^^^^^ [2] - /react.js:113:5 - 113| | { -current: T | null, ... } - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ [4] +Error -------------------------------------------------------------------------------------------- jsx_checking.js:11:44 + +Cannot resolve name `HTMLElement`. [cannot-resolve-name] + + 11| {}} />; // ok + ^^^^^^^^^^^ Error -------------------------------------------------------------------------------------------- jsx_checking.js:17:26 @@ -301,48 +289,28 @@ References: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [2] -Error -------------------------------------------------------------------------------------------- jsx_checking.js:20:41 +Error -------------------------------------------------------------------------------------------- jsx_checking.js:18:41 + +Cannot resolve name `HTMLElement`. [cannot-resolve-name] -Cannot create `CompWithOptionalRefProp` element because in property `ref`: [incompatible-type] - - Either string [1] is incompatible with `HTMLElement` [2] in the first parameter. - - Or function [3] is incompatible with object type [4]. Functions without statics are not compatible with objects. + 18| {}} />; // error: extra ref prop + ^^^^^^^^^^^ - jsx_checking.js:20:41 - 20| {}} />; // error: string ~> HTMLElement, ref checking still works - ^^^^^^^^^^^^^^^^^^ [3] -References: - jsx_checking.js:20:46 - 20| {}} />; // error: string ~> HTMLElement, ref checking still works - ^^^^^^ [1] - component_syntax_components.js:2:85 - 2| declare export component CompWithOptionalRefProp(foo: string, ref?: React.RefSetter); - ^^^^^^^^^^^ [2] - /react.js:113:5 - 113| | { -current: T | null, ... } - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ [4] +Error -------------------------------------------------------------------------------------------- jsx_checking.js:19:46 +Cannot resolve name `HTMLElement`. [cannot-resolve-name] -Error -------------------------------------------------------------------------------------------- jsx_checking.js:22:41 + 19| {}} />; // ok + ^^^^^^^^^^^ -Cannot create `CompWithRequiredRefProp` element because in property `ref`: [incompatible-type] - - Either string [1] is incompatible with `HTMLElement` [2] in the first parameter. - - Or function [3] is incompatible with object type [4]. Functions without statics are not compatible with objects. - jsx_checking.js:22:41 - 22| {}} />; // error: string ~> HTMLElement, ref checking still works - ^^^^^^^^^^^^^^^^^^ [3] +Error -------------------------------------------------------------------------------------------- jsx_checking.js:21:46 -References: - jsx_checking.js:22:46 - 22| {}} />; // error: string ~> HTMLElement, ref checking still works - ^^^^^^ [1] - component_syntax_components.js:3:84 - 3| declare export component CompWithRequiredRefProp(foo: string, ref: React.RefSetter); - ^^^^^^^^^^^ [2] - /react.js:113:5 - 113| | { -current: T | null, ... } - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ [4] +Cannot resolve name `HTMLElement`. [cannot-resolve-name] + + 21| {}} />; // ok + ^^^^^^^^^^^ Error ------------------------------------------------------------------------------------------------ subtyping.js:14:1 @@ -364,7 +332,4 @@ References: -Found 22 errors - -Only showing the most relevant union/intersection branches. -To see all branches, re-run Flow with --show-all-branches +Found 28 errors diff --git a/tests/react_rules/ref_read_different_type.js b/tests/react_rules/ref_read_different_type.js index f2b9e6faaaa..9228faa1629 100644 --- a/tests/react_rules/ref_read_different_type.js +++ b/tests/react_rules/ref_read_different_type.js @@ -1,4 +1,4 @@ -component Foo(otherRef: { current: HTMLElement | null }) { +component Foo(otherRef: { current: interface {} | null }) { otherRef.current; // error return null; } diff --git a/tests/union/union.js b/tests/union/union.js index 14937656969..c2a638acd39 100644 --- a/tests/union/union.js +++ b/tests/union/union.js @@ -10,3 +10,5 @@ function CD(b: boolean) { function qux2(e: C | D) { } // OK qux2(new C); } + +declare opaque type Document;