Skip to content

Commit 096b8f9

Browse files
Merge pull request #204 from FormidableLabs/fix/types-prism-lib
2 parents d6c0605 + 231b346 commit 096b8f9

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

.changeset/popular-seals-occur.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"prism-react-renderer": patch
3+
---
4+
5+
Fix types for Prism library.

packages/prism-react-renderer/src/types.ts

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,10 @@
11
import type { CSSProperties } from "react"
2-
import type { Token as PrismToken } from "prismjs"
2+
import type { Token as PrismToken, Grammar } from "prismjs"
3+
import Prism from "prismjs"
34

45
export type Language = string
5-
export type PrismGrammar = Record<string, unknown>
6-
type LanguagesDict = Record<Language, PrismGrammar>
7-
8-
export type PrismLib = {
9-
languages: LanguagesDict
10-
tokenize: (code: string, grammar: PrismGrammar) => Array<PrismToken | string>
11-
highlight: (code: string, grammar: PrismGrammar, language: Language) => string
12-
hooks: {
13-
run: (
14-
name: string,
15-
env: {
16-
code: string
17-
grammar: PrismGrammar
18-
language: Language
19-
}
20-
) => void
21-
}
22-
}
6+
export type PrismGrammar = Grammar
7+
export type PrismLib = typeof Prism
238

249
export type Token = {
2510
types: string[]

0 commit comments

Comments
 (0)