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 cd10e59 commit 13430aa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
12 changes: 12 additions & 0 deletions dev/index.d.ts
Expand Up @@ -75,4 +75,16 @@ export interface CompileData {
referenceType?: 'collapsed' | 'full' | undefined
}

declare module 'micromark-util-types' {
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
interface TokenTypeMap {
listItem: 'listItem'
}

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
interface Token {
_spread?: boolean
}
}

export {fromMarkdown} from './lib/index.js'
10 changes: 3 additions & 7 deletions dev/lib/index.js
Expand Up @@ -192,7 +192,6 @@ export const fromMarkdown =

return compiler(options)(
postprocess(
// @ts-expect-error: micromark types need to accept `null`.
parse(options).document().write(preprocess()(value, encoding, true))
)
)
Expand Down Expand Up @@ -504,7 +503,6 @@ function compiler(options) {
firstBlankLineIndex &&
(!lineIndex || firstBlankLineIndex < lineIndex)
) {
// @ts-expect-error Patched.
listItem._spread = true
}

Expand All @@ -523,9 +521,10 @@ function compiler(options) {
if (event[1].type === types.listItemPrefix) {
listItem = {
type: 'listItem',
// @ts-expect-error Patched
_spread: false,
start: Object.assign({}, event[1].start)
start: Object.assign({}, event[1].start),
// @ts-expect-error: we’ll add `end` in a second.
end: undefined
}
// @ts-expect-error: `listItem` is most definitely defined, TS...
events.splice(index, 0, ['enter', listItem, event[2]])
Expand All @@ -537,7 +536,6 @@ function compiler(options) {
}
}

// @ts-expect-error Patched.
events[start][1]._spread = listSpread
return length
}
Expand Down Expand Up @@ -1339,7 +1337,6 @@ function compiler(options) {
type: 'list',
ordered: token.type === 'listOrdered',
start: null,
// @ts-expect-error Patched.
spread: token._spread,
children: []
}
Expand All @@ -1352,7 +1349,6 @@ function compiler(options) {
function listItem(token) {
return {
type: 'listItem',
// @ts-expect-error Patched.
spread: token._spread,
checked: null,
children: []
Expand Down

0 comments on commit 13430aa

Please sign in to comment.