Skip to content

Commit 10042da

Browse files
committed
Refactor code-style
* Add more docs to JSDoc * Add support for `null` in input of API types
1 parent 3f980d1 commit 10042da

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

complex-types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// To do: next major: remove this file.
2-
export type {MdxjsEsm} from './index.js'
2+
export type {MdxjsEsm, MDXJSEsm} from './index.js'
33

44
/// <reference types="./index.js" />

index.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ export interface MdxjsEsm extends Literal {
2525
}
2626
}
2727

28+
/**
29+
* Deprecated: use the `MdxjsEsm` type instead.
30+
*/
31+
// eslint-disable-next-line @typescript-eslint/naming-convention
32+
export type MDXJSEsm = MdxjsEsm
33+
2834
// Add nodes to content.
2935
declare module 'mdast' {
3036
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions

lib/index.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,30 @@
22
* @typedef {import('mdast-util-from-markdown').CompileContext} CompileContext
33
* @typedef {import('mdast-util-from-markdown').Extension} FromMarkdownExtension
44
* @typedef {import('mdast-util-from-markdown').Handle} FromMarkdownHandle
5-
* @typedef {import('mdast-util-to-markdown').Options} ToMarkdownExtension
5+
*
66
* @typedef {import('mdast-util-to-markdown').Handle} ToMarkdownHandle
7+
* @typedef {import('mdast-util-to-markdown').Options} ToMarkdownExtension
8+
*
79
* @typedef {import('estree-jsx').Program} Program
8-
* @typedef {import('../index.js').MdxjsEsm} MdxjsEsm
910
*
10-
* @typedef {MdxjsEsm} MDXJSEsm
11-
* Deprecated name, prefer `MdxjsEsm`.
11+
* @typedef {import('../index.js').MdxjsEsm} MdxjsEsm
1212
*/
1313

14-
/** @type {FromMarkdownExtension} */
14+
/**
15+
* Extension for `mdast-util-from-markdown` to enable MDX ESM.
16+
*
17+
* @type {FromMarkdownExtension}
18+
*/
1519
export const mdxjsEsmFromMarkdown = {
1620
enter: {mdxjsEsm: enterMdxjsEsm},
1721
exit: {mdxjsEsm: exitMdxjsEsm, mdxjsEsmData: exitMdxjsEsmData}
1822
}
1923

20-
/** @type {ToMarkdownExtension} */
24+
/**
25+
* Extension for `mdast-util-to-markdown` to enable MDX ESM.
26+
*
27+
* @type {ToMarkdownExtension}
28+
*/
2129
export const mdxjsEsmToMarkdown = {handlers: {mdxjsEsm: handleMdxjsEsm}}
2230

2331
/**
@@ -36,7 +44,7 @@ function enterMdxjsEsm(token) {
3644
function exitMdxjsEsm(token) {
3745
const value = this.resume()
3846
const node = /** @type {MdxjsEsm} */ (this.exit(token))
39-
/** @type {Program|undefined} */
47+
/** @type {Program | undefined} */
4048
// @ts-expect-error: custom.
4149
const estree = token.estree
4250

0 commit comments

Comments
 (0)