Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unknown && false is too loosely typed #53352

Open
Diggsey opened this issue Mar 19, 2023 · 0 comments
Open

unknown && false is too loosely typed #53352

Diggsey opened this issue Mar 19, 2023 · 0 comments
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript

Comments

@Diggsey
Copy link

Diggsey commented Mar 19, 2023

Bug Report

The following code should type-check: https://www.typescriptlang.org/play?#code/FAFwngDgpgBAYgQwDYGcwwLwwHYFclIwA+Mu2AJlAGYCW2U5xMVyKsJeAtgEZQBOTAAzYmAIlFMAEgBUAsgBkAggQDCAewJQAxiBprswYFTI69IqmrUAKAB4AuUtgDW2NQHdsASgeJU6AN7AMMEwfFAguHwiNjAAZLHMrFDAAL7AQA

🔎 Search Terms

unknown falsy false and &&

🕗 Version & Regression Information

Please keep and fill in the line that best applies:

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

⏯ Playground Link

Playground link with relevant code

💻 Code

type Falsy = null | undefined | false | number | 0n | "" | HTMLAllCollection

function foo(x: unknown): Falsy {
    return x && false
}

🙁 Actual behavior

Fails to type-check

🙂 Expected behavior

Should type-check

This would be improved further if:

@RyanCavanaugh RyanCavanaugh added Suggestion An idea for TypeScript Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature labels Mar 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

2 participants