Skip to content

window.opener should not be typed as any #49415

Description

lib Update Request

Configuration Check

My compilation target is esnext and my lib is ["ESNext", "dom"].

Missing / Incorrect Definition

window.opener should not be typed as any. I might be missing something obvious, but this has already been reported and supposedly fixed at #42433 more than a year ago, but it still seems to be typed as any, both on my local version of Typescript (version 4.7.3) and at https://github.com/microsoft/TypeScript/blob/main/lib/lib.dom.d.ts#L17209

Activity

  1. RyanCavanaugh commented on Sep 9, 2026

    @RyanCavanaugh
    Member

    window.opener is still declared as any in both TypeScript 4.7.3 and the current native compiler. The browser API may return null (and otherwise exposes the opener window proxy), so any loses the nullability and prevents useful checking.

    type IsAny<T> = 0 extends 1 & T ? true : false;
    type Assert<T extends true> = T;
    
    // Expected: The DOM declaration gives window.opener a specific non-any type.
    // Actual: typeof window.opener is any.
    type OpenerIsAny = Assert<IsAny<typeof window.opener>>;

    The assertion currently succeeds; it should fail after window.opener receives a specific DOM type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptHelp WantedYou can do this

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions