Repository navigation
Build/Test Tools: Add accordion.js to TypeScript checking. - #14041
rahultank-spaceo wants to merge 1 commit into
Conversation
Corrects the JSDoc type of the accordionSwitch() parameter from Object to JQuery, which resolves the type errors reported once the file is checked. See #65997.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
PR #14041 landed in https://core.trac.wordpress.org/changeset/64297 |
Include `accordion.js` in `tsconfig.json` and document the `accordionSwitch()` parameter as `JQuery` to match its callers and use of jQuery methods. This adds static checking without changing runtime behavior. Developed in: #14041 Props rahultank. See #65997. git-svn-id: https://develop.svn.wordpress.org/trunk@64297 602fd350-edb4-49c9-b593-d223f7449a82
Include `accordion.js` in `tsconfig.json` and document the `accordionSwitch()` parameter as `JQuery` to match its callers and use of jQuery methods. This adds static checking without changing runtime behavior. Developed in: WordPress/wordpress-develop#14041 Props rahultank. See #65997. Built from https://develop.svn.wordpress.org/trunk@64297 git-svn-id: http://core.svn.wordpress.org/trunk@63447 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Adds
src/js/_enqueues/lib/accordion.jsto the files checked bytsc(npm run typecheck:js).With the file included,
tscreported 3 errors, all from one cause: theelparameter ofaccordionSwitch()was documented as{Object}, soel.closest()andel.attr()were reported as missing (TS2339).elis always a jQuery object (accordionSwitch( $( this ) )), so the JSDoc type is changed to{JQuery}. This matches the existing use of jQuery types in core JSDoc, such as{JQueryStatic}incolor-picker.jsandnav-menu.js.Only a JSDoc comment changes in the script, so there is no runtime change.
Testing instructions
npm run typecheck:js. It completes with no errors.accordion.jsand run it again.tscreports the 3 TS2339 errors on lines 58 and 91.Trac ticket: https://core.trac.wordpress.org/ticket/65997
Use of AI Tools
AI assistance: Yes
Used for: Initial draft of the change and this description; the change and the verification runs were reviewed and confirmed by me in a local environment.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.