Skip to content

Commit 01f46a8

Browse files
committed
fixup!
1 parent 9aac677 commit 01f46a8

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

src/utils/parser/constants.mjs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,20 @@ export const DOC_API_HEADING_TYPES = [
7272
// This is a mapping for types within the Markdown content and their respective
7373
// JavaScript primitive types within the MDN JavaScript docs
7474
// @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Data_structures#primitive_values
75-
export const DOC_TYPES_MAPPING_PRIMITIVES = [
76-
'null',
77-
'undefined',
78-
'boolean',
79-
'number',
80-
'bigint',
81-
'string',
82-
'symbol',
83-
];
75+
export const DOC_TYPES_MAPPING_PRIMITIVES = {
76+
...Object.fromEntries(
77+
[
78+
'null',
79+
'undefined',
80+
'boolean',
81+
'number',
82+
'bigint',
83+
'string',
84+
'symbol',
85+
].map(e => [e, e])
86+
),
87+
integer: 'number',
88+
};
8489

8590
// This is a mapping for types within the Markdown content and their respective
8691
// JavaScript globals types within the MDN JavaScript docs

src/utils/parser/index.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,10 @@ export const transformTypeToReferenceLink = type => {
8181
*/
8282
const transformType = lookupPiece => {
8383
// Transform JS primitive type references into Markdown links (MDN)
84-
if (DOC_TYPES_MAPPING_PRIMITIVES.includes(lookupPiece.toLowerCase())) {
85-
return `${DOC_MDN_BASE_URL_JS_PRIMITIVES}#${lookupPiece.toLowerCase()}_type`;
84+
if (lookupPiece.toLowerCase() in DOC_TYPES_MAPPING_PRIMITIVES) {
85+
const typeValue = DOC_TYPES_MAPPING_PRIMITIVES[lookupPiece.toLowerCase()];
86+
87+
return `${DOC_MDN_BASE_URL_JS_PRIMITIVES}#${typeValue}_type`;
8688
}
8789

8890
// Transforms JS Global type references into Markdown links (MDN)

0 commit comments

Comments
 (0)