Skip to content

Commit 683e9fe

Browse files
committed
Handle JSDoc wildcard types
Resolves #2949
1 parent 964b128 commit 683e9fe

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ title: Changelog
1515
The `chevronSmall` helper is now deprecated and will be removed with v0.29.0.
1616
- Classes/interfaces marked with `@hidden` will no longer appear in the
1717
"Hierarchy" section of the docs.
18+
- TypeDoc now handles wildcard JSDoc types, #2949.
1819

1920
### Thanks!
2021

src/lib/converter/types.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export function loadConverters() {
9393
// Only used if skipLibCheck: true
9494
jsDocNullableTypeConverter,
9595
jsDocNonNullableTypeConverter,
96+
jsDocAllTypeConverter,
9697
]
9798
) {
9899
for (const key of actor.kind) {
@@ -1154,6 +1155,15 @@ const jsDocNonNullableTypeConverter: TypeConverter<ts.JSDocNonNullableType> = {
11541155
convertType: requestBugReport,
11551156
};
11561157

1158+
const jsDocAllTypeConverter: TypeConverter<ts.JSDocAllType> = {
1159+
kind: [ts.SyntaxKind.JSDocAllType],
1160+
convert() {
1161+
return new IntrinsicType("any");
1162+
},
1163+
// Should be a UnionType
1164+
convertType: requestBugReport,
1165+
};
1166+
11571167
function requestBugReport(context: Context, nodeOrType: ts.Node | ts.Type) {
11581168
if ("kind" in nodeOrType) {
11591169
const kindName = ts.SyntaxKind[nodeOrType.kind];

src/test/converter2/issues/gh2949.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/**
2+
* @callback Test
3+
* @returns {Promise<*>}
4+
*/
5+
export {};

src/test/issues.c2.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2128,4 +2128,9 @@ describe("Issue Tests", () => {
21282128
const project = convert();
21292129
equal(project.children?.map(c => c.name), ["notExcluded"]);
21302130
});
2131+
2132+
it("#2949 handles JSDoc wildcard types", () => {
2133+
const project = convert();
2134+
equal(query(project, "Test").type?.toString(), "() => Promise<any>");
2135+
});
21312136
});

0 commit comments

Comments
 (0)