Consider the following code, note the documentation of someField
:
interface Test {
/**
* Some description.
* lorum ipsum.
* foo bar.
*/
someField: string;
}
function withGeneric<T extends Test>(arg: T) {
return arg;
}
function withoutGeneric(arg: Test) {
return arg;
}
withGeneric({
someField: ""
});
withoutGeneric({
someField: ""
});
When I hover with my mouse over someField
in the withoutGeneric
call, VSCode nicely shows me the documentation:
However, when hovering over someField
in the withGeneric
call, the documentation is not shown:
Is there a way to make the tsdoc documentation work with the generic argument too?
I found an answer that works for my purpose. Add a union with the extended from type:
Now VSCode does show the documentation:
It feels like a trick, but I fail to see any disadvantages to it?