vue
vue copied to clipboard
fix(scheduler): add missing type annotation to callActivatedHooks
Summary of Changes
Added Component[] type annotation to the queue parameter in the callActivatedHooks function within src/core/observer/scheduler.ts.
Type of Change
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Refactor (code change that neither fixes a bug nor adds a feature)
The Problem
The callActivatedHooks function lacked a type annotation for its queue parameter, unlike other similar functions in the scheduler (e.g., callUpdatedHooks). This inconsistency reduced type safety and code clarity, potentially allowing incorrect types to be passed during development.
The Solution
Explicitly typed the queue parameter as Component[]. This aligns with the activatedChildren array type (which is passed to this function) and matches the pattern used in other scheduler hook functions, improving overall code consistency and type safety.
Testing
- [x] Ran
npm run ts-checkto verify no type errors were introduced. - [x] Ran
npm test -- test/unit/modules/observer/scheduler.spec.tsto ensure scheduler logic remains intact. - [x] Verified that
activatedChildrenis defined asArray<Component>, confirmingComponent[]is the correct type.