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
{{ message }}
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
Repository navigation
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
The JSDoc types do not include an example of importing a type with a generic.
e.g. this is the correct way:
/**
* @template T
* @typedef {import("../types").ThunkAction<T>} ThunkAction<T>
*
I won't enumerate the wrong ways I tried :D
It took me a good hour to figure it out, with lots of searching. I could not find any examples anywhere in the docs, nor in Stack Overflow. I figured someone else could benefit from my confusion.
Activity
andrewrlee commentedon Oct 19, 2019
Thank-you, this helped me loads after a lot of searching.
I'm new to JSDoc and using vscode. Another gotcha for me was that this restricts
typeDefother types in the same jsdoc as a template variable:The following makes Bob generic too:
The following makes Bob generic and also adds a
Cannot find name 'T'error:It also seems like the second param on the type def is optional, as the following also works for me:
I assume these aren't defects, but I found this quite confusing and additional documentation might help?
gregtatum commentedon Oct 24, 2019
Thanks for clarifying some of those points Andrew Lee (@andrewrlee), I ran into some of those issues as well.
codingedgar commentedon Dec 13, 2019
Greg Tatum (@gregtatum) wow thank you so much!! 👏👏 👏
tjx666 commentedon Feb 13, 2020
I want to know how to keep the generic when useing typedef to import:

sultan99 commentedon Jun 6, 2020
YuTengjing (@tjx666)