-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Lint: sketchy-null-string: partially wrong error message? #4608
Comments
@stouf The message is quite descriptive. |
@TrySound Thanks for replying :)
Given that
As written above,
Yep, that's correct, but I don't think this should be a warning. Perhaps I'm missing something here? |
According to the documentation, it seems that this is just the expected behavior since empty strings are evaluated as a falsy values.
At first, I didn't get why Flow would show warnings for possible empty values but it's actually easy to imagine situations where it would be useful. For example, function sayHi(info: { name?: string }) {
if (!info.name) {
throw new Error('Please provide a name');
}
if (info.name.length === 0) {
// This case will always be caught by the if previous statement
throw new Error('Empty name not allowed');
}
return `Hi ${info.name}!`;
} The message about |
The following code
with the following configuration
gives me the following warning with Flow v0.52.0:
Am I missing something? Flow seems to be confusing maybe type and optional property here doesn't it?
The text was updated successfully, but these errors were encountered: