Skip to content

Commit 8f47c24

Browse files
committed
Fix rendering of "Type Declaration" header
Ref: #3002
1 parent 06a4239 commit 8f47c24

File tree

11 files changed

+40
-33
lines changed

11 files changed

+40
-33
lines changed

.npmrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ audit = false
66

77
# While we're on the TS beta, need this flag.
88
legacy-peer-deps = true
9+
10+
# This breaks some of the scripts in the scripts directory
11+
update-notifier = false

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ title: Changelog
1515
- Optional methods are now rendered with a trailing `?` in the reflection preview and signature, #2995.
1616
- The `compilerOptions` option now functions properly with non-boolean options, #3000.
1717
- Configuration errors within the `compilerOptions` option are now handled gracefully, #3000.
18+
- Fixed improper casing of "Type Declaration" header, #3002.
1819

1920
## v0.28.10 (2025-08-10)
2021

site/tags/primaryExport.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
title: "@primaryModifier"
2+
title: "@primaryExport"
33
---
44

5-
# @primaryModifier
5+
# @primaryExport
66

77
**Tag Kind:** [Modifier](../tags.md#modifier-tags)
88

src/lib/internationalization/locales/en.cts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ export = {
506506
// Page headings/labels
507507
theme_implements: "Implements",
508508
theme_indexable: "Indexable",
509-
theme_type_declaration: "Type declaration",
509+
theme_type_declaration: "Type Declaration",
510510
theme_index: "Index",
511511
theme_hierarchy: "Hierarchy",
512512
theme_hierarchy_summary: "Hierarchy Summary",

src/lib/output/themes/default/partials/member.declaration.tsx

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,44 @@
1-
import type { DeclarationReflection } from "../../../../models/index.js";
1+
import type { DeclarationReflection } from "#models";
22
import { JSX } from "#utils";
33
import { FormattedCodeBuilder, FormattedCodeGenerator, type FormatterNode, Wrap } from "../../../formatter.js";
44
import { hasTypeParameters } from "../../lib.js";
55
import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext.js";
66

7+
function shouldRenderDefaultValue(props: DeclarationReflection) {
8+
const defaultValue = props.defaultValue;
9+
10+
if (defaultValue === undefined) {
11+
return false;
12+
}
13+
14+
/** Fix for #2717. If type is the same as value the default value is omitted */
15+
if (props.type && props.type.type === "literal") {
16+
const reflectionTypeString = props.type.toString();
17+
18+
if (reflectionTypeString === defaultValue.toString()) {
19+
return false;
20+
}
21+
}
22+
23+
return true;
24+
}
25+
726
export function memberDeclaration(context: DefaultThemeRenderContext, props: DeclarationReflection) {
827
const builder = new FormattedCodeBuilder(context.router, context.model);
928
const content: FormatterNode[] = [];
1029
builder.member(content, props, { topLevelLinks: false });
1130
const generator = new FormattedCodeGenerator(context.options.getValue("typePrintWidth"));
1231
generator.node({ type: "nodes", content }, Wrap.Detect);
1332

14-
/** Fix for #2717. If type is the same as value the default value is omitted */
15-
function shouldRenderDefaultValue() {
16-
if (props.type && props.type.type === "literal") {
17-
const reflectionTypeString = props.type.toString();
18-
19-
const defaultValue = props.defaultValue;
20-
21-
if (defaultValue === undefined || reflectionTypeString === defaultValue.toString()) {
22-
return false;
23-
}
24-
}
25-
return true;
26-
}
27-
2833
return (
2934
<>
3035
<div class="tsd-signature">
3136
{generator.toElement()}
32-
{!!props.defaultValue && shouldRenderDefaultValue() && (
33-
<>
34-
<span class="tsd-signature-symbol">
35-
{" = "}
36-
{props.defaultValue}
37-
</span>
38-
</>
37+
{shouldRenderDefaultValue(props) && (
38+
<span class="tsd-signature-symbol">
39+
{" = "}
40+
{props.defaultValue}
41+
</span>
3942
)}
4043
</div>
4144

src/test/renderer/specs/types/ExpandType.AExpanded.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@
271271
{
272272
"div.tsd-type-declaration": [
273273
{
274-
"h4": "Type declaration"
274+
"h4": "Type Declaration"
275275
},
276276
{
277277
"ul.tsd-parameters": {

src/test/renderer/specs/types/ExpandType.BExpanded.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@
318318
{
319319
"div.tsd-type-declaration": [
320320
{
321-
"h4": "Type declaration"
321+
"h4": "Type Declaration"
322322
},
323323
{
324324
"ul.tsd-parameters": {

src/test/renderer/specs/types/ExpandType.NestedBehavior1.AExpanded.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@
332332
{
333333
"div.tsd-type-declaration": [
334334
{
335-
"h4": "Type declaration"
335+
"h4": "Type Declaration"
336336
},
337337
{
338338
"ul.tsd-parameters": {

src/test/renderer/specs/types/ExpandType.NestedBehavior1.AllExpanded.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@
275275
{
276276
"div.tsd-type-declaration": [
277277
{
278-
"h4": "Type declaration"
278+
"h4": "Type Declaration"
279279
},
280280
{
281281
"ul.tsd-parameters": {
@@ -359,7 +359,7 @@
359359
{
360360
"div.tsd-type-declaration": [
361361
{
362-
"h4": "Type declaration"
362+
"h4": "Type Declaration"
363363
},
364364
{
365365
"ul.tsd-parameters": {
@@ -443,7 +443,7 @@
443443
{
444444
"div.tsd-type-declaration": [
445445
{
446-
"h4": "Type declaration"
446+
"h4": "Type Declaration"
447447
},
448448
{
449449
"ul.tsd-parameters": {

src/test/renderer/specs/types/Nested.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@
365365
{
366366
"div.tsd-type-declaration": [
367367
{
368-
"h4": "Type declaration"
368+
"h4": "Type Declaration"
369369
},
370370
{
371371
"ul.tsd-parameters": [

0 commit comments

Comments
 (0)