From b8bf126ffb0ca30a9c247a05e31503e71f907a5b Mon Sep 17 00:00:00 2001 From: Sasha Sorokin <10401817+Brawaru@users.noreply.github.com> Date: Mon, 9 Oct 2023 03:42:03 +0200 Subject: [PATCH] feat: export types related to error handling --- src/parser/error-handling.ts | 6 +++--- src/parser/index.ts | 2 ++ src/secondary-exports.ts | 8 +++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/parser/error-handling.ts b/src/parser/error-handling.ts index 6970150..96a580f 100644 --- a/src/parser/error-handling.ts +++ b/src/parser/error-handling.ts @@ -4,7 +4,7 @@ import { type ParserOptions, } from '@formatjs/icu-messageformat-parser' -type ParseErrorHandlerResult = MessageFormatElement[] | undefined | void +export type ParseErrorHandlerResult = MessageFormatElement[] | undefined | void /** * A function that handles parsing error and either throws another error, or @@ -39,7 +39,7 @@ export const builtinStrategies = { Object.setPrototypeOf(builtinStrategies, null) -type ParseErrorHandlingStrategy = keyof typeof builtinStrategies +export type ParseErrorHandlingStrategy = keyof typeof builtinStrategies export type ParseErrorHandlingOption = | ParseErrorHandler @@ -61,7 +61,7 @@ export function resolveParseErrorHandler(option: ParseErrorHandlingOption) { throw new Error(`Cannot resolve built-in strategy with name "${option}"`) } -interface ParseErrorContext { +export interface ParseErrorContext { /** ID of the module that is being parsed. */ get moduleId(): string diff --git a/src/parser/index.ts b/src/parser/index.ts index 5ac76ab..a89722f 100644 --- a/src/parser/index.ts +++ b/src/parser/index.ts @@ -10,4 +10,6 @@ export { resolveParseErrorHandler, type ParseErrorHandler, type ParseErrorHandlingOption, + type ParseErrorContext, + type ParseErrorHandlingStrategy, } from './error-handling.ts' diff --git a/src/secondary-exports.ts b/src/secondary-exports.ts index 1ddf2af..cf74e7d 100644 --- a/src/secondary-exports.ts +++ b/src/secondary-exports.ts @@ -1 +1,7 @@ -export { AnyMessage } from './parser/index.ts' +export { + AnyMessage, + type ParseErrorContext, + type ParseErrorHandler, + type ParseErrorHandlingOption, + type ParseErrorHandlingStrategy, +} from './parser/index.ts'