From b76d80475f2db046e9b03fdca89a7ef9804dcccc Mon Sep 17 00:00:00 2001 From: Gerrit Birkeland Date: Sat, 6 Apr 2024 17:02:19 -0600 Subject: [PATCH] Fix conversion of NoInfer Resolves #2539 --- CHANGELOG.md | 4 ++++ src/lib/converter/types.ts | 9 +++++++-- src/test/behavior.c2.test.ts | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bc636028..d3c9c2b8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ - Added `gitRevision:short` placeholder option to `--sourceLinkTemplate` option, #2529. Links generated by TypeDoc will now default to using the non-short git revision. +### Bug Fixes + +- Fixed conversion of `NoInfer` missing type parameter reference, #2539. + ### Thanks! - @xuhdev diff --git a/src/lib/converter/types.ts b/src/lib/converter/types.ts index e7d0c284e..01b88154f 100644 --- a/src/lib/converter/types.ts +++ b/src/lib/converter/types.ts @@ -697,7 +697,7 @@ const queryConverter: TypeConverter = { const referenceConverter: TypeConverter< ts.TypeReferenceNode, - ts.TypeReference | ts.StringMappingType + ts.TypeReference | ts.StringMappingType | ts.SubstitutionType > = { kind: [ts.SyntaxKind.TypeReference], convert(context, node) { @@ -747,7 +747,12 @@ const referenceConverter: TypeConverter< context.resolveAliasedSymbol(symbol), context, ); - if (type.flags & ts.TypeFlags.StringMapping) { + if (type.flags & ts.TypeFlags.Substitution) { + // NoInfer + ref.typeArguments = [ + convertType(context, (type as ts.SubstitutionType).baseType), + ]; + } else if (type.flags & ts.TypeFlags.StringMapping) { ref.typeArguments = [ convertType(context, (type as ts.StringMappingType).type), ]; diff --git a/src/test/behavior.c2.test.ts b/src/test/behavior.c2.test.ts index 44085dc8d..ff1f5c970 100644 --- a/src/test/behavior.c2.test.ts +++ b/src/test/behavior.c2.test.ts @@ -1177,6 +1177,6 @@ describe("Behavior Tests", () => { const sig = querySig(project, "createStreetLight"); equal(sig.parameters?.length, 2); equal(sig.parameters[0].type?.toString(), "C[]"); - equal(sig.parameters[1].type?.toString(), "NoInfer"); + equal(sig.parameters[1].type?.toString(), "NoInfer"); }); });