Skip to content

fix(40454): allow IntersectionObserverInit.root to accept type Docume… #909

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

Merged
merged 2 commits into from
Oct 5, 2020

Conversation

troyt-42
Copy link
Contributor

…nt and update IntersectionObserver.root to be of type Node

Fix microsoft/TypeScript#40454

@troyt-42 troyt-42 requested a review from sandersn as a code owner September 10, 2020 15:16
@ghost
Copy link

ghost commented Sep 10, 2020

CLA assistant check
All CLA requirements met.

@saschanaz
Copy link
Contributor

The right way to do this is updating idlSource.json to point https://w3c.github.io/IntersectionObserver/ and running npm run fetch-idl "Intersection Observer" && npm run build && npm run baseline-accept, so that we can keep syncing with the upstream changes.

@troyt-42
Copy link
Contributor Author

@saschanaz thanks for the comment! I tried that approach, but it seems https://w3c.github.io/IntersectionObserver/ changed all void type to undefined type
image
which makes the script throws

Error: Unknown DOM type: undefined
    at convertDomTypeToTsTypeSimple (/Users/troytao/TSJS-lib-generator/lib/emitter.js:301:15)
    at convertDomTypeToTsTypeWorker (/Users/troytao/TSJS-lib-generator/lib/emitter.js:239:28)
    at convertDomTypeToTsType (/Users/troytao/TSJS-lib-generator/lib/emitter.js:233:22)
    at emitSignature (/Users/troytao/TSJS-lib-generator/lib/emitter.js:598:26)
    at /Users/troytao/TSJS-lib-generator/lib/emitter.js:610:45
    at Array.forEach (<anonymous>)
    at emitSignatures (/Users/troytao/TSJS-lib-generator/lib/emitter.js:610:30)
    at emitMethod (/Users/troytao/TSJS-lib-generator/lib/emitter.js:590:13)
    at /Users/troytao/TSJS-lib-generator/lib/emitter.js:620:31
    at Array.forEach (<anonymous>)

Is it ok if I add a ['undefined', 'void'] to baseTypeConversionMap in emitter.ts to fix this ?

@saschanaz
Copy link
Contributor

Is it ok if I add a ['undefined', 'void'] to baseTypeConversionMap in emitter.ts to fix this ?

Gread find! Yes, that will fix it.

@troyt-42 troyt-42 force-pushed the master branch 2 times, most recently from 3633391 to dab2303 Compare September 10, 2020 20:52
@troyt-42
Copy link
Contributor Author

@saschanaz updated!

Copy link
Contributor

@saschanaz saschanaz left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@troyt-42
Copy link
Contributor Author

troyt-42 commented Oct 5, 2020

@sandersn poke you for merging this PR ...

src/helpers.ts Outdated
@@ -16,7 +16,8 @@ export const baseTypeConversionMap = new Map<string, string>([
["sequence", "Array"],
["record", "Record"],
["FrozenArray", "ReadonlyArray"],
["EventHandler", "EventHandler"]
["EventHandler", "EventHandler"],
["undefined", "void"]
Copy link
Contributor

Choose a reason for hiding this comment

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

BTW, #920 did this in another way so we don't need this anymore. Sorry, but still was a good work!

@saschanaz
Copy link
Contributor

Could you run npm run fetch-idl "Intersection Observer" && npm run build && npm run baseline-accept once again? I think that will fix the attribute type also to Element | Document | null.

@troyt-42
Copy link
Contributor Author

troyt-42 commented Oct 5, 2020

@saschanaz thanks for notifying! I just rebased the PR, removed the change in helpers.ts and ran npm run fetch-idl "Intersection Observer" && npm run build && npm run baseline-accept.

@saschanaz
Copy link
Contributor

saschanaz commented Oct 5, 2020

The TypeScript team will review and merge this when the "review time" comes, so please wait until that happens 🙏

@sandersn sandersn merged commit 469ba81 into microsoft:master Oct 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IntersectionObserverInit.root should accept type Document
3 participants