Skip to content

Commit

Permalink
(chore) clean up types just a little
Browse files Browse the repository at this point in the history
  • Loading branch information
joshgoebel committed Jun 16, 2020
1 parent a4ee4e4 commit c5783d2
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
// eslint-disable-next-line
declare const hljs : HLJSApi;

interface HLJSApi {
type HLJSApi = PublicApi & ModesAPI

interface PublicApi {
highlight: (languageName: string, code: string, ignoreIllegals?: boolean, continuation?: Mode) => HighlightResult
highlightAuto: (code: string, languageSubset?: string[]) => AutoHighlightResult
fixMarkup: (html: string) => string
Expand All @@ -24,7 +26,7 @@ interface HLJSApi {
versionString: string
}

interface HLJSApi {
interface ModesAPI {
SHEBANG: (mode?: Partial<Mode> & {binary?: string | RegExp}) => Mode
BACKSLASH_ESCAPE: Mode
QUOTE_STRING_MODE: Mode
Expand All @@ -43,7 +45,7 @@ interface HLJSApi {
UNDERSCORE_TITLE_MODE: Mode
METHOD_GUARD: Mode
END_SAME_AS_BEGIN: (mode: Mode) => Mode
// build in regex
// built in regex
IDENT_RE: string
UNDERSCORE_IDENT_RE: string
NUMBER_RE: string
Expand All @@ -52,13 +54,7 @@ interface HLJSApi {
RE_STARTERS_RE: string
}

type LanguageFn = (hljs: HLJSApi) => Language

// interface RawLanguage {
// name?: string
// aliases?: string[]
// rawDefinition?: () => Language
// }
type LanguageFn = (hljs?: HLJSApi) => Language

interface HighlightResult {
relevance : number
Expand All @@ -73,23 +69,23 @@ interface HighlightResult {
// * for auto-highlight
second_best? : Omit<HighlightResult, 'second_best'>
}
interface AutoHighlightResult extends HighlightResult {}

interface illegalData {
msg: string
context: string
mode: CompiledMode
}

interface AutoHighlightResult extends HighlightResult {
}

type PluginEvent =
'before:highlight'
| 'after:highlight'
| 'before:highlightBlock'
| 'after:highlightBlock'

type HLJSPlugin = { [K in PluginEvent]? : any }
type HLJSPlugin = {
[K in PluginEvent]? : any
}

interface EmitterConstructor {
new (opts: any): Emitter
Expand Down

0 comments on commit c5783d2

Please sign in to comment.