Skip to content

Commit c31c83f

Browse files
committed
fixed type errors
1 parent c204205 commit c31c83f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/index.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,9 @@ function transform(state, node) {
290290

291291
case 'mdxJsxFlowElement': {
292292
// Map the attributes array into name/value pairs
293+
/** @type {Record<string, unknown>} */
293294
const attributesMap = {}
295+
294296
if (Array.isArray(unsafe.attributes)) {
295297
unsafe.attributes.forEach((attr) => {
296298
if (
@@ -317,7 +319,7 @@ function transform(state, node) {
317319
}
318320

319321
case 'mdxJsxTextElement': {
320-
// Handle text elements the same way
322+
/** @type {Record<string, unknown>} */
321323
const attributesMap = {}
322324
if (Array.isArray(unsafe.attributes)) {
323325
unsafe.attributes.forEach((attr) => {
@@ -563,7 +565,11 @@ function properties(state, properties) {
563565
// Handle both traditional properties and MDX attributes
564566
const properties_ =
565567
properties && typeof properties === 'object' ? properties : {}
566-
const mdxAttributes = properties_?.attributes || {} // Add support for MDX attributes
568+
/** @type {Array<{ type: 'mdxJsxAttribute' } & Record<string, unknown>>} */
569+
const mdxAttributes =
570+
/** @type {{ attributes?: Array<{ type: 'mdxJsxAttribute' } & Record<string, unknown>> }} */ (
571+
properties_
572+
)?.attributes || []
567573

568574
/** @type {Properties} */
569575
const result = {}
@@ -573,6 +579,7 @@ function properties(state, properties) {
573579
// Process traditional properties
574580
for (key in properties_) {
575581
if (own.call(properties_, key)) {
582+
// @ts-ignore
576583
const unsafe = properties_[key]
577584
let safe = propertyValue(
578585
state,

0 commit comments

Comments
 (0)