Skip to content

Commit 25be256

Browse files
committed
Add docs for formatValues
Prompted by a suggestion from GitHub Copilot's PR review.
1 parent 2dfd553 commit 25be256

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

dotcom-rendering/src/devServer/docs/article.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,17 @@ const Examples = () => (
9595
</>
9696
);
9797

98+
/**
99+
* Joins all the `string` values of an enum into a single, comma-separated
100+
* `string`.
101+
*
102+
* `ArticleDesign`, `ArticleDisplay` and the two variants of `ArticleTheme` are
103+
* TypeScript enums. Their values contain both the `string` and `number`
104+
* representations of the enum, but here we just want the `string`s, so we
105+
* filter out the `number`s.
106+
*
107+
* https://www.typescriptlang.org/docs/handbook/enums.html#reverse-mappings
108+
*/
98109
const formatValues = (a: object): string =>
99110
Object.values(a)
100111
.filter((v) => typeof v !== 'number')

0 commit comments

Comments
 (0)