UIRouterGlobals.transition type is incorrectly non-nullable
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 365
- Forks
- 139
- PR merge metrics
- No merged PRs in 30d
Description
UIRouterGlobals.transition type is incorrectly non-nullable
Summary
The UIRouterGlobals.transition property is typed as non-nullable (Transition), but at runtime it is null or undefined when there is no active transition (e.g., after a state has fully loaded or on initial page load).
Version
@uirouter/core: 6.1.1
Current Type Definition
export class UIRouterGlobals {
transition: Transition;
// ... other properties
}
Expected Type Definition
export class UIRouterGlobals {
transition: Transition | null | undefined;
// ... other properties
}
Reproduction
Code Example
import { UIRouterGlobals } from '@uirouter/core';
// In an Angular component during ngOnInit, after the state has loaded:
constructor(private uiRouterGlobals: UIRouterGlobals) {}
ngOnInit(): void {
// This throws: "can't access property 'to', this.uiRouterGlobals.transition is null"
const stateName = this.uiRouterGlobals.transition.to().name;
}
Root Cause
When no transition is currently active (which is the normal state after a route has finished loading), uiRouterGlobals.transition is null or undefined. The TypeScript type definition incorrectly claims this property is always present, leading to runtime errors when developers follow the types.
Expected Behavior
The type definition should accurately reflect runtime behavior, allowing TypeScript to catch potential null reference errors at compile time.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the UIRouterGlobals declaration in @uirouter/core and compare the declared transition type with the runtime behavior described in the reproduction. Update the type so it permits the absent-transition cases, then verify that the TypeScript checks cover the nullable usage described by the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100