Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix types for prism library prop. #204

Merged
merged 1 commit into from
May 7, 2023
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