Skip to content

Fix missing optional parameter of createImageBitmap #571

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 11 commits into from
Feb 25, 2020

Conversation

hexrcs
Copy link
Contributor

@hexrcs hexrcs commented Oct 2, 2018

TypeScript Issue # 27475

  1. ImageBitmapOptions was declared both in addedTypes.json as an interface and in idl/HTML - ImageBitmap and animations.widl as a dictionary, which is I believe the root cause of it not showing up as an optional parameter inside createImageBitmap method. I removed the interface declaration.
  2. Window and Worker have different supports for ImageBitmapSource (see this conversation). I created two distinct types ImageBitmapSourceWindow and ImageBitmapSourceWorker for them in the widl files.

This is my first PR to a major open source project ;) Please kindly review the changes I made. Suggestions would be much appreciated!

@msftclas
Copy link

msftclas commented Oct 2, 2018

CLA assistant check
All CLA requirements met.

Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

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

I would like to return the definition of imageBitmapOptions to using inline unions instead of aliases.

@@ -17647,6 +17650,7 @@ type CanvasTextBaseline = "top" | "hanging" | "middle" | "alphabetic" | "ideogra
type ChannelCountMode = "max" | "clamped-max" | "explicit";
type ChannelInterpretation = "speakers" | "discrete";
type ClientTypes = "window" | "worker" | "sharedworker" | "all";
type ColorSpaceConversion = "none" | "default";
Copy link
Member

Choose a reason for hiding this comment

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

Small global aliases are annoying because of alias interning: everybody with a type none | default will now see the name ColorSpaceConversion for it.

Not sure the best workaround for this. I’ll think about it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for reviewing, I will find time to come back and reconsider about this PR soon. :)

@@ -396,45 +396,6 @@
}
}
},
"ImageBitmapOptions": {
Copy link
Member

Choose a reason for hiding this comment

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

What replaces this entry? Whatever it is, it results in a whole bunch of unwanted type aliases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The already existing dictionary ImageBitmapOptions in HTML - ImageBitmap and animations.widl replaces this entry. This was a conflict if I remember right.

@saschanaz
Copy link
Contributor

Are the IDL changes hand-written or generated by npm run fetch?

@hexrcs
Copy link
Contributor Author

hexrcs commented Nov 14, 2018

Are the IDL changes hand-written or generated by npm run fetch?

@saschanaz Sorry for the delay. They are handwritten. *.d.ts are generated.

@saschanaz
Copy link
Contributor

Sorry to be late, but IDLs must not be hand-written and instead should be generated by npm run fetch -- (SpecName).

@saschanaz
Copy link
Contributor

@hexrcs Mind refreshing this PR? The removal in addedTypes.json looks great but the manual edits in *.widl do not. Can you remove them and do npm run build && npm run baseline-accept?

Some explanation: The old item in addedTypes.json was incorrectly registered as an interface with no exposed field rather than a dictionary. This caused confusion and caused unexpected deletions as the code thought ImageBitmapOptions (and some typedefs referenced solely from it) shouldn't be exposed in any files.

@hexrcs
Copy link
Contributor Author

hexrcs commented Jan 29, 2019

@saschanaz Yes, would like to! Will be checking this out tonight or tomorrow. Thanks for the clarification.

@hexrcs
Copy link
Contributor Author

hexrcs commented Jan 31, 2019

@saschanaz Hi, which SpecName should I use to run npm run fetch -- (SpecName)? There doesn't seem to be any documentation about this. Thanks!

@hexrcs
Copy link
Contributor Author

hexrcs commented Jan 31, 2019

I tried to run npm run fetch -- "HTML - Web application APIs" after reading #628 (comment) , but the fetch script went on to update all the .widl files and ended up with an error.

Looks like something's wrong with WebGL2RenderingContext?

npm run fetch -- "HTML - Web application APIs"

> tsjs-lib-generator@ fetch /Volumes/SSD2/opensource/ms/TSJS-lib-generator
> echo This could take a few minutes... && npm run fetch-idl && npm run fetch-mdn "HTML - Web application APIs"

This could take a few minutes...

> tsjs-lib-generator@ fetch-idl /Volumes/SSD2/opensource/ms/TSJS-lib-generator
> npm run build && node ./lib/idlfetcher.js


> tsjs-lib-generator@ build /Volumes/SSD2/opensource/ms/TSJS-lib-generator
> tsc --p ./tsconfig.json && node ./lib/index.js


> tsjs-lib-generator@ fetch-mdn /Volumes/SSD2/opensource/ms/TSJS-lib-generator
> npm run build && node ./lib/mdnfetcher.js "HTML - Web application APIs"


> tsjs-lib-generator@ build /Volumes/SSD2/opensource/ms/TSJS-lib-generator
> tsc --p ./tsconfig.json && node ./lib/index.js

/Volumes/SSD2/opensource/ms/TSJS-lib-generator/lib/emitter.js:281
        throw new Error("Unknown DOM type: " + objDomType);
        ^

Error: Unknown DOM type: WebGL2RenderingContext
    at convertDomTypeToTsTypeSimple (/Volumes/SSD2/opensource/ms/TSJS-lib-generator/lib/emitter.js:281:15)
    at convertDomTypeToTsTypeWorker (/Volumes/SSD2/opensource/ms/TSJS-lib-generator/lib/emitter.js:221:28)
    at Array.map (<anonymous>)
    at convertDomTypeToTsTypeWorker (/Volumes/SSD2/opensource/ms/TSJS-lib-generator/lib/emitter.js:224:36)
    at convertDomTypeToTsType (/Volumes/SSD2/opensource/ms/TSJS-lib-generator/lib/emitter.js:215:22)
    at emitTypeDef (/Volumes/SSD2/opensource/ms/TSJS-lib-generator/lib/emitter.js:906:60)
    at Array.forEach (<anonymous>)
    at emitTypeDefs (/Volumes/SSD2/opensource/ms/TSJS-lib-generator/lib/emitter.js:910:37)
    at emit (/Volumes/SSD2/opensource/ms/TSJS-lib-generator/lib/emitter.js:946:9)
    at Object.emitWebIdl (/Volumes/SSD2/opensource/ms/TSJS-lib-generator/lib/emitter.js:136:70)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! tsjs-lib-generator@ build: `tsc --p ./tsconfig.json && node ./lib/index.js`
npm ERR! Exit status 1

@saschanaz
Copy link
Contributor

Hi, which SpecName should I use to run npm run fetch -- (SpecName)?

"HTML - ImageBitmap and animations", but it can be skipped for this PR. Looks like npm run build && npm run baseline-accept will fix the test.

@saschanaz
Copy link
Contributor

Ah right, the code has been updated and now it should be npm run fetch-idl (note the -idl). Sorry for the confusion 😅

@saschanaz
Copy link
Contributor

Looks like something's wrong with WebGL2RenderingContext?

That should be fixed by #648, it's because other specs has started referencing it while the code doesn't know about it.

@hexrcs
Copy link
Contributor Author

hexrcs commented Jan 31, 2019

@saschanaz Done! Could you please review again? 😃

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.

👍 but still needs an approval from @sandersn

@benjamind
Copy link

Any progress or guidance on how to use createImageBitmap with options at this time?

@sandersn sandersn merged commit c5ad7c3 into microsoft:master Feb 25, 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.

6 participants