You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This indicates that the type of handlePath is determined by PathHandler. The types for params path and lineNumber are resolved accordingly.
When converting this code to typescript, there is no way to associate the function declaration with the new type/interface. One workaround is just to repeat all of the type information from PathHandler at every function that conforms to the type. Another workaround is to use a function expression, like const handlePath: PathHandler = function(....), but this loses hoisting and unnecessarily imposes one style over another.
There should be a way to type the entire function declaration similar to the jsdoc equivalent, e.g.:
When using jsdoc, you can do something like:
This indicates that the type of
handlePath
is determined byPathHandler
. The types for paramspath
andlineNumber
are resolved accordingly.When converting this code to typescript, there is no way to associate the function declaration with the new type/interface. One workaround is just to repeat all of the type information from
PathHandler
at every function that conforms to the type. Another workaround is to use a function expression, likeconst handlePath: PathHandler = function(....)
, but this loses hoisting and unnecessarily imposes one style over another.There should be a way to type the entire function declaration similar to the jsdoc equivalent, e.g.:
The text was updated successfully, but these errors were encountered: