Skip to content

Commit c5783d2

Browse files
committed
(chore) clean up types just a little
1 parent a4ee4e4 commit c5783d2

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

Diff for: types/index.d.ts

+10-14
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
// eslint-disable-next-line
44
declare const hljs : HLJSApi;
55

6-
interface HLJSApi {
6+
type HLJSApi = PublicApi & ModesAPI
7+
8+
interface PublicApi {
79
highlight: (languageName: string, code: string, ignoreIllegals?: boolean, continuation?: Mode) => HighlightResult
810
highlightAuto: (code: string, languageSubset?: string[]) => AutoHighlightResult
911
fixMarkup: (html: string) => string
@@ -24,7 +26,7 @@ interface HLJSApi {
2426
versionString: string
2527
}
2628

27-
interface HLJSApi {
29+
interface ModesAPI {
2830
SHEBANG: (mode?: Partial<Mode> & {binary?: string | RegExp}) => Mode
2931
BACKSLASH_ESCAPE: Mode
3032
QUOTE_STRING_MODE: Mode
@@ -43,7 +45,7 @@ interface HLJSApi {
4345
UNDERSCORE_TITLE_MODE: Mode
4446
METHOD_GUARD: Mode
4547
END_SAME_AS_BEGIN: (mode: Mode) => Mode
46-
// build in regex
48+
// built in regex
4749
IDENT_RE: string
4850
UNDERSCORE_IDENT_RE: string
4951
NUMBER_RE: string
@@ -52,13 +54,7 @@ interface HLJSApi {
5254
RE_STARTERS_RE: string
5355
}
5456

55-
type LanguageFn = (hljs: HLJSApi) => Language
56-
57-
// interface RawLanguage {
58-
// name?: string
59-
// aliases?: string[]
60-
// rawDefinition?: () => Language
61-
// }
57+
type LanguageFn = (hljs?: HLJSApi) => Language
6258

6359
interface HighlightResult {
6460
relevance : number
@@ -73,23 +69,23 @@ interface HighlightResult {
7369
// * for auto-highlight
7470
second_best? : Omit<HighlightResult, 'second_best'>
7571
}
72+
interface AutoHighlightResult extends HighlightResult {}
7673

7774
interface illegalData {
7875
msg: string
7976
context: string
8077
mode: CompiledMode
8178
}
8279

83-
interface AutoHighlightResult extends HighlightResult {
84-
}
85-
8680
type PluginEvent =
8781
'before:highlight'
8882
| 'after:highlight'
8983
| 'before:highlightBlock'
9084
| 'after:highlightBlock'
9185

92-
type HLJSPlugin = { [K in PluginEvent]? : any }
86+
type HLJSPlugin = {
87+
[K in PluginEvent]? : any
88+
}
9389

9490
interface EmitterConstructor {
9591
new (opts: any): Emitter

0 commit comments

Comments
 (0)