From 33e455282d4b168c929b367a0cb7d22a250a63e4 Mon Sep 17 00:00:00 2001 From: Yang Jun Date: Thu, 23 Jul 2026 22:37:21 +0800 Subject: [PATCH] refactor: encapsulate Drop passthrough in createScope --- src/context/context.ts | 2 +- src/context/scope.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/context/context.ts b/src/context/context.ts index c85323f39..2619be6b6 100644 --- a/src/context/context.ts +++ b/src/context/context.ts @@ -95,7 +95,7 @@ export class Context { return scope } public push (ctx: Scope): Scope { - const scope = ctx instanceof Drop ? ctx : createScope(ctx) + const scope = createScope(ctx) this.scopes.push(scope) return scope } diff --git a/src/context/scope.ts b/src/context/scope.ts index e5fd79943..33603d941 100644 --- a/src/context/scope.ts +++ b/src/context/scope.ts @@ -6,6 +6,7 @@ export interface ScopeObject extends Record { export type Scope = ScopeObject | Drop -export function createScope (from?: ScopeObject): ScopeObject { +export function createScope (from?: Scope): Scope { + if (from instanceof Drop) return from return Object.assign(Object.create(null), from) }