Skip to content

Commit

Permalink
Merge pull request #204 from FormidableLabs/fix/types-prism-lib
Browse files Browse the repository at this point in the history
  • Loading branch information
carloskelly13 committed May 7, 2023
2 parents d6c0605 + 231b346 commit 096b8f9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .changeset/popular-seals-occur.md
@@ -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
@@ -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

0 comments on commit 096b8f9

Please sign in to comment.