From f0869ceb73e17866903f25b8039173e7d792c589 Mon Sep 17 00:00:00 2001 From: terminalchai Date: Sun, 15 Mar 2026 00:32:34 +0530 Subject: [PATCH 1/2] fix(yaml): export YAMLException type from js-yaml --- src/index.ts | 2 +- src/yaml.ts | 21 +++------------------ 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/src/index.ts b/src/index.ts index add28cb..031fcb7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,7 +5,7 @@ export { parseJSONC, stringifyJSONC } from "./jsonc"; export type { JSONCParseError, JSONCParseOptions } from "./jsonc"; export { parseYAML, stringifyYAML } from "./yaml"; -export type { YAMLParseOptions, YAMLStringifyOptions } from "./yaml"; +export type { YAMLParseOptions, YAMLStringifyOptions, YAMLException } from "./yaml"; export { parseJSON, stringifyJSON } from "./json"; export type { JSONParseOptions, JSONStringifyOptions } from "./json"; diff --git a/src/yaml.ts b/src/yaml.ts index 7003751..b904bbe 100644 --- a/src/yaml.ts +++ b/src/yaml.ts @@ -1,4 +1,4 @@ -import { load, dump } from "js-yaml"; +import { load, dump, YAMLException } from "js-yaml"; import { type FormatOptions, getFormat, storeFormat } from "./_format"; // Source: https://github.com/nodeca/js-yaml @@ -48,6 +48,8 @@ export function stringifyYAML(value: any, options?: YAMLStringifyOptions): strin // --- Types --- +export type { YAMLException }; + export interface YAMLParseOptions extends FormatOptions { /** string to be used as a file path in error/warning messages. */ filename?: string | undefined; @@ -95,20 +97,3 @@ export interface YAMLStringifyOptions extends FormatOptions { replacer?: ((key: string, value: any) => any) | undefined; } -interface Mark { - buffer: string; - column: number; - line: number; - name: string; - position: number; - snippet: string; -} - -declare class YAMLException extends Error { - constructor(reason?: string, mark?: Mark); - toString(compact?: boolean): string; - name: string; - reason: string; - message: string; - mark: Mark; -} From caebf914e45e94d27b631fd3488ee090ca04514a Mon Sep 17 00:00:00 2001 From: terminalchai Date: Sun, 15 Mar 2026 01:19:58 +0530 Subject: [PATCH 2/2] fix(yaml): use value export for YAMLException to support instanceof --- src/index.ts | 4 ++-- src/yaml.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index 031fcb7..323cd44 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,8 +4,8 @@ export type { JSON5ParseOptions, JSON5StringifyOptions } from "./json5"; export { parseJSONC, stringifyJSONC } from "./jsonc"; export type { JSONCParseError, JSONCParseOptions } from "./jsonc"; -export { parseYAML, stringifyYAML } from "./yaml"; -export type { YAMLParseOptions, YAMLStringifyOptions, YAMLException } from "./yaml"; +export { parseYAML, stringifyYAML, YAMLException } from "./yaml"; +export type { YAMLParseOptions, YAMLStringifyOptions } from "./yaml"; export { parseJSON, stringifyJSON } from "./json"; export type { JSONParseOptions, JSONStringifyOptions } from "./json"; diff --git a/src/yaml.ts b/src/yaml.ts index b904bbe..291724b 100644 --- a/src/yaml.ts +++ b/src/yaml.ts @@ -48,7 +48,7 @@ export function stringifyYAML(value: any, options?: YAMLStringifyOptions): strin // --- Types --- -export type { YAMLException }; +export { YAMLException }; export interface YAMLParseOptions extends FormatOptions { /** string to be used as a file path in error/warning messages. */