Function parameters are not inferable when defined via JSDoc using @type tag (with strict) #58580
Labels
Help Wanted
You can do this
Possible Improvement
The current behavior isn't wrong, but it's possible to see that it might be better in some cases
Milestone
🔎 Search Terms
infer
@type
strict
JSDoc
Parameters
Function
🕗 Version & Regression Information
I've pulled the latest version of this repository and made a test case in the "fourslash" section, which demonstrates the problem I see.
(I couldn't see how to do something like this in the playground, sorry. Commit is linked)
⏯ Playground Link
scottmcginness@cda5366
💻 Code
In tsconfig.json:
(The above definition is obviously just
Parameters<T>
, but put in full for comparison with another example below)🙁 Actual behavior
The type
FuncParam
resolved tonever
(i.e. it took the false branch of the ternary)🙂 Expected behavior
The type
FuncParam
should be[param: string]
, as given by the JSDoc@type
tagAdditional information about the issue
This seems like a bug because all other ways of specifying the
func
function with JSDoc or theFuncParam
type seemed to work as expected:@param
tag instead:yields
FuncParam
→[param: string]
undefined
works, but is not what I want for the definition offunc
:yields
FuncParam
→[param?: string | undefined]
infer
works (but is not usable for the intended purpose):Parameters<T>
works):This also only seemed to occur specifically with
strict: true
. I couldn't see this with any of the otherstrict...
options (though I may have missed something here)All other views on the function seems to show that it is happily a function with a string parameter. i.e. the tooltip hover over
func
, while insideuse-it.ts
shows:The output I see from the single test linked above (using
hereby runtests --tests=jsDocInferredFunctionParameters
) is:This also happens for arrow functions and class methods, e.g.
with similar code as for
FuncParam
.The text was updated successfully, but these errors were encountered: