Closed orta closed 2 months ago
dom.d.ts
BlobEvent
CSSAnimation
CSSCounterStyleRule
CSSTransition
ClipboardItem
FileSystem
FileSystemDirectoryEntry
FileSystemDirectoryReader
FileSystemEntry
FileSystemFileEntry
FontFace
FontFaceSet
FontFaceSetLoadEvent
FormDataEvent
IdleDeadline
MathMLElement
MediaCapabilities
MediaMetadata
MediaRecorder
MediaRecorderErrorEvent
MediaSession
NetworkInformation
PerformanceEventTiming
PerformancePaintTiming
PictureInPictureWindow
RemotePlayback
SVGMPathElement
SVGSetElement
SubmitEvent
ApplicationCache
BhxBrowser
CaretPosition
ClientRect
ClientRectList
CryptoKeyPair
DOMError
DOMSettableTokenList
DataCue
DeferredPermissionRequest
DeviceAcceleration
DeviceRotationRate
ExtensionScriptApis
FocusNavigationEvent
GamepadPose
HTMLAppletElement
HTMLDialogElement
HTMLTableDataCellElement
HTMLTableHeaderCellElement
InputDeviceInfo
ListeningStateChangedEvent
MSAssertion
MSBlobBuilder
MSFIDOCredentialAssertion
MSFIDOSignature
MSFIDOSignatureAssertion
MSGesture
MSGraphicsTrust
MSInputMethodContext
MSMediaKeyError
MSMediaKeySession
MSMediaKeys
MSStream
MediaStreamError
MediaStreamErrorEvent
MediaStreamEvent
MediaStreamTrackAudioSourceNode
NavigationPreloadManager
NodeFilter
OffscreenCanvas
OffscreenCanvasRenderingContext2D
OverflowEvent
PerfWidgetExternal
PermissionRequest
PermissionRequestedEvent
RTCDtlsTransportStateChangedEvent
RTCDtmfSender
RTCError
RTCErrorEvent
RTCIceCandidatePairChangedEvent
RTCIceGatherer
RTCIceGathererEvent
RTCIceTransportStateChangedEvent
RTCIdentityAssertion
RTCSctpTransport
RTCSrtpSdesTransport
RTCSsrcConflictEvent
RTCStatsProvider
RandomSource
SVGCursorElement
SVGElementInstance
SVGElementInstanceList
SVGPathSeg
SVGPathSegArcAbs
SVGPathSegArcRel
SVGPathSegClosePath
SVGPathSegCurvetoCubicAbs
SVGPathSegCurvetoCubicRel
SVGPathSegCurvetoCubicSmoothAbs
SVGPathSegCurvetoCubicSmoothRel
SVGPathSegCurvetoQuadraticAbs
SVGPathSegCurvetoQuadraticRel
SVGPathSegCurvetoQuadraticSmoothAbs
SVGPathSegCurvetoQuadraticSmoothRel
SVGPathSegLinetoAbs
SVGPathSegLinetoHorizontalAbs
SVGPathSegLinetoHorizontalRel
SVGPathSegLinetoRel
SVGPathSegLinetoVerticalAbs
SVGPathSegLinetoVerticalRel
SVGPathSegList
SVGPathSegMovetoAbs
SVGPathSegMovetoRel
SVGZoomEvent
ServiceUIFrameContext
SpeechGrammar
SpeechGrammarList
SpeechRecognition
SpeechRecognitionErrorEvent
SpeechRecognitionEvent
StyleMedia
SyncManager
TextEvent
VRDisplay
VRDisplayCapabilities
VRDisplayEvent
VREyeParameters
VRFieldOfView
VRFrameData
VRPose
WebKitPoint
webkitRTCPeerConnection
onremove
, replaceState
, commitStyles
, persist
outputLatency
, createMediaStreamTrackSource
appearance
, aspectRatio
, backgroundBlendMode
, borderBlock
, borderBlockColor
, borderBlockStyle
, borderBlockWidth
, borderEndEndRadius
, borderEndStartRadius
, borderInline
, borderInlineColor
, borderInlineStyle
, borderInlineWidth
, borderStartEndRadius
, borderStartStartRadius
, colorScheme
, contain
, counterSet
, fontOpticalSizing
, fontVariantAlternates
, fontVariationSettings
, inset
, insetBlock
, insetBlockEnd
, insetBlockStart
, insetInline
, insetInlineEnd
, insetInlineStart
, isolation
, marginBlock
, marginInline
, mixBlendMode
, offset
, offsetAnchor
, offsetDistance
, offsetPath
, offsetRotate
, paddingBlock
, paddingInline
, scrollMargin
, scrollMarginBlock
, scrollMarginBlockEnd
, scrollMarginBlockStart
, scrollMarginBottom
, scrollMarginInline
, scrollMarginInlineEnd
, scrollMarginInlineStart
, scrollMarginLeft
, scrollMarginRight
, scrollMarginTop
, scrollPadding
, scrollPaddingBlock
, scrollPaddingBlockEnd
, scrollPaddingBlockStart
, scrollPaddingBottom
, scrollPaddingInline
, scrollPaddingInlineEnd
, scrollPaddingInlineStart
, scrollPaddingLeft
, scrollPaddingRight
, scrollPaddingTop
, scrollSnapAlign
, scrollSnapStop
, scrollSnapType
, shapeImageThreshold
, shapeMargin
, shapeOutside
, textDecorationSkipInk
, textDecorationThickness
, textUnderlineOffset
glyphOrientationVertical
, maskComposite
, maskImage
, maskPosition
, maskRepeat
, maskSize
, rubyAlign
, textJustify
, webkitTapHighlightColor
, webkitTextSizeAdjust
, zoom
getContextAttributes
read
, write
initCompositionEvent
item
pictureInPictureEnabled
, rootElement
, exitPictureInPicture
, hasStorageAccess
, requestStorageAccess
caretPositionFromPoint
, getAnimations
part
msGetRegionContent
webkitRelativePath
hand
, pose
pulse
captureStream
transferControlToOffscreen
outerText
requestSubmit
allowPaymentRequest
capture
, webkitEntries
, webkitdirectory
onbounce
, onfinish
, onstart
disableRemotePlayback
, remote
form
disablePictureInPicture
, onenterpictureinpicture
, onleavepictureinpicture
, requestPictureInPicture
request
databases
commit
dataTransfer
, getTargetRanges
initKeyboardEvent
char
pseudoElement
getDisplayMedia
contentHint
initMessageEvent
mediaCapabilities
, mediaSession
activeVRDisplays
, msManipulationViewsEnabled
, msMaxTouchPoints
, msPointerEnabled
, getUserMedia
, getVRDisplays
, msLaunchUri
, msSaveBlob
, msSaveOrOpenBlob
namespaceURI
actions
, badge
, image
, renotify
, requireInteraction
, silent
, timestamp
, vibrate
onshippingaddresschange
, onshippingoptionchange
, shippingAddress
, shippingOption
, shippingType
onpayerdetailchange
, payerEmail
, payerName
, payerPhone
, shippingAddress
, shippingOption
, addEventListener
, removeEventListener
detail
detail
expirationTime
userVisibleOnly
iceTransport
, onerror
, getRemoteCertificates
address
ongatheringstatechange
, onselectedcandidatepairchange
, onstatechange
, role
, getLocalCandidates
, getLocalParameters
, getRemoteCandidates
, getRemoteParameters
, getSelectedCandidatePair
, addEventListener
, removeEventListener
idpErrorInfo
, idpLoginUrl
, peerIdentity
, sctp
, getIdentityAssertion
, setIdentityProvider
setCodecPreferences
forEach
isHistoryNavigation
, isReloadNavigation
trailer
rel
, relList
beginElement
, beginElementAt
, endElement
, endElementAt
pathSegList
, getPointAtLength
, getTotalLength
onunload
, onzoom
, getComputedStyle
length
viewTarget
disposition
, sample
navigationPreload
, sync
delegatesFocus
changeType
initStorageEvent
fontBoundingBoxAscent
, fontBoundingBoxDescent
altitudeAngle
, azimuthAngle
, touchType
initUIEvent
corruptedVideoFrames
cancelIdleCallback
, requestIdleCallback
applicationCache
, defaultStatus
, doNotTrack
, msContentScript
, offscreenBuffering
, oncompassneedscalibration
, ondeviceorientationabsolute
, ongamepadconnected
, ongamepaddisconnected
, onmousewheel
, onreadystatechange
, onvrdisplayactivate
, onvrdisplayblur
, onvrdisplayconnect
, onvrdisplaydeactivate
, onvrdisplaydisconnect
, onvrdisplaypresentchange
, styleMedia
, departFocus
, getMatchedCSSRules
, msWriteProfilerMark
, webkitCancelAnimationFrame
, webkitConvertPointFromNodeToPage
, webkitConvertPointFromPageToNode
, webkitRequestAnimationFrame
close
signal
colorSpace
, willReadFrequently
startTime
playbackRate
dataTransfer
, targetRanges
pseudoElement
encryptionScheme
preferCurrentTab
cursor
, displaySurface
, logicalSurface
suppressLocalAudioPlayback
autoGainControl
, noiseSuppression
, resizeMode
restrictOwnAudio
autoGainControl
, channelCount
, latency
, noiseSuppression
, resizeMode
suppressLocalAudioPlayback
autoGainControl
, channelCount
, latency
, noiseSuppression
, resizeMode
playbackRate
shippingOptions
error
, payerErrors
, shippingAddressErrors
payer
, shippingAddress
bytesDiscardedOnSend
, circuitBreakerTriggerCount
, consentExpiredTimestamp
, consentRequestsSent
, currentRtt
, firstRequestTimestamp
, lastPacketReceivedTimestamp
, lastPacketSentTimestamp
, lastRequestTimestamp
, lastResponseTimestamp
, packetsDiscardedOnSend
, packetsReceived
, packetsSent
, priority
, retransmissionsReceived
, retransmissionsSent
, totalRtt
errorText
statusText
priority
degradationPreference
voiceActivityFlag
iceRole
, packetsReceived
, packetsSent
, selectedCandidatePairChanges
, tlsGroup
disposition
, sample
slotAssignment
files
which
"remove"
scrollPathIntoView
pictureInPictureElement
, getAnimations
caretPositionFromPoint
, caretRangeFromPoint
, elementFromPoint
, elementsFromPoint
, getSelection
"formdata"
, "webkitanimationend"
, "webkitanimationiteration"
, "webkitanimationstart"
, "webkittransitionend"
"cancel"
, "dragexit"
onformdata
, onwebkitanimationend
, onwebkitanimationiteration
, onwebkitanimationstart
, onwebkittransitionend
oncancel
, ondragexit
, onsecuritypolicyviolation
unregisterProtocolHandler
replaceChildren
"shippingaddresschange"
, "shippingoptionchange"
"error"
"SVGUnload"
, "SVGZoom"
"abort"
, "afterprint"
, "beforeprint"
, "beforeunload"
, "blur"
, "canplay"
, "canplaythrough"
, "change"
, "click"
, "compassneedscalibration"
, "contextmenu"
, "dblclick"
, "deviceorientationabsolute"
, "drag"
, "dragend"
, "dragenter"
, "dragleave"
, "dragover"
, "dragstart"
, "drop"
, "durationchange"
, "emptied"
, "ended"
, "error"
, "focus"
, "hashchange"
, "input"
, "invalid"
, "keydown"
, "keypress"
, "keyup"
, "load"
, "loadeddata"
, "loadedmetadata"
, "loadstart"
, "message"
, "mousedown"
, "mouseenter"
, "mouseleave"
, "mousemove"
, "mouseout"
, "mouseover"
, "mouseup"
, "mousewheel"
, "offline"
, "online"
, "pagehide"
, "pageshow"
, "pause"
, "play"
, "playing"
, "popstate"
, "progress"
, "ratechange"
, "readystatechange"
, "reset"
, "resize"
, "scroll"
, "seeked"
, "seeking"
, "select"
, "stalled"
, "storage"
, "submit"
, "suspend"
, "timeupdate"
, "unload"
, "volumechange"
, "vrdisplayactivate"
, "vrdisplayblur"
, "vrdisplayconnect"
, "vrdisplaydeactivate"
, "vrdisplaydisconnect"
, "vrdisplaypresentchange"
, "waiting"
"gamepadconnected"
, "gamepaddisconnected"
ongamepadconnected
, ongamepaddisconnected
crossOriginIsolated
memory
, exception
"applet"
"animate"
, "animateMotion"
, "animateTransform"
, "feDropShadow"
, "mpath"
, "set"
index.iterable.d.ts
vibrate
The following four types also seems to be removed, but are not mentioned in the above list :
@types/web@0.0.16
should be the version which is shipped with TS 4.4rc
Found undocumented breaking change: PermissionName
has less union members than 4.3 which cause the following code type error.
navigator.permissions.query({ name: 'camera' })
See: https://w3c.github.io/permissions/#enumdef-permissionname
Breaking change documented wrong:
CryptoKeyPair
didn't get removed.
// 4.3
interface CryptoKeyPair {
privateKey: CryptoKey;
publicKey: CryptoKey;
}
// 4.4
interface CryptoKeyPair {
privateKey?: CryptoKey;
publicKey?: CryptoKey;
}
ClipboardItem
constructor type is wrong. According to MDN, it should be string | Blob | Promise<string | Blob>
.
In 4.3 it is string | Blob
, in 4.4 it is Promise<string | Blob>
which is wrong.
Found undocumented breaking change:
PermissionName
has less union members than 4.3 which cause the following code type error.navigator.permissions.query({ name: 'camera' })
See: https://w3c.github.io/permissions/#enumdef-permissionname
Camera permission is at risk because of lack of multiple implementation, so I guess the work item is to document the removal.
ClipboardItem
constructor type is wrong. According to MDN, it should bestring | Blob | Promise<string | Blob>
.In 4.3 it is
string | Blob
, in 4.4 it isPromise<string | Blob>
which is wrong.
I want to add (deprecated: ref #884) mouseWheelEvent
to the list of removed types
Undocumented change msSaveBlob
was removed from window.navigator
in TypeScript 4.4.2.
I tried upgrading from TS 4.3.5 to 4.4.2 today and encountered two issues:
HTMLDialogElement
went missing (as a value, not as a type). This is noted in the list above. But why? It's supported by Chrome, Edge, and Opera, and by Firefox behind a flag. The type is still present, as it is needed to represent <dialog>
elements. I can write declare var HTMLDialogElement: HTMLDialogElement;
to allow using it as a value, but then element instanceof HTMLDialogElement
no longer works as a type guard.HTMLInputElement.autofocus
was removed. This is not noted in the list above. This seems like a bug since it is supported in every browser. The MDN page's browser compatibility section just refers to the page for the global autofocus attribute where it is noted as fully supported in Chrome, Edge, and Opera, and supported everywhere on several elements including HTMLInputElement. In my case, I have a custom JSX implementation, and I basically have to patch the HTMLInputElement
type to work around this.It would be great if these changes could be reverted.
HTMLDialogElement
went missing (as a value, not as a type). This is noted in the list above. But why? It's supported by Chrome, Edge, and Opera, and by Firefox behind a flag. The type is still present, as it is needed to represent<dialog>
elements. I can writedeclare var HTMLDialogElement: HTMLDialogElement;
to allow using it as a value, but thenelement instanceof HTMLDialogElement
no longer works as a type guard.
Chrome/Edge/Opera all uses the same engine Blink and no other engine supports it without a flag, that is why. Please refer to https://github.com/microsoft/TypeScript-DOM-lib-generator#when-the-type-is-missing for the reasoning here.
HTMLInputElement.autofocus
was removed. This is not noted in the list above. This seems like a bug since it is supported in every browser. The MDN page's browser compatibility section just refers to the page for the global autofocus attribute where it is noted as fully supported in Chrome, Edge, and Opera, and supported everywhere on several elements including HTMLInputElement. In my case, I have a custom JSX implementation, and I basically have to patch theHTMLInputElement
type to work around this.
Fixed by #1111
Thanks, I read that section of the README but it's not clear about flagged features, plus <dialog>
is enabled by default in Firefox Nightly.
Why was hashchange
event removed? Now there is only Event
which doesn't have newURL
property:
https://www.typescriptlang.org/play?ts=4.4.2#code/O4SwdgJg9sB0CGEIFEBuBTMAXAMiAzlpugE4AUA5ABbz5UDGNYA5uhQDQAEZ6AXJwAlaVAMJNWaTFgCUnALwA+TgG90sMOmABVAEo4AvtKA
Why was
hashchange
event removed? Now there is onlyEvent
which doesn't havenewURL
property: https://www.typescriptlang.org/play?ts=4.4.2#code/O4SwdgJg9sB0CGEIFEBuBTMAXAMiAzlpugE4AUA5ABbz5UDGNYA5uhQDQAEZ6AXJwAlaVAMJNWaTFgCUnALwA+TgG90sMOmABVAEo4AvtKA
Fixed by #1104
Location#reload(forcedReload: boolean): void
was removed as well.
Was that intended?
Location#reload(forcedReload: boolean): void
was removed as well. Was that intended?
It's currently a Firefox specific extension, so yes, that was intended.
Hello, speech recognition apis have been removed but i don't find informations about deprecation of this technology.
is there a remplacement api ?
Hello, speech recognition apis have been removed but i don't find informations about deprecation of this technology.
is there a remplacement api ?
It's not deprecated, it's just not mature enough with no prefix-less implementation and being still in WICG (where immature specifications exist).
Just a query, maybe my bad understanding, but File.webkitRelativePath is not a standard property and, according to MDN, should NOT be used on production sites. Can this be made optional or removed (or is my understanding here wrong)? https://developer.mozilla.org/en-US/docs/Web/API/File/webkitRelativePath
I believe ClipboardItem constructor should be restricted to only accept Blob
. Blink has only partial support for ClipboardItem - as per MDN:
The ClipboardItem constructor only accepts a blob as the item data, but not strings or Promises that resolve to strings or blobs. See bug 1014310.
I believe ClipboardItem constructor should be restricted to only accept
Blob
. Blink has only partial support for ClipboardItem - as per MDN:The ClipboardItem constructor only accepts a blob as the item data, but not strings or Promises that resolve to strings or blobs. See bug 1014310.
Makes sense, do you want to write a patch?
sorry for the noob question: how is it decided which interfaces get added or removed? at what point do changes usually end up in microsoft/TypeScript?
the new TS features are great, but sadly all the dom type changes are a bit of a disincentive to upgrade for me at the moment. for example, some code that I work on uses RTCSctpTransport
which is still in the spec, has no "feature at risk" annotation, and still works in chrome :/
nonetheless thanks for all the great work.
Mostly based on MDN browser compatibility data. For example, RTCSctpTransport
is marked as Chrome(ium)-only on MDN: https://developer.mozilla.org/en-US/docs/Web/API/RTCSctpTransport#browser_compatibility
FYI at Chrome DevTools we have started our attempts to upgrade to TypeScript 4.4.2, but sadly this issue is one the major timesinks for this release. Initial big hitters are:
getSelection
removed from ShadowRoot
getElementFromPoint
removed from ShadowRoot
DOMError
unknown
in catch (but we were able to turn off the config setting for this 👍 )Unfortunately, adding @types/web
isn't as straightforward for us and also does not appear to resolve the situation for us where we rely on Chromium-only API's. That said, Chrome DevTools is probably in a special situation where we run on a single engine, so sometimes we use modern API's that are not supported on other engines just yet.
It seems like our Google internal team ran into similar issues before: https://github.com/microsoft/TypeScript-DOM-lib-generator/issues/1067 But since we use a different stack and upgrade TypeScript at our own pace, we ran into this later than them.
I think the correct approach would be to add @deprecated
with an explanation to the functions or properties that will be removed in the next major release. With this approach, developers will be able to see that object.deprecated is going to be removed and can raise their concerns before the removal happens.
With the current approach, you need won't realize that a change is coming if you are not actively using the beta or RC version of TypeScript, because in 4.3 the function exists and in 4.4 the function is gone.
4.4 was a special release that trimmed a lot of nonstandard things, I think any future releases will follow W3C/WHATWG deprecation step.
The removal of autoGainControl and noiseSuppression caused a build break. This is supported in most browsers and outlined in W3C Capture Streams - https://www.w3.org/TR/mediacapture-streams/#dom-mediatracksupportedconstraints-autogaincontrol Can you provide any insight into why it was removed?
The removal of the userVisibleOnly
property from the PushSubscriptionOptions
interface caused issues in a project where WebPush is being used. Chrome & Edge still require userVisibleOnly
to be set when calling PushManager.subscribe()
or the call will fail. userVisibleOnly
is also still documented in the latest W3C Push API Draft: https://www.w3.org/TR/push-api/#pushsubscriptionoptions-interface. Is there a reason why this property was removed?
The removal of autoGainControl and noiseSuppression caused a build break. This is supported in most browsers and outlined in W3C Capture Streams - https://www.w3.org/TR/mediacapture-streams/#dom-mediatracksupportedconstraints-autogaincontrol Can you provide any insight into why it was removed?
Seems they are supported on Firefox and Chrome. PR welcome.
userVisibleOnly
is also still documented in the latest W3C Push API Draft: https://www.w3.org/TR/push-api/#pushsubscriptionoptions-interface. Is there a reason why this property was removed?
See MDN for the data. Note that PushSubscrptionOptionsInit
still has userVisibleOnly
so the option still can be set. (Logically it shouldn't exist either but there is no good way to autodetect dictionary member support.)
Why did you remove OffscreenCanvas? It is available in Edge, Chrome and Opera.
Those are all chromium, and collectively only count as one browser implementation
@orta Well, but if all browsers would be chromium based, they would be count as one and we would have nothing at all :-) I think, other criteria such as usage in %, global diffusion,... would be more correct.
Thanks, I read that section of the README but it's not clear about flagged features, plus
<dialog>
is enabled by default in Firefox Nightly.
I also think that the tag deprecated
is quite misleading, since it is an upcoming feature which is about to be supported. As @IceCreamYou stated, it is already also by the nightly build of Firefox.
Since I'm working with electron, which uses chromium, it would be helpful to have the dom.d.ts for chrome. Is that available and how?
Well, but if all browsers would be chromium based
C'mon, you know that's not true. Let's be realistic here, we'd not be working to the idea of web standards if we pretend that the only things which matter are Google's choices of how it runs its browser. There are three major browsers, and using consensus between them is a good strategy for deciding if something is adopted for the long-term.
it would be helpful to have the dom.d.ts for chrome
You're welcome to build a version of the dom.d.ts for just chromium, the upcoming TypeScript 4.5 include a feature which allows folks to switch out that with their own version https://github.com/microsoft/TypeScript/issues/44795 which makes that much easier to set up, though it would be possible to do today - you'd probably want to fork this repo and start from there. You can mix it with browser-compat-data to determine what is available.
Small remark about the new NetworkInformation
interface from my side: it contains only .type
, but not .effectiveType
nor other fields. Based on MDN data, .effectiveType
support level is similar to .type
:
https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation#browser_compatibility
Small remark about the new
NetworkInformation
interface from my side: it contains only.type
, but not.effectiveType
nor other fields. Based on MDN data,.effectiveType
support level is similar to.type
: https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation#browser_compatibility
Good catch, PR welcome.
Why were elementFromPoint
, elementsFromPoint
removed from DocumentOrShadowRoot? These exist on ShadowRoot and weren't added to it, so compilation breaks now when using them.
Why were
elementFromPoint
,elementsFromPoint
removed from DocumentOrShadowRoot? These exist on ShadowRoot and weren't added to it, so compilation breaks now when using them.
@saschanaz thanks! Has that fix made it into typescript@next
?
Nah, but you can try it today by installing @types/web
from npm! (Please read the guide in that page to deploy it)
Why don't ya'll add an @experimental
tag that is similar to @deprecated
and not break apps? Does the TS team know how annoying in-range breaks are?
add an @experimental tag that is similar to @deprecated and not break apps
Great suggestion! It's really bad when TypeScript suggests you're working with outdated technology, when you are actually using upcoming ones.
Any references as to why InputDeviceInfo
is deleted? It isn't marked deprecated or deleted on MDN:
https://developer.mozilla.org/en-US/docs/Web/API/InputDeviceInfo
That's because the previous version of BCD marked it as unsupported. https://github.com/mdn/browser-compat-data/pull/12451 fixed it, so it will also be fixed soon here. Thanks @queengooborg 👍
The removal of OffscreenCanvas
and associated symbols broke my project, so I tried declaration merging.
I had issues though. This is my custom offscreenCanvas.d.ts
, extracted from a 4.3.* lib.dom.d.ts
(errors denoted by comments):
/// <reference lib="dom" />
interface HTMLCanvasElement extends HTMLElement {
transferControlToOffscreen(): OffscreenCanvas;
}
interface ImageBitmapRenderingContext {
// Error: Subsequent property declarations must have the same type. Property 'canvas' must be of type 'HTMLCanvasElement', but here has type 'HTMLCanvasElement | OffscreenCanvas'.
readonly canvas: HTMLCanvasElement | OffscreenCanvas;
}
interface WebGLRenderingContextBase {
// Error: Subsequent property declarations must have the same type. Property 'canvas' must be of type 'HTMLCanvasElement'
readonly canvas: HTMLCanvasElement | OffscreenCanvas;
}
interface OffscreenCanvas extends EventTarget {
height: number;
width: number;
// Error: Cannot find name 'ImageEncodeOptions'
convertToBlob(options?: ImageEncodeOptions): Promise<Blob>;
getContext(contextId: "2d", options?: CanvasRenderingContext2DSettings): OffscreenCanvasRenderingContext2D | null;
getContext(contextId: "bitmaprenderer", options?: ImageBitmapRenderingContextSettings): ImageBitmapRenderingContext | null;
getContext(contextId: "webgl", options?: WebGLContextAttributes): WebGLRenderingContext | null;
getContext(contextId: "webgl2", options?: WebGLContextAttributes): WebGL2RenderingContext | null;
getContext(contextId: OffscreenRenderingContextId, options?: any): OffscreenRenderingContext | null;
transferToImageBitmap(): ImageBitmap;
}
declare var OffscreenCanvas: {
prototype: OffscreenCanvas;
new(width: number, height: number): OffscreenCanvas;
};
interface OffscreenCanvasRenderingContext2D extends CanvasCompositing, CanvasDrawImage, CanvasDrawPath, CanvasFillStrokeStyles, CanvasFilters, CanvasImageData, CanvasImageSmoothing, CanvasPath, CanvasPathDrawingStyles, CanvasRect, CanvasShadowStyles, CanvasState, CanvasText, CanvasTextDrawingStyles, CanvasTransform {
readonly canvas: OffscreenCanvas;
commit(): void;
}
declare var OffscreenCanvasRenderingContext2D: {
prototype: OffscreenCanvasRenderingContext2D;
new(): OffscreenCanvasRenderingContext2D;
};
type OffscreenRenderingContextId = "2d" | "bitmaprenderer" | "webgl" | "webgl2";
type OffscreenRenderingContext = OffscreenCanvasRenderingContext2D | ImageBitmapRenderingContext | WebGLRenderingContext | WebGL2RenderingContext;
// Error: Duplicate identifier 'CanvasImageSource '.
type CanvasImageSource = HTMLOrSVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | OffscreenCanvas;
// Error: Duplicate identifier 'TexImageSource '.
type TexImageSource = ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas;
// Error: Duplicate identifier 'Transferable'.
type Transferable = ArrayBuffer | MessagePort | ImageBitmap | OffscreenCanvas;
I get that the errors are to-be-expected. What I'm curious about is how or if they can be worked around - am I missing something with declaration merging? If not, what should projects using experimental symbols that cannot be added using declaration merging do? Is hand editing lib.dom.d.ts
the way to go?
@JeremyTCD Just use my declarations from DefinitlyTyped https://www.npmjs.com/package/@types/offscreencanvas
@ova2 After installing I still had errors because of type usage in my code, e.g. Transferable
arguments. But I got the gist of how to work around these issues from your typings.
Instead of trying to overload types, e.g:
type Transferable = ArrayBuffer | MessagePort | ImageBitmap | OffscreenCanvas;
I should've been looking for usages of types and replacing them with union types, e.g. Transferable
> Transferable | OffscreenCanvas
.
Thanks for the tip!
It's strongly misleading to mark experimental technologies, which I want to use to be in the front line, as @deprecated, which is the opposite from this perspective. Instead, @experimental would be helpful and highly appreciated!
Yeah, we're not planning on marking APIs which haven't got to the point of being supported in many browsers with @deprecated
- they're just not meant to be in the DOM types shipped with TypeScript
The idea of using @experimental
is cool, but that also means shipping definitions which are ahead of their time which we shouldn't do IMO. That's what DefinitelyTyped is for.
The size of this thread actually suggests that many people are irritated, that their applications suddenly appear buggy. And now we are forced to resort to solutions that feel like workarounds. I'd actually appreciate it a lot if the standard typescript packages would allow me to use upcoming technologies and simply hint about.
Isn't that one of the great features of TypeScript that we can use the standards of tomorrow already today?
Beta
With TypeScript 4.4, we coordinated some pretty fundamental infrastructure work to prepare for the version of
dom.d.ts
with the future of the generator repo. This work resulted in two note-worthy items:The
dom.d.ts
files typically accessed inside TypeScript are now also deployed to@types/web
starting with version0.0.1
which corresponds to the version oflibdom.d.ts
in TypeScript 4.3. This means an update to TypeScript 4.4 does not mean you have to update all of your web.d.ts
files.The name change is to more accurately reflect the scope of the APIs, for a long time the file has provided much more APIs than just the DOM and
@types/web
reflects that. If you're interested in switching to use@types/web
, there are instructions in the npm README.The 4.4
dom.d.ts
file which is included with TypeScript includes quite a lot of changes, with a lot of APIs which have been marked as deleted by the web standards committees. You can see the full list in this issueWe've been testing these changes with DefinitelyTyped, and have been individually rolling back changes which we think are a bit too breaking, this is more of an art than a science however. If you think we should rollback a particular change we're open to discussing change in this issue or the
dom-lib-generator
channel in the TypeScript Community DiscordWe plan to have thorough support for replacing
lib.dom.d.ts
with@types/web
in 4.5 with https://github.com/microsoft/TypeScript/issues/44795