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

Fix: lookup JSDoc typings #107

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fix: lookup JSDoc typings #107

wants to merge 1 commit into from

Conversation

binury
Copy link

@binury binury commented May 12, 2023

This is a quick fix to two functions which, since their detection failure returns false, have their return values annotated as {boolean|string}. In reality, the boolean returned is always false, and so it makes more sense to use a JSDoc type expression of false.

Sure. But why does this really matter?

With the return type as boolean i.e. {true|false}
a usage with a short circuit assignment to a {string} var will cause a false positive type warning:

const headers = {
  
  contentType: mime.lookup(path.extname(filePath)) || 'text/plain;charset=UTF-8',
}

as the language server infers from the {boolean|string} type annotation(s) that lookup will in some scenarios return true, which would make contentType no longer a {string}.

@binury binury changed the title Fix: JSDocs typings Fix: JSDoc typings May 12, 2023
@binury
Copy link
Author

binury commented Jan 7, 2024

any changes needed here to merge?

@binury binury changed the title Fix: JSDoc typings Fix: lookup JSDoc typings Feb 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant