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

Add type guard to string.present #10561

Closed

Conversation

notbakaneko
Copy link
Collaborator

@notbakaneko notbakaneko commented Sep 15, 2023

Implicitly makes the return type of presence string | null which it should be instead of string | null | undefined

@nanaya
Copy link
Collaborator

nanaya commented Sep 15, 2023

wouldn't this make the false condition incorrectly infer the variable as null | undefined when it may still be a string?

similar issue with microsoft/TypeScript#15048

@notbakaneko
Copy link
Collaborator Author

oh right empty string is still there 🤔

@notbakaneko
Copy link
Collaborator Author

Going to close this as the case where we need the type narrowing is rare and can be worked around when needed; adding a workaround here with the options currently available is a bit problematic since '' itself is a subtype of string and typescript will complain about that instead...

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

Successfully merging this pull request may close these issues.

2 participants