chore: remove any and resolve lint (#28782)

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 has an initiative to remove much of the
`any` usage in favor of stronger types. This will make modifications to
this codebase safer as we will have access to proper type checking.

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

- Added stronger types to the `animationTimeout` variable. Making this
change causes our linter to fail because we are using a number value in
a conditional which we do not allow. To avoid this, I needed to check if
`animationTimeout` was `undefined`. This should not cause any changes
for Ionic developers, but I want to ship this a) in a separate patch and
b) in a minor release to de-risk just in case there's an edge case I am
not considering.

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

<!--
  If this introduces a breaking change:
1. Describe the impact and migration path for existing applications
below.
  2. Update the BREAKING.md file with the breaking change.
3. Add "BREAKING CHANGE: [...]" to the commit description when merging.
See
https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#footer
for more information.
-->


## Other information

<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->
This commit is contained in:
Liam DeBeasi
2024-01-08 10:22:31 -05:00
committed by GitHub
parent 658d1caccd
commit e22c78d682

View File

@ -22,7 +22,7 @@ export const transitionEndAsync = (el: HTMLElement | null, expectedDuration = 0)
*/ */
const transitionEnd = (el: HTMLElement | null, expectedDuration = 0, callback: (ev?: TransitionEvent) => void) => { const transitionEnd = (el: HTMLElement | null, expectedDuration = 0, callback: (ev?: TransitionEvent) => void) => {
let unRegTrans: (() => void) | undefined; let unRegTrans: (() => void) | undefined;
let animationTimeout: any; let animationTimeout: number | undefined;
const opts: any = { passive: true }; const opts: any = { passive: true };
const ANIMATION_FALLBACK_TIMEOUT = 500; const ANIMATION_FALLBACK_TIMEOUT = 500;
@ -45,7 +45,7 @@ const transitionEnd = (el: HTMLElement | null, expectedDuration = 0, callback: (
animationTimeout = setTimeout(onTransitionEnd, expectedDuration + ANIMATION_FALLBACK_TIMEOUT); animationTimeout = setTimeout(onTransitionEnd, expectedDuration + ANIMATION_FALLBACK_TIMEOUT);
unRegTrans = () => { unRegTrans = () => {
if (animationTimeout) { if (animationTimeout !== undefined) {
clearTimeout(animationTimeout); clearTimeout(animationTimeout);
animationTimeout = undefined; animationTimeout = undefined;
} }