Skip to content

Commit 86311fc

Browse files
mmkaljoshgoebel
authored andcommitted
types: separate out deprecated highlight overload
Minor thing in the type definitions I noticed. The .js makes it clear that the old API looks like `highlight(lang, code, ignoreIllegals)`, and the new API looks like `highlight(code, {lang, ignoreIllegals})`. The types on the other hand imply you could do things like `highlight(code, {lang: ...}, true)` - but that `true` would be ignored at runtime. So this separates the two forms into function overloads, and adds a `/** @deprecated */` tag to the old form so IDEs will hint not to use it.
1 parent 4b45a2b commit 86311fc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

types/index.d.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ declare module 'highlight.js' {
2929
}
3030

3131
interface PublicApi {
32-
highlight: (codeOrLanguageName: string, optionsOrCode: string | HighlightOptions, ignoreIllegals?: boolean) => HighlightResult
32+
highlight(code: string, options: HighlightOptions): HighlightResult
33+
/** @deprecated use `higlight(code, {lang: ..., ignoreIllegals: ...})` */
34+
highlight(languageName: string, code: string, ignoreIllegals?: boolean): HighlightResult
3335
highlightAuto: (code: string, languageSubset?: string[]) => AutoHighlightResult
3436
highlightBlock: (element: HTMLElement) => void
3537
highlightElement: (element: HTMLElement) => void

0 commit comments

Comments
 (0)