diff --git a/yaml/_loader_state.ts b/yaml/_loader_state.ts index f6115a79fe08..eca9b601d0ac 100644 --- a/yaml/_loader_state.ts +++ b/yaml/_loader_state.ts @@ -365,9 +365,7 @@ export class LoaderState { const anchor = this.anchor; const result: unknown[] = []; - if (this.anchor !== null && typeof this.anchor !== "undefined") { - this.anchorMap.set(this.anchor, result); - } + if (this.anchor !== null) this.anchorMap.set(this.anchor, result); let ch = this.peek(); @@ -844,9 +842,7 @@ export class LoaderState { return false; } - if (this.anchor !== null && typeof this.anchor !== "undefined") { - this.anchorMap.set(this.anchor, result); - } + if (this.anchor !== null) this.anchorMap.set(this.anchor, result); ch = this.next(); @@ -1122,9 +1118,7 @@ export class LoaderState { let atExplicitKey = false; let detected = false; - if (this.anchor !== null && typeof this.anchor !== "undefined") { - this.anchorMap.set(this.anchor, result); - } + if (this.anchor !== null) this.anchorMap.set(this.anchor, result); let ch = this.peek(); @@ -1502,9 +1496,7 @@ export class LoaderState { } this.result = type.construct(this.result); - if (this.anchor !== null) { - this.anchorMap.set(this.anchor, this.result); - } + if (this.anchor !== null) this.anchorMap.set(this.anchor, this.result); } composeNode( { parentIndent, nodeContext, allowToSeek, allowCompact }: {