Skip to content

Commit

Permalink
Update types for changes in micromark-util-types
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed May 30, 2023
1 parent 40a9fa9 commit 59e04e5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
3 changes: 3 additions & 0 deletions dev/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 4 additions & 3 deletions dev/lib/html.js
Original file line number Diff line number Diff line change
@@ -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
*/

Expand Down Expand Up @@ -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
}
Expand Down
9 changes: 5 additions & 4 deletions dev/lib/syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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}

/**
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"include": ["**/*.js"],
"exclude": ["coverage/", "node_modules/"],
"exclude": ["coverage/", "lib/", "node_modules/", "index.js"],
"compilerOptions": {
"checkJs": true,
"declaration": true,
Expand Down

0 comments on commit 59e04e5

Please sign in to comment.