Skip to content

Commit 0297cd9

Browse files
authoredJun 15, 2024··
fix(rehype): fix type issues (#699)
* fix(rehype): fix type issues The augmented hast `Data` interface conflicts with `ElementData` from `mdast-util-to-hast`. The augmentation is redundant, so it’s removed entirely. The augmented hast `Properties` interface was redundant and invalid. Instead, the value is now converted to string in the place it is used.
1 parent 966e7e4 commit 0297cd9

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed
 

‎packages/rehype/src/core.ts

+1-10
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,6 @@ export type RehypeShikiCoreOptions =
5858
& CodeOptionsMeta
5959
& RehypeShikiExtraOptions
6060

61-
declare module 'hast' {
62-
interface Data {
63-
meta?: string
64-
}
65-
interface Properties {
66-
metastring?: string
67-
}
68-
}
69-
7061
const languagePrefix = 'language-'
7162

7263
function rehypeShikiFromHighlighter(
@@ -123,7 +114,7 @@ function rehypeShikiFromHighlighter(
123114
return
124115
}
125116

126-
const metaString = head.data?.meta ?? head.properties.metastring ?? ''
117+
const metaString = head.data?.meta ?? head.properties.metastring?.toString() ?? ''
127118
const meta = parseMetaString?.(metaString, node, tree) || {}
128119

129120
const codeOptions: CodeToHastOptions = {

‎packages/rehype/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/// <reference types="mdast-util-to-hast" />
12
import type { LanguageInput } from 'shiki/core'
23
import type { BuiltinLanguage, BuiltinTheme } from 'shiki'
34
import { bundledLanguages, getHighlighter } from 'shiki'

0 commit comments

Comments
 (0)