Skip to content

Commit

Permalink
Fix conversion of NoInfer
Browse files Browse the repository at this point in the history
Resolves #2539
  • Loading branch information
Gerrit0 committed Apr 6, 2024
1 parent 3398e98 commit b76d804
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions src/lib/converter/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ const queryConverter: TypeConverter<ts.TypeQueryNode> = {

const referenceConverter: TypeConverter<
ts.TypeReferenceNode,
ts.TypeReference | ts.StringMappingType
ts.TypeReference | ts.StringMappingType | ts.SubstitutionType
> = {
kind: [ts.SyntaxKind.TypeReference],
convert(context, node) {
Expand Down Expand Up @@ -747,7 +747,12 @@ const referenceConverter: TypeConverter<
context.resolveAliasedSymbol(symbol),
context,
);
if (type.flags & ts.TypeFlags.StringMapping) {
if (type.flags & ts.TypeFlags.Substitution) {
// NoInfer<T>
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),
];
Expand Down
2 changes: 1 addition & 1 deletion src/test/behavior.c2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<C>");
});
});

0 comments on commit b76d804

Please sign in to comment.