Skip to content

NaN && 1 gets incorrectly typed as 0 | 1 #61988

Open
@antonilol

Description

@antonilol

🔎 Search Terms

"NaN"

🕗 Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________

i got the same output for every version in the typescript playground, except 3.3.3 where as const is not supported. without as const this gets typed as just number

⏯ Playground Link

https://www.typescriptlang.org/play/?ts=5.9.0-dev.20250702#code/MYewdgzgLgBGCGYYF4YDl5pgMmzAjDPBDKJFANxA

💻 Code

const nan = NaN && 1 as const;

🙁 Actual behavior

It gets typed as 0 | 1. (See .d.ts output in playground)

🙂 Expected behavior

It should get number or a more specific type.

Additional information about the issue

NaN is falsy in javascript, !!NaN === false

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