diff --git a/src/highlight.js b/src/highlight.js
index e525d94354..e0406d91eb 100644
--- a/src/highlight.js
+++ b/src/highlight.js
@@ -107,7 +107,7 @@ const HLJS = function(hljs) {
* @property {boolean} illegal - indicates whether any illegal matches were found
*/
function highlight(languageName, code, ignoreIllegals, continuation) {
- /** @type {{ code: string, language: string, result?: any }} */
+ /** @type {BeforeHighlightContext} */
const context = {
code,
language: languageName
diff --git a/src/lib/logger.js b/src/lib/logger.js
index e5ccce4493..d102f74aea 100644
--- a/src/lib/logger.js
+++ b/src/lib/logger.js
@@ -14,9 +14,10 @@ export const error = (message) => {
/**
* @param {string} message
+ * @param {any} args
*/
-export const warn = (message) => {
- console.log(`WARN: ${message}`);
+export const warn = (message, ...args) => {
+ console.log(`WARN: ${message}`, ...args);
};
/**
diff --git a/types/index.d.ts b/types/index.d.ts
index c66773faae..fa5b06f9bf 100644
--- a/types/index.d.ts
+++ b/types/index.d.ts
@@ -1,3 +1,5 @@
+/* eslint-disable no-unused-vars */
+/* eslint-disable no-use-before-define */
// For TS consumers who use Node and don't have dom in their tsconfig lib, import the necessary types here.
///
@@ -77,6 +79,7 @@ interface HighlightResult {
errorRaised? : Error
// * for auto-highlight
second_best? : Omit
+ code?: string
}
interface AutoHighlightResult extends HighlightResult {}
@@ -86,14 +89,17 @@ interface illegalData {
mode: CompiledMode
}
-type PluginEvent =
- 'before:highlight'
- | 'after:highlight'
- | 'before:highlightBlock'
- | 'after:highlightBlock'
-
+type BeforeHighlightContext = {
+ code: string,
+ language: string,
+ result?: HighlightResult
+}
+type PluginEvent = keyof HLJSPlugin;
type HLJSPlugin = {
- [K in PluginEvent]? : any
+ 'after:highlight'?: (result: HighlightResult) => void,
+ 'before:highlight'?: (context: BeforeHighlightContext) => void,
+ 'after:highlightBlock'?: (data: { result: HighlightResult}) => void,
+ 'before:highlightBlock'?: (data: { block: Element, language: string}) => void,
}
interface EmitterConstructor {
@@ -162,6 +168,7 @@ interface LanguageDetail {
exports?: any,
classNameAliases?: Record
compilerExtensions?: CompilerExt[]
+ supersetOf?: string
}
type Language = LanguageDetail & Partial