WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

UIRouterGlobals.transition type is incorrectly non-nullable #1013

@eoghanb6

Description

@eoghanb6

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions