Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/popular-seals-occur.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"prism-react-renderer": patch
---

Fix types for Prism library.
23 changes: 4 additions & 19 deletions packages/prism-react-renderer/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
import type { CSSProperties } from "react"
import type { Token as PrismToken } from "prismjs"
import type { Token as PrismToken, Grammar } from "prismjs"
import Prism from "prismjs"

export type Language = string
export type PrismGrammar = Record<string, unknown>
type LanguagesDict = Record<Language, PrismGrammar>

export type PrismLib = {
languages: LanguagesDict
tokenize: (code: string, grammar: PrismGrammar) => Array<PrismToken | string>
highlight: (code: string, grammar: PrismGrammar, language: Language) => string
hooks: {
run: (
name: string,
env: {
code: string
grammar: PrismGrammar
language: Language
}
) => void
}
}
export type PrismGrammar = Grammar
export type PrismLib = typeof Prism

export type Token = {
types: string[]
Expand Down