From 1a3e05b546a9706a20b50f4ab7eda4b5ae4b1092 Mon Sep 17 00:00:00 2001 From: Joe Hildebrand Date: Thu, 9 Jun 2022 14:24:08 -0600 Subject: [PATCH] Fix definition of DiagnosticCallback. Fixes #283. --- CHANGELOG.md | 3 ++- lib/peg.d.ts | 58 +++++++++++++--------------------------------------- 2 files changed, 16 insertions(+), 45 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7e0b554..09581a09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,7 +27,8 @@ Released: TBD ### Bug Fixes -- None +- [#283](https://github.com/peggyjs/peggy/issues/283) Fix incorrect type + information for DiagnosticCallback, from @hildjj 2.0.1 ----- diff --git a/lib/peg.d.ts b/lib/peg.d.ts index 6da5da96..c120acb9 100644 --- a/lib/peg.d.ts +++ b/lib/peg.d.ts @@ -997,50 +997,20 @@ export interface Session { ): void; } -export interface DiagnosticCallback { - /** - * Called when compiler reports an error. - * - * @param stage Stage in which this diagnostic was originated - * @param message Main message, which should describe error objectives - * @param location If defined, this is location described in the `message` - * @param notes Additional messages with context information - */ - error?( - stage: Stage, - message: string, - location?: LocationRange, - notes?: DiagnosticNote[] - ): void; - /** - * Called when compiler reports a warning. - * - * @param stage Stage in which this diagnostic was originated - * @param message Main message, which should describe warning objectives - * @param location If defined, this is location described in the `message` - * @param notes Additional messages with context information - */ - warning?( - stage: Stage, - message: string, - location?: LocationRange, - notes?: DiagnosticNote[] - ): void; - /** - * Called when compiler reports an informational message. - * - * @param stage Stage in which this diagnostic was originated - * @param message Main message, which gives information about an event - * @param location If defined, this is location described in the `message` - * @param notes Additional messages with context information - */ - info?( - stage: Stage, - message: string, - location?: LocationRange, - notes?: DiagnosticNote[] - ): void; -} +/** + * Called when compiler reports an error, warning, or info. + * + * @param stage Stage in which this diagnostic was originated + * @param message Main message, which should describe error objectives + * @param location If defined, this is location described in the `message` + * @param notes Additional messages with context information + */ +export type DiagnosticCallback = ( + stage: Stage, + message: string, + location?: LocationRange, + notes?: DiagnosticNote[] +) => void; /** * Parser dependencies, is an object which maps variables used to access the