A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
chore: add stronger types to several files (#28347)
Issue number: Internal --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> As part of FW-2832, the team would like to swap out usages of the any type for stronger types. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> https://github.com/ionic-team/ionic-framework/pull/28347/commits/c529bc23f1853d679fc8fe1f8128084bb1182414 - `scrollToTop` doesn't return anything, so I added the `void` return type https://github.com/ionic-team/ionic-framework/pull/28347/commits/a96971ad28af7fa4c92ce2697a491d0b16e784a7 - `animation.effect` is a type of [AnimationEffect](https://developer.mozilla.org/en-US/docs/Web/API/Animation/effect). One of the more common types of effects is a `KeyframeEffect`. However, TypeScript doesn't know which specific type of AnimationEffect we are using, so I cast `animation.effect` as KeyframeEffect where appropriate. - I also added `!` to places where we know the effect and other properties are always defined (since they run after the web animation has been constructed) - Added stronger types to the internal to/from/fromTo functions (the public facing type improvements are in https://github.com/ionic-team/ionic-framework/pull/28334) https://github.com/ionic-team/ionic-framework/pull/28347/commits/fdaf550059cfd1ed9f84b70594ea626cf9300c06 - `getRootNode` can return multiple types of objects, so I cast it to the specific types that we work with in `isFocused`. https://github.com/ionic-team/ionic-framework/pull/28347/commits/46a6efa510c2bf91f3bb5930f4297f1eb7dbac49 - Added the "Animation" type and resolved related errors once we had stronger types https://github.com/ionic-team/ionic-framework/pull/28347/commits/a7cb9a56858e4195e2a557e6b648872920a476fa - Made heavier use of the `T` generic - Once we know `node` is an Element (`nodeType === 1`) we manually cast the element as `T` https://github.com/ionic-team/ionic-framework/pull/28347/commits/6a9d1f095d015d59dc9f4dc7355894b5601f8411 - The focus visible utility is an internal utility, but it was lacking an interface, so I added one. https://github.com/ionic-team/ionic-framework/pull/28347/commits/90b64c2de535d7a22175c698c2cb7fd850d84c82 - Removed unneeded HTMLElement casting - Added `!` since we can assume the selected elements are defined with the refresher - Added documentation as to why casting `referencEl.style` as `any` is something we need to keep. https://github.com/ionic-team/ionic-framework/pull/28347/commits/3a084caf8379df8ee2c334e51d92dd391e13473a - Avoided the Event naming collision by using globalThis ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change, please describe the impact and migration path for existing applications below. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> Note: This PR contains only type changes. Changes the required updates to the implementation of Ionic are pulled out into separate PRs and target a minor release branch to minimize risk. --------- Co-authored-by: Amanda Johnston <90629384+amandaejohnston@users.noreply.github.com>
L
Liam DeBeasi committed
15a02253d35fcd44cb875f678d3e3b8fc8331593
Parent: 331c08a
Committed by GitHub <noreply@github.com>
on 10/23/2023, 4:46:42 PM