Skip to content

Wrong error message for testing void with ?? #57172

Open

Description

🔎 Search Terms

nullish An expression of type 'void' cannot be tested for truthiness.

(there are many closed issues with these search term, but they are all from people confused by why this is an error in the first place)

🕗 Version & Regression Information

  • This is the behavior in every version I tried

⏯ Playground Link

https://www.typescriptlang.org/play?ts=5.3.3#code/CYUwxgNghgTiAEA3W8oC4kHsCWwDcAUAVPAPynwBmUEAziHkA

💻 Code

declare var a: void;

a ?? false;

🙁 Actual behavior

It reports "An expression of type 'void' cannot be tested for truthiness."

🙂 Expected behavior

The error message should not mention truthiness, since I'm not testing for truthiness. nullishness? :P

Additional information about the issue

No response

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions