Skip to content

Commit

Permalink
fixed type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
cobbvanth committed Jan 4, 2025
1 parent c204205 commit c31c83f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,9 @@ function transform(state, node) {

case 'mdxJsxFlowElement': {
// Map the attributes array into name/value pairs
/** @type {Record<string, unknown>} */
const attributesMap = {}

if (Array.isArray(unsafe.attributes)) {
unsafe.attributes.forEach((attr) => {
if (
Expand All @@ -317,7 +319,7 @@ function transform(state, node) {
}

case 'mdxJsxTextElement': {
// Handle text elements the same way
/** @type {Record<string, unknown>} */
const attributesMap = {}
if (Array.isArray(unsafe.attributes)) {
unsafe.attributes.forEach((attr) => {
Expand Down Expand Up @@ -563,7 +565,11 @@ function properties(state, properties) {
// Handle both traditional properties and MDX attributes
const properties_ =
properties && typeof properties === 'object' ? properties : {}
const mdxAttributes = properties_?.attributes || {} // Add support for MDX attributes
/** @type {Array<{ type: 'mdxJsxAttribute' } & Record<string, unknown>>} */
const mdxAttributes =
/** @type {{ attributes?: Array<{ type: 'mdxJsxAttribute' } & Record<string, unknown>> }} */ (
properties_
)?.attributes || []

/** @type {Properties} */
const result = {}
Expand All @@ -573,6 +579,7 @@ function properties(state, properties) {
// Process traditional properties
for (key in properties_) {
if (own.call(properties_, key)) {
// @ts-ignore
const unsafe = properties_[key]
let safe = propertyValue(
state,
Expand Down

0 comments on commit c31c83f

Please sign in to comment.