Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate latest dom types into libdom.d.ts #44684

Merged
merged 4 commits into from
Jun 25, 2021
Merged

Conversation

orta
Copy link
Contributor

@orta orta commented Jun 21, 2021

Re: #44424 and microsoft/TypeScript-DOM-lib-generator#1023

types-web is the very actively maintained version of lib dom, most likely the version which we'd be basing @types/web on. It's quite far ahead of the current TS .d.ts.

Note that there are new failures from this, I think due to the addition of readonly attributes

    tests/baselines/reference/mappedTypeRecursiveInference.errors.txt
    tests/baselines/reference/varianceCallbacksAndIndexedAccesses.errors.txt

@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Jun 21, 2021
@orta
Copy link
Contributor Author

orta commented Jun 21, 2021

@typescript-bot test this
@typescript-bot run dt

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jun 21, 2021

Heya @orta, I've started to run the parallelized Definitely Typed test suite on this PR at ea65c43. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jun 21, 2021

Heya @orta, I've started to run the extended test suite on this PR at ea65c43. You can monitor the build here.

@orta
Copy link
Contributor Author

orta commented Jun 21, 2021

Some notes as I go through the fails

  • console.exception is deprecated, basically is an alias to error, which is fine
  • somehow JSX is getting defined?
  • We probably need an alias for EventListenerOrEventListenerObject - as that has been recommended for a long time as the way to add typing to events

@sandersn
Copy link
Member

Additional notes:

  • Looks like there might be a bug in reverse mapped types, perhaps to do with readonly. We'll need to file a bug and work around it.
  • The JSX failures are from our old mock version of react@16. It has 13 new errors, but I don't yet know what they are.

@orta
Copy link
Contributor Author

orta commented Jun 22, 2021

Looking at the DT results, I think we'll need to:

  • Get EventListenerOrEventListenerObject back in the dom.d.ts because people extend it (for example angular)
  • EventListener needs to not be a union
  • Revert the readonly prototypes change (lots of assignability issues in DT)
  • Bring back HTMLTableDataCellElement, HTMLTableHeaderCellElement , StyleMedia and ClientRect because React uses
  • Maybe bring back HTMLDocument
  • Not sure what to do with: Interface 'Navigator' incorrectly extends interface 'NavigatorNetworkInformation'.

Maybe OffscreenCanvas needs to come back?

@orta
Copy link
Contributor Author

orta commented Jun 24, 2021

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jun 24, 2021

Heya @orta, I've started to run the extended test suite on this PR at d4afc2e. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jun 24, 2021

Heya @orta, I've started to run the parallelized Definitely Typed test suite on this PR at d4afc2e. You can monitor the build here.

@orta
Copy link
Contributor Author

orta commented Jun 24, 2021

Upstream dom.d.ts changes:

  • We need to add: interface HTMLDialogElement extends HTMLElement {} ( preact and react) which will get TS' test suite green
  • OffscreenCanvas should get addded
  • HTMLDocument - we should add this
  • getUserMedia should come back

Changes to DT:

  • applicationCache for jquerymobile
  • Bunch of pkijs fails for Key params
  • DocumentEvent for tinymce

Something is up with

Error in polymer
Error: Errors in typescript@local for external dependencies:
../webcomponents.js/index.d.ts(68,9): error TS2687: All declarations of 'customElements' must have identical modifiers.
../../../../../../built/local/lib.dom.d.ts(17160,14): error TS2687: All declarations of 'customElements' must have identical modifiers.
  • w3c-css-typed-object-model-level-1 - getMatchedCSSRules was removed
  • Firefox depended on DOMError, can look to see if that's a change upstream probably change

Rest of the tests

sandersn added a commit to DefinitelyTyped/DefinitelyTyped that referenced this pull request Jun 24, 2021
TS 4.4's version of the DOM deprecates some more elements. Remove them
from blissfuljs as well.

microsoft/TypeScript#44684
@sandersn
Copy link
Member

sandersn commented Jun 24, 2021

From DT fixes:

  • SVGCircleElement is now assignable to SVGPathElement because it's a subtype, because SVGPathElement dropped all its non-add/removeEventListener properties. Need to decide if Path should have some artificial property to distinguish it from other SVGGeometryElement subtypes. (from d3-shape/v1)
  • preact uses HTMLDialogElement and will need a PR in order for dependents to use TS 4.4.
  • cordova-plugin-file vendored filesystem/index.d.ts from DT and also needs to be updated. @types/ng-cordova depends on it.

sandersn added a commit to DefinitelyTyped/DefinitelyTyped that referenced this pull request Jun 24, 2021
TS 4.4's version of the DOM deprecates some more elements. Remove them
from blissfuljs as well.

