No type hints for JSDoc @type annotation?

Please check the following code:

 

Typing `f` show use the following intellisense for the above functions:

 

`f1` function looks ok, there is no type information, parameter names are displayed

`f2` function has all the type info someone might need

`f3` function uses `@type` + clojure function syntax, here only the return type is displayed, the parameter types are missing

`f4` function uses `@type` + typescript function syntax, types are completely missing

`f5`function uses different signature for the func via `@param` but this is ignored in intellisense (this could be ok)

`f6` function uses different signature for the func via `@type` and this is ignored in intellisense too unfortunately

 

Is there a way to configure WebStorm to rely on `@type` annotations instead of the actual function signature? Or is there an other way to override the actual function signature with other JSDoc feature? 

The reason I am asking this because we would like to create a nice intellisense experience in our workflow where mostly WebStorm and Visual Studio Code are used. Visual Studio Code handles `@type` very well, it allows us to define/redefine the actual function signature. 

Would be nice to have the same experience in WebStorm as well somehow. If it is possible to configure this please let me know.

 

3 comments

>`f3` function uses `@type` + clojure function syntax, here only the return type is displayed, the parameter types are missing

Logged as https://youtrack.jetbrains.com/issue/WEB-36466, please follow it for updates

 

>`f4` function uses `@type` + typescript function syntax, types are completely missing

 

Using TypeScript syntax in JSDoc is not currently supported, please vote for https://youtrack.jetbrains.com/issue/WEB-35266

 

>`f5`function uses different signature for the func via `@param` but this is ignored in intellisense (this could be ok)

 

This is expected - it's not a valid JSDoc, Closure compiler will throw errors like "JSC_INEXISTENT_PARAM: parameter a does not appear in f5's parameter list "  when using this syntax

0

@Elena thank you for the fast response. Glad to hear there is an initiative for typescript syntax.

 

What do you think about `f6` form? Is it possible (or will it be) with either the clojure or typescript syntax to override the type (number of parameters and their types + return value) of the function which is inferred by WebStorm? This would be useful in some cases to let the developer decide the signature of a function.This can be already done via using `*.d.ts` files for example so would be nice to do the same via JSDoc as well.

 

 

 

0

To make 'f6' work, both WEB-36466 and WEB-35266 have to be fixed... Using closure function @type with `...args` is a valid use case, so it should be implemented one day

0

Please sign in to leave a comment.