Skip to content

Commit ec4177f

Browse files
committed
Add a test for #2916
1 parent 031f7a4 commit ec4177f

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ title: Changelog
2323
- Fixed broken links within module pages when structure-dir router was used, #2928.
2424
- Type parameters on JS classes defined with `@typedef` now correctly handle the constraint, #2929.
2525
- API: `toString` on types containing index signatures now behave correctly, #2917.
26+
- Added `@inlineType` to the list of tags excluded by default.
2627

2728
## v0.28.1 (2025-03-20)
2829

src/lib/converter/types.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ const predicateConverter: TypeConverter<ts.TypePredicateNode, ts.Type> = {
604604

605605
// This is a horrible thing... we're going to want to split this into converters
606606
// for different types at some point.
607-
const typeLiteralConverter: TypeConverter<ts.TypeLiteralNode> = {
607+
const typeLiteralConverter = {
608608
kind: [ts.SyntaxKind.TypeLiteral],
609609
convert(context, node) {
610610
const symbol = context.getSymbolAtLocation(node) ?? node.symbol;
@@ -653,7 +653,6 @@ const typeLiteralConverter: TypeConverter<ts.TypeLiteralNode> = {
653653
return new ReflectionType(reflection);
654654
},
655655
convertType(context, type) {
656-
// Don't use the third parameter here or you break convertTypeInline
657656
const symbol = type.getSymbol();
658657
const reflection = new DeclarationReflection(
659658
"__type",
@@ -693,7 +692,7 @@ const typeLiteralConverter: TypeConverter<ts.TypeLiteralNode> = {
693692

694693
return new ReflectionType(reflection);
695694
},
696-
};
695+
} satisfies TypeConverter<ts.TypeLiteralNode>;
697696

698697
const queryConverter: TypeConverter<ts.TypeQueryNode> = {
699698
kind: [ts.SyntaxKind.TypeQuery],
@@ -1267,11 +1266,8 @@ function convertTypeInlined(context: Context, type: ts.Type): SomeType {
12671266
return new ArrayType(elementType);
12681267
}
12691268

1270-
// typeLiteralConverter doesn't use the node, so we can get away with lying here.
12711269
return typeLiteralConverter.convertType(
12721270
context,
12731271
type,
1274-
null!,
1275-
undefined,
12761272
);
12771273
}

src/lib/utils/options/defaults.ts

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export const excludeTags: readonly `@${string}`[] = [
3838
"@satisfies",
3939
"@overload",
4040
"@inline",
41+
"@inlineType",
4142
];
4243

4344
export const blockTags: readonly `@${string}`[] = TagDefaults.blockTags;

src/test/converter2/issues/gh2916.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* @typedef {object} HelloProps
3+
* @property {string} name Name property docs
4+
*/
5+
6+
/**
7+
* @inlineType HelloProps
8+
* @param {HelloProps} props
9+
*/
10+
export function hello(props) {
11+
return "Hello {props.name}!";
12+
}

src/test/issues.c2.test.ts

+6
Original file line numberDiff line numberDiff line change
@@ -2080,6 +2080,12 @@ describe("Issue Tests", () => {
20802080
equal(Bug4.signatures[0].type?.toString(), "U");
20812081
});
20822082

2083+
it("#2916 handles @inlineType on @typedef declared types", () => {
2084+
const project = convert();
2085+
const hello = querySig(project, "hello");
2086+
equal(hello.parameters?.[0].type?.toString(), "{ name: string }");
2087+
});
2088+
20832089
it("#2917 stringifies index signatures", () => {
20842090
const project = convert();
20852091
const data = query(project, "Foo.data");

0 commit comments

Comments
 (0)