Chore(deps): Update TypeScript to version 6.0.2 and adjust related types#1287
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the frontend toolchain to a newer TypeScript version and adjusts a few DOM/Node typing mismatches that become more visible with stricter/updated TypeScript typings.
Changes:
- Bump
typescriptdependency from^5.9.3to^6.0.2. - Replace
NodeJS.Timeouttimer handle annotations withReturnType<typeof setTimeout/setInterval>in hooks/components. - Update test mocking to use
globalThis.IntersectionObserverinstead ofglobal.IntersectionObserver.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/hooks/useWindowSize.ts | Updates timeout handle typing to be environment-agnostic. |
| src/hooks/useStickyObserver.test.ts | Uses globalThis for IntersectionObserver mocking. |
| src/features/hardware/insights/Insights.tsx | Updates interval handle typing to be environment-agnostic. |
| package.json | Attempts to bump TypeScript to ^6.0.2. |
| package-lock.json | Locks TypeScript to 6.0.2 and includes lockfile metadata updates. |
Comments suppressed due to low confidence (2)
src/hooks/useWindowSize.ts:33
timeoutIdis declared without an initializer, but it's cleared in bothhandleResizeand the effect cleanup. At runtime this meansclearTimeoutmay receiveundefined, while the variable is typed as a non-optionalReturnType<typeof setTimeout>. Initialize it toundefined/nulland guard before clearing (or give it an initialsetTimeoutvalue) so the runtime value matches the declared type.
let timeoutId: ReturnType<typeof setTimeout>;
const handleResize = () => {
clearTimeout(timeoutId);
timeoutId = setTimeout(() => {
src/features/hardware/insights/Insights.tsx:329
- The interval is only cleared on mouse/touch end. If the component unmounts (route change/tab switch) while the interval is running, it will keep firing and call
setOffseton an unmounted component. Add an effect cleanup to clear any active interval on unmount (or store the interval handle in a ref and always clear it in cleanup).
const [intervalId, setIntervalId] = useState<ReturnType<
typeof setInterval
> | null>(null);
const { t } = useTranslation();
const handleMouseDown = (increment: number) => {
if (intervalId) return;
const id = setInterval(() => {
setOffset((prev) => Math.max(0, prev + increment));
}, 100);
setIntervalId(id);
};
const handleMouseUp = () => {
if (intervalId) {
clearInterval(intervalId);
setIntervalId(null);
}
};
Contributor
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Related Issues
Type of Change
fix/branch)feat/branch)refactor/branch)docs/branch)chore/branch)Screenshots / Videos
Test Plan
Checklist
npm run lint && npm run format/cargo tauri-lint && cargo tauri-fmt)npm test/cargo tauri-test)