microsoft/TypeScript#44684
@orta
Copy link
Contributor Author

orta commented Jun 24, 2021

Decided against adding navigator.getUserMedia it just needs switching in DT tests to navigator.mediaDevices.getUserMedia

@orta
Copy link
Contributor Author

orta commented Jun 24, 2021

@typescript-bot test this
@typescript-bot run dt

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jun 24, 2021

Heya @orta, I've started to run the parallelized Definitely Typed test suite on this PR at 429c877. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jun 24, 2021

Heya @orta, I've started to run the extended test suite on this PR at 429c877. You can monitor the build here.

sandersn added a commit to DefinitelyTyped/DefinitelyTyped that referenced this pull request Jun 24, 2021
It refers to DOMError, which is no longer declared in TS 4.4's version
of the DOM.

microsoft/TypeScript#44684
sandersn added a commit to DefinitelyTyped/DefinitelyTyped that referenced this pull request Jun 24, 2021
It refers to DOMError, which is no longer declared in TS 4.4's version of the DOM.

microsoft/TypeScript#44684
sandersn added a commit to DefinitelyTyped/DefinitelyTyped that referenced this pull request Jun 25, 2021
@sandersn sandersn merged commit 9ebe11c into microsoft:main Jun 25, 2021
orta added a commit to DefinitelyTyped/DefinitelyTyped that referenced this pull request Jun 25, 2021
@orta
Copy link
Contributor Author

orta commented Jun 26, 2021

@typescript-bot run dt - <edit/> looks like this won't run after the merge

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jun 26, 2021

Heya @orta, I've started to run the parallelized Definitely Typed test suite on this PR at fbce8ed. You can monitor the build here.

sandersn added a commit to DefinitelyTyped/DefinitelyTyped that referenced this pull request Jun 28, 2021
TS 4.4 further changes webrtc types. This PR makes it match those
upcoming types, commenting out types that conflict between 4.4 and
earlier versions of TS.

Needed after microsoft/TypeScript#44684 is merged.
sandersn added a commit to DefinitelyTyped/DefinitelyTyped that referenced this pull request Jun 28, 2021
TS 4.4 changes mediacapture-record types. This PR makes it match those
upcoming types.

Needed after microsoft/TypeScript#44684 is merged.
sandersn added a commit to DefinitelyTyped/DefinitelyTyped that referenced this pull request Jun 28, 2021
* Make webcomponents.js work with TS 4.4 DOM

TS 4.4 improves its types for web components. This PR makes DT match those upcoming types.

Needed after microsoft/TypeScript#44684 is merged.

* specify minimum ts version

* Update minimum TS version of polymer too
sandersn added a commit to DefinitelyTyped/DefinitelyTyped that referenced this pull request Jun 28, 2021
* Make wicg-mediasessions work with TS 4.4 DOM

TS 4.4 improves its types for MediaSesssion. This PR makes DT match those upcoming types.

Needed after microsoft/TypeScript#44684 is merged.

* Fix tests
sandersn added a commit to DefinitelyTyped/DefinitelyTyped that referenced this pull request Jun 28, 2021
* Make requestidlecallback work with TS 4.4 DOM

TS 4.4 improves its types for requestidlecallback. This PR makes DT match those upcoming types.

Needed after microsoft/TypeScript#44684 is merged.

* remove redundant undefined for now
sandersn pushed a commit to DefinitelyTyped/DefinitelyTyped that referenced this pull request Jun 29, 2021
@@ -129,7 +129,7 @@ function test(required1: () => boolean, required2: () => boolean, b: boolean, op
>f.apply : (this: Function, thisArg: any, argArray?: any) => any
>f : () => void
>apply : (this: Function, thisArg: any, argArray?: any) => any
>parent : Window
>parent : Window | null
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* for visibility

It was actually legit comment :) -> microsoft/TypeScript-DOM-lib-generator#1089
thank you @orta @saschanaz

Comment on lines -12899 to -12902
interface SVGElementInstance extends EventTarget {
readonly correspondingElement: SVGElement;
readonly correspondingUseElement: SVGUseElement;
}
Copy link

@buschtoens buschtoens Aug 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These properties used to be available on SVGElement, which used to extend SVGElementInstance in LOC 12883. They disappeared during the upgrade from v4.3.5 to v4.4.2.

Reported here: microsoft/TypeScript-DOM-lib-generator#1023 (comment)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removal was intentional, as per microsoft/TypeScript-DOM-lib-generator#1023 (comment):

Those are not available on any modern browser nor MDN, and thus are probably IE-specific properties. The removal is intended since the types library intends to only include things that exist in modern browsers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants