Skip to content

Commit

Permalink
Add exports of MdxJsx{Flow,Text}ElementHast types
Browse files Browse the repository at this point in the history
Closes GH-7.
  • Loading branch information
wooorm committed Jan 31, 2023
1 parent f9794c4 commit 4403dfd
Showing 1 changed file with 53 additions and 4 deletions.
57 changes: 53 additions & 4 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {
DefinitionContent,
PhrasingContent
} from 'mdast'
import type {ElementContent, Parent as HastParent} from 'hast'
import type {Program} from 'estree-jsx'

import type {Tag} from './lib/index.js'
Expand Down Expand Up @@ -136,6 +137,54 @@ export interface MdxJsxTextElement extends MdastParent {
children: PhrasingContent[]
}

/**
* MDX JSX element node, occurring in flow (block), for hast.
*/
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
export interface MdxJsxFlowElementHast extends HastParent {
/**
* Node type.
*/
type: 'mdxJsxFlowElement'
/**
* MDX JSX element name (`null` for fragments).
*/
// eslint-disable-next-line @typescript-eslint/ban-types
name: string | null
/**
* MDX JSX element attributes.
*/
attributes: Array<MdxJsxAttribute | MdxJsxExpressionAttribute>
/**
* Content.
*/
children: ElementContent[]
}

/**
* MDX JSX element node, occurring in text (phrasing), for hast.
*/
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
export interface MdxJsxTextElementHast extends HastParent {
/**
* Node type.
*/
type: 'mdxJsxTextElement'
/**
* MDX JSX element name (`null` for fragments).
*/
// eslint-disable-next-line @typescript-eslint/ban-types
name: string | null
/**
* MDX JSX element attributes.
*/
attributes: Array<MdxJsxAttribute | MdxJsxExpressionAttribute>
/**
* Content.
*/
children: ElementContent[]
}

// Add nodes to mdast content.
declare module 'mdast' {
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
Expand All @@ -162,23 +211,23 @@ declare module 'hast' {
/**
* MDX JSX element node, occurring in text (phrasing).
*/
mdxJsxTextElement: MdxJsxTextElement
mdxJsxTextElement: MdxJsxTextElementHast
/**
* MDX JSX element node, occurring in flow (block).
*/
mdxJsxFlowElement: MdxJsxFlowElement
mdxJsxFlowElement: MdxJsxFlowElementHast
}

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
interface ElementContentMap {
/**
* MDX JSX element node, occurring in text (phrasing).
*/
mdxJsxTextElement: MdxJsxTextElement
mdxJsxTextElement: MdxJsxTextElementHast
/**
* MDX JSX element node, occurring in flow (block).
*/
mdxJsxFlowElement: MdxJsxFlowElement
mdxJsxFlowElement: MdxJsxFlowElementHast
}
}

Expand Down

0 comments on commit 4403dfd

Please sign in to comment.