refactor(yaml): remove ResultType (#5765)

initial commit
This commit is contained in:
Tim Reichen 2024-08-22 04:43:07 +02:00 committed by GitHub
parent 0332f0ada8
commit 349fb8f8f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -67,8 +67,6 @@ export interface LoaderStateOptions {
onWarning?(error: Error): void;
}
type ResultType = unknown[] | Record<string, unknown> | string;
const ESCAPED_HEX_LENGTHS = new Map<number, number>([
[0x78, 2], // x
[0x75, 4], // u
@ -155,7 +153,7 @@ export class LoaderState {
tag?: string | null;
anchor?: string | null;
kind?: string | null;
result: ResultType | null = "";
result: unknown[] | Record<string, unknown> | string | null = "";
constructor(
input: string,
@ -863,7 +861,7 @@ function readFlowCollection(state: LoaderState, nodeIndent: number): boolean {
let ch = state.peek();
let terminator: number;
let isMapping = true;
let result: ResultType = {};
let result = {};
if (ch === LEFT_SQUARE_BRACKET) {
terminator = RIGHT_SQUARE_BRACKET;
isMapping = false;
@ -958,7 +956,7 @@ function readFlowCollection(state: LoaderState, nodeIndent: number): boolean {
),
);
} else {
(result as ResultType[]).push(keyNode as ResultType);
(result as unknown[]).push(keyNode);
}
skipSeparationSpace(state, true, nodeIndent);