From 59e04e5ee99293fac58aa6f2056db931f73e5aa0 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Tue, 30 May 2023 16:14:42 +0200 Subject: [PATCH] Update types for changes in `micromark-util-types` --- dev/index.js | 3 +++ dev/lib/html.js | 7 ++++--- dev/lib/syntax.js | 9 +++++---- tsconfig.json | 2 +- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/dev/index.js b/dev/index.js index ae17457..fe59824 100644 --- a/dev/index.js +++ b/dev/index.js @@ -7,3 +7,6 @@ export {frontmatter} from './lib/syntax.js' export {frontmatterHtml} from './lib/html.js' + +// Note: we don’t have an `index.d.ts` in this extension because all token +// types are dynamic in JS diff --git a/dev/lib/html.js b/dev/lib/html.js index cb2509a..152b963 100644 --- a/dev/lib/html.js +++ b/dev/lib/html.js @@ -1,7 +1,8 @@ /** - * @typedef {import('micromark-util-types').HtmlExtension} HtmlExtension - * @typedef {import('micromark-util-types').Handle} Handle * @typedef {import('micromark-util-types').CompileContext} CompileContext + * @typedef {import('micromark-util-types').Handle} Handle + * @typedef {import('micromark-util-types').HtmlExtension} HtmlExtension + * @typedef {import('micromark-util-types').TokenType} TokenType * @typedef {import('../matters.js').Options} Options */ @@ -29,7 +30,7 @@ export function frontmatterHtml(options) { let index = -1 while (++index < listOfMatters.length) { - const type = listOfMatters[index].type + const type = /** @type {TokenType} */ (listOfMatters[index].type) enter[type] = start exit[type] = end } diff --git a/dev/lib/syntax.js b/dev/lib/syntax.js index 4fa39c9..ea39375 100644 --- a/dev/lib/syntax.js +++ b/dev/lib/syntax.js @@ -3,6 +3,7 @@ * @typedef {import('micromark-util-types').ConstructRecord} ConstructRecord * @typedef {import('micromark-util-types').Extension} Extension * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenType} TokenType * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext * @typedef {import('micromark-util-types').Tokenizer} Tokenizer * @@ -54,10 +55,10 @@ export function frontmatter(options) { */ function createConstruct(matter) { const anywhere = matter.anywhere - const frontmatterType = matter.type - const fenceType = frontmatterType + 'Fence' - const sequenceType = fenceType + 'Sequence' - const valueType = frontmatterType + 'Value' + const frontmatterType = /** @type {TokenType} */ (matter.type) + const fenceType = /** @type {TokenType} */ (frontmatterType + 'Fence') + const sequenceType = /** @type {TokenType} */ (fenceType + 'Sequence') + const valueType = /** @type {TokenType} */ (frontmatterType + 'Value') const closingFenceConstruct = {tokenize: tokenizeClosingFence, partial: true} /** diff --git a/tsconfig.json b/tsconfig.json index ebe8889..cc07d3f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,6 @@ { "include": ["**/*.js"], - "exclude": ["coverage/", "node_modules/"], + "exclude": ["coverage/", "lib/", "node_modules/", "index.js"], "compilerOptions": { "checkJs": true, "declaration": true,