From 843e046c3423e4ce1d0630a9c706b465065792e0 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Sat, 8 Jul 2023 17:37:34 +0200 Subject: [PATCH] Update `@types/mdast` and friends --- dev/lib/index.js | 32 +++++++++++++------------------- package.json | 8 ++++---- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/dev/lib/index.js b/dev/lib/index.js index ee5fbce..75b0281 100644 --- a/dev/lib/index.js +++ b/dev/lib/index.js @@ -6,24 +6,21 @@ * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext * @typedef {import('micromark-util-types').Value} Value * - * @typedef {import('unist').Parent} UnistParent * @typedef {import('unist').Point} Point * + * @typedef {import('mdast').Parent} Parent * @typedef {import('mdast').PhrasingContent} PhrasingContent - * @typedef {import('mdast').StaticPhrasingContent} StaticPhrasingContent - * @typedef {import('mdast').Content} Content + * @typedef {import('mdast').Nodes} Nodes * @typedef {import('mdast').Break} Break * @typedef {import('mdast').Blockquote} Blockquote * @typedef {import('mdast').Code} Code * @typedef {import('mdast').Definition} Definition * @typedef {import('mdast').Emphasis} Emphasis * @typedef {import('mdast').Heading} Heading - * @typedef {import('mdast').HTML} HTML + * @typedef {import('mdast').Html} Html * @typedef {import('mdast').Image} Image - * @typedef {import('mdast').ImageReference} ImageReference * @typedef {import('mdast').InlineCode} InlineCode * @typedef {import('mdast').Link} Link - * @typedef {import('mdast').LinkReference} LinkReference * @typedef {import('mdast').List} List * @typedef {import('mdast').ListItem} ListItem * @typedef {import('mdast').Paragraph} Paragraph @@ -36,10 +33,8 @@ */ /** - * @typedef {Root | Content} Node - * @typedef {Extract} Parent * - * @typedef {Omit & {type: 'fragment', children: Array}} Fragment + * @typedef {Omit & {type: 'fragment', children: Array}} Fragment */ /** @@ -110,7 +105,7 @@ * * @typedef CompileContext * mdast compiler context. - * @property {Array} stack + * @property {Array} stack * Stack of nodes. * @property {Array} tokenStack * Stack of tokens. @@ -122,9 +117,9 @@ * Capture some of the output data. * @property {(this: CompileContext) => string} resume * Stop capturing and access the output data. - * @property {(this: CompileContext, node: Kind, token: Token, onError?: OnEnterError) => Kind} enter + * @property {(this: CompileContext, node: Kind, token: Token, onError?: OnEnterError) => Kind} enter * Enter a token. - * @property {(this: CompileContext, token: Token, onError?: OnExitError) => Node} exit + * @property {(this: CompileContext, token: Token, onError?: OnExitError) => Nodes} exit * Exit a token. * @property {TokenizeContext['sliceSerialize']} sliceSerialize * Get the string value of a token. @@ -141,7 +136,7 @@ */ // To do: micromark: create a registry of tokens? -// To do: next major: don’t return given `Node` from `enter`. +// To do: next major: don’t return given `Nodes` from `enter`. // To do: next major: remove setter/getter. import {ok as assert} from 'devlop' @@ -569,7 +564,7 @@ function compiler(options) { /** * Create an opener handle. * - * @param {(token: Token) => Node} create + * @param {(token: Token) => Nodes} create * Create a node. * @param {Handle} [and] * Optional function to also run. @@ -599,7 +594,7 @@ function compiler(options) { } /** - * @template {Node} Kind + * @template {Nodes} Kind * Node type. * @this {CompileContext} * Context. @@ -654,7 +649,7 @@ function compiler(options) { * Corresponding token. * @param {OnExitError | undefined} [onExitError] * Handle the case where another token is open. - * @returns {Node} + * @returns {Nodes} * The closed node. */ function exit(token, onExitError) { @@ -1108,8 +1103,7 @@ function compiler(options) { setData('inReference', true) if (node.type === 'link') { - /** @type {Array} */ - // @ts-expect-error: Assume static phrasing content. + /** @type {Array} */ const children = fragment.children node.children = children @@ -1309,7 +1303,7 @@ function compiler(options) { return {type: 'break'} } - /** @returns {HTML} */ + /** @returns {Html} */ function html() { return {type: 'html', value: ''} } diff --git a/package.json b/package.json index daf5db3..a858bae 100644 --- a/package.json +++ b/package.json @@ -41,18 +41,18 @@ "default": "./index.js" }, "dependencies": { - "@types/mdast": "^3.0.0", - "@types/unist": "^2.0.0", + "@types/mdast": "^4.0.0", + "@types/unist": "^3.0.0", "decode-named-character-reference": "^1.0.0", "devlop": "^1.0.0", - "mdast-util-to-string": "^3.1.0", + "mdast-util-to-string": "^4.0.0", "micromark": "^4.0.0", "micromark-util-decode-numeric-character-reference": "^2.0.0", "micromark-util-decode-string": "^2.0.0", "micromark-util-normalize-identifier": "^2.0.0", "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0", - "unist-util-stringify-position": "^3.0.0" + "unist-util-stringify-position": "^4.0.0" }, "devDependencies": { "@types/node": "^20.0.0",