-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
[trusted-types] Properly augment global to prevent conflicts with lib… #64360
[trusted-types] Properly augment global to prevent conflicts with lib… #64360
Conversation
….dom.d.ts et.all This is the proper patern to augment global interfaces that are defined by the runtime. The previous approach would break once `lib.dom.d.ts` declares these interfaces. The previous approach also made it impossible for other libraries to use these types. For example, DefinitelyTyped#60691 had to be reverted. With proper module augmentation we can land DefinitelyTyped#60691 again.
@eps1lon Thank you for submitting this PR! This is a live comment which I will keep updated. 1 package in this PR@eps1lon: I see that you have added yourself as an owner, are you sure you want to become an owner? Code ReviewsBecause this is a widely-used package, a DT maintainer will need to review it before it can be merged. You can test the changes of this PR in the Playground. Status
Once every item on this list is checked, I'll ask you for permission to merge and publish the changes. Diagnostic Information: What the bot saw about this PR{
"type": "info",
"now": "-",
"pr_number": 64360,
"author": "eps1lon",
"headCommitOid": "b2dda2fc88ad47eae37521d10ea87a57764bd478",
"mergeBaseOid": "784bfdb802a4bebfc0799a0857487c7af5eda9dc",
"lastPushDate": "2023-02-14T20:31:48.000Z",
"lastActivityDate": "2023-02-14T20:37:55.000Z",
"hasMergeConflict": false,
"isFirstContribution": false,
"tooManyFiles": false,
"hugeChange": false,
"popularityLevel": "Critical",
"pkgInfo": [
{
"name": "trusted-types",
"kind": "edit",
"files": [
{
"path": "types/trusted-types/index.d.ts",
"kind": "definition"
},
{
"path": "types/trusted-types/test/browser.ts",
"kind": "test"
}
],
"owners": [
"vrana",
"engelsdamien",
"siegrift",
"bjarkler"
],
"addedOwners": [
"eps1lon"
],
"deletedOwners": [],
"popularityLevel": "Critical"
}
],
"reviews": [],
"mainBotCommentID": 1430339063,
"ciResult": "pass"
} |
🔔 @vrana @engelsdamien @Siegrift @bjarkler — please review this PR in the next few days. Be sure to explicitly select |
Inspecting the JavaScript source for this package found some properties that are not in the .d.ts files. trusted-types (unpkg)was missing the following properties:
|
DefinitelyTyped#64360) * [trusted-types] Properly augment global to prevent conflicts with lib.dom.d.ts et.all This is the proper patern to augment global interfaces that are defined by the runtime. The previous approach would break once `lib.dom.d.ts` declares these interfaces. The previous approach also made it impossible for other libraries to use these types. For example, DefinitelyTyped#60691 had to be reverted. With proper module augmentation we can land DefinitelyTyped#60691 again. * $ExpectError -> @ts-expect-error
This fixes a breakage caused by DefinitelyTyped/DefinitelyTyped#64360, which removed the ability to use Trusted Types in value contexts. PiperOrigin-RevId: 510091208
In particular, replace instanceof checks with trustedTypes.is* checks and typeof expressions with the types themselves. This fixes a breakage caused by DefinitelyTyped/DefinitelyTyped#64360, which removed the ability to use Trusted Types in value contexts. PiperOrigin-RevId: 510091208
In particular, replace instanceof checks with trustedTypes.is* checks and typeof expressions with the types themselves. This fixes a breakage caused by DefinitelyTyped/DefinitelyTyped#64360, which removed the ability to use Trusted Types in value contexts. PiperOrigin-RevId: 510113784
* Add two missing mode bar buttons * Add test with scattermapbox and new button name * Add two more button names * Add test for new button names * 🤖 Merge PR #64342 feat: update @nginstack/engine definitions by @Henato Co-authored-by: Renato <renato@innovaro.com.br> * 🤖 Merge PR #64343 feat: update @nginstack/iquery definitions by @Henato Co-authored-by: Renato <renato@innovaro.com.br> * 🤖 Merge PR #64344 feat: update @nginstack/orm definitions by @Henato Co-authored-by: Renato <renato@innovaro.com.br> * 🤖 Merge PR #64345 feat: update @nginstack/jsunit definitions by @Henato Co-authored-by: Renato <renato@innovaro.com.br> * 🤖 Merge PR #64346 feat: update @nginstack/datasource definitions by @Henato Co-authored-by: Renato <renato@innovaro.com.br> * 🤖 Merge PR #64348 feat: update @nginstack/dev-tools definitions by @Henato Co-authored-by: Renato <renato@innovaro.com.br> * 🤖 Merge PR #64349 feat: update @nginstack/devops definitions by @Henato Co-authored-by: Renato <renato@innovaro.com.br> * 🤖 Merge PR #64240 barnard59-validate-shacl: added ValidationError export by @tpluscode * added ValidationError export * added test * 🤖 Merge PR #64331 [oidc-provider] Expose as ESM module by @BendingBender * 🤖 Merge PR #64198 [plotly.js] Add types for updatemenus by @gjulianm * [plotly.js] Add types for updatemenus Added types for the updatemenus property of layout. This includes two types, UpdateMenu and UpdateMenuButton Reference: https://plotly.com/javascript/reference/layout/updatemenus/#layout-updatemenus-items-updatemenu-visible * [plotly] run prettier * 🤖 Merge PR #63976 update(anchor-js): version 5 bump by @peterblazejewicz - version 5 is breaking (as per release notes) - option for visiblity removed - naming alinged with module documentation (options, visiblity, AnchorJS, etc) with aliases - tests updated https://github.com/bryanbraun/anchorjs/releases/tag/5.0.0 Thanks! * Use GH_DT_MERGEBOT_TOKEN for starting action on dt-mergebot (#64357) * [gapi.client.*] Bulk update Google API namespace (#63835) * 🤖 Merge PR #63909 react-native-sqlite-storage: fixing typos and adding properties by @icehaunter 1. Fixed a typo in a function name 2. Fixed return type of a function 3. Added a missing property * 🤖 Merge PR #62388 feat(geometric): Add lineRotate method to geometric module (geometric v2.4.0) by @tmcw * feat(geometric): Add lineRotate method * Add ScaleX and ScaleY as well * Fix comment style * 🤖 Merge PR #63487 fix : distribute key and restprops in react-table component's props by @Doooooring * fix : distribute key and restprops in react-table component's props * fix : add semicolon in react-table * fix : add the semicolon * [trusted-types] Properly augment global to prevent conflicts with lib… (#64360) * [trusted-types] Properly augment global to prevent conflicts with lib.dom.d.ts et.all This is the proper patern to augment global interfaces that are defined by the runtime. The previous approach would break once `lib.dom.d.ts` declares these interfaces. The previous approach also made it impossible for other libraries to use these types. For example, #60691 had to be reverted. With proper module augmentation we can land #60691 again. * $ExpectError -> @ts-expect-error * 🤖 Merge PR #63315 [ejs] adjust options.root parameter by @mshima * [ejs] adjust root parameter * Update index.d.ts * [ejs] add test for root array * Fix EJS v8 deps --------- Co-authored-by: Piotr Błażejewicz <peterblazejewicz@users.noreply.github.com> * 🤖 Merge PR #63879 [paypal-checkout-components] Add missing `style` and callbacks by @phylor * Add missing `style` and callbacks to paypal-checkout-components * Fix prettier issues * 🤖 Merge PR #64249 meteor: Add new async methods from 2.9 by @ebroder * 🤖 Merge PR #64363 [relay-runtime] Add cacheConfig to subscription config by @merrywhether * 🤖 Merge PR #64337 add zhoverformat to plotly data type by @BMJHayward Co-authored-by: Brendan Hayward <email> * 🤖 Merge PR #64019 Fixed types for types/onfleet__node-onfleet by @YokySantiago Fixed: property types for worker.teams, function types for task.createBatch task.autoAssign * 🤖 Merge PR #63929 [d3-sankey] add Node.fixedValue by @simPod * 🤖 Merge PR #63979 blessed: ListElement.setItems allows string[] by @bennbollay * blessed: ListElement.setItems allows string[] * Update blessed-tests.ts * 🤖 Merge PR #63517 [react-dom] [react-native] fix incorrect typedefs for unstable_batchedUpdates by @k-yle * 🤖 Merge PR #63877 update "wordcloud" types to align upstream by @g-plane * update "wordcloud" types to align upstream * update properties of "wordcloud" * update tests of "wordcloud" * `minFontSize` should be readonly * update library version * 🤖 Merge PR #63926 Update select2 Options.dropdownParent to allow additional types by @jdufresne Per the docs at: https://select2.org/configuration/options-api dropdownParent is allowed to be of type "jQuery selector or DOM node". This can be further seen by the select2 code at: https://github.com/select2/select2/blob/0a30b0b3e67843c09b0bcc4d01e65b72d9b1279f/src/js/select2/dropdown/attachBody.js#L6 * 🤖 Merge PR #63794 [@types/async] Fix return types when callback not provided by @nwalters512 * [@types/async] Fix return types when callback not provided * Remove self as owner * 🤖 Merge PR #63658 [ref-napi] Replace Value<T> with Pointer<T>. by @yfwz100 According to library description, a buffer is always a pointer to the underly type. * 🤖 Merge PR #64020 fix(react-native-background-downloader): correct types for DownloadTaskState by @fivecar It turns out that react-native-background-downloader doesn't actually export this type. Things may seem fine with doing things like `DownloadTaskState.DOWNLOADING` in your code, until you use that in a package that you also then publish yourself. At that point, you'll find the transpiled JS in your package refers to things like react_native_background_downloader_1.DownloadTaskState.DOWNLOADING, which definitely does not exist and will throw at runtime. * 🤖 Merge PR #63968 [Nunjucks] Add `dev` argument to `ConfigureOptions` by @pezholio There is an undocumented `dev` argument that can be sent to `nunjucks.configure`, which allows a full error trace to the thrown (See: mozilla/nunjucks#1430) * 🤖 Merge PR #64073 [canvasjs] Added missing ChartOptions properties by @sampie777 Co-authored-by: S. Jansen <sa.jansen1@gmail.com> * 🤖 Merge PR #64358 Phoenix callbacks can be async by @flupke All callback arguments can now return T | Promise<T>, to fix annoying eslint errors like: Promise returned in function argument where a void return was expected. (eslint @typescript-eslint/no-misused-promises) * 🤖 Merge PR #63921 [d3-sankey] remove unused import from tests by @simPod --------- Co-authored-by: Henato <57230682+Henato@users.noreply.github.com> Co-authored-by: Renato <renato@innovaro.com.br> Co-authored-by: Tomasz Pluskiewicz <tpluscode@users.noreply.github.com> Co-authored-by: Dimitri B <BendingBender@users.noreply.github.com> Co-authored-by: Guillermo Julián <gjulianm@users.noreply.github.com> Co-authored-by: Piotr Błażejewicz (Peter Blazejewicz) <peterblazejewicz@users.noreply.github.com> Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Co-authored-by: Maxim Mazurok <maxim@mazurok.com> Co-authored-by: Ilia Borovitinov <icehaunter@gmail.com> Co-authored-by: Tom MacWright <tmcw@users.noreply.github.com> Co-authored-by: Doooooring <106396244+Doooooring@users.noreply.github.com> Co-authored-by: Sebastian Silbermann <sebastian.silbermann@klarna.com> Co-authored-by: Marcelo Shima <marceloshima@gmail.com> Co-authored-by: Serge Hänni <phylor@users.noreply.github.com> Co-authored-by: Evan Broder <evan@ebroder.net> Co-authored-by: Risto Keravuori <kerarist@twitch.tv> Co-authored-by: Brendan Hayward <brendanhayward85@gmail.com> Co-authored-by: Santiago Botero Ruiz <39206812+YokySantiago@users.noreply.github.com> Co-authored-by: Simon Podlipsky <simon@podlipsky.net> Co-authored-by: Benn Bollay <bb.github@magitech.org> Co-authored-by: Kyℓe Hensel <k-yle@users.noreply.github.com> Co-authored-by: Pig Fang <g-plane@hotmail.com> Co-authored-by: Jon Dufresne <jon.dufresne@gmail.com> Co-authored-by: Nathan Walters <nwalters512@gmail.com> Co-authored-by: Wang Zhi <yfwz100@yeah.net> Co-authored-by: Philip Su <39933441+fivecar@users.noreply.github.com> Co-authored-by: Stuart Harrison <pezholio@gmail.com> Co-authored-by: S. Jansen <sampie777@users.noreply.github.com> Co-authored-by: S. Jansen <sa.jansen1@gmail.com> Co-authored-by: Luper Rouch <luper.rouch@gmail.com>
Retrying #62209 which was already ready to merge. Accidentally forgot to land. Will just wait for CI and then merge.
This is the proper patern to augment global interfaces that are defined by the runtime (see #60837 (review))
The previous approach would break once
lib.dom.d.ts
declares these interfaces.The previous approach also made it impossible for other libraries to use these types.
For example, #60691 had to be reverted.
With proper module augmentation we can land #60691 again.
Verified that the new approach will allow landing #60691: #61166
Please fill in this template.
npm test <package to test>
.Select one of these and delete the others:
If changing an existing definition:
[ ]If this PR brings the type definitions up to date with a new version of the JS library, update the version number in the header.