From 215b4314316bd2a03ece95c15e061d599394f62b Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Fri, 23 Aug 2024 18:14:06 -0400 Subject: [PATCH 1/2] No dynamic checker --- packages/@glimmer/debug/lib/stack-check.ts | 25 +++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/packages/@glimmer/debug/lib/stack-check.ts b/packages/@glimmer/debug/lib/stack-check.ts index f8abf5bbba..5d1c64e3f2 100644 --- a/packages/@glimmer/debug/lib/stack-check.ts +++ b/packages/@glimmer/debug/lib/stack-check.ts @@ -16,20 +16,25 @@ export interface Checker { expected(): string; } -export function wrap(checker: () => Checker): Checker { - class Wrapped { - declare type: T; +class Wrapped { + declare type: T; + #checker: () => Checker; - validate(value: unknown): value is T { - return checker().validate(value); - } + constructor(checker: () => Checker) { + this.#checker = checker; + } - expected(): string { - return checker().expected(); - } + validate(value: unknown): value is T { + return this.#checker().validate(value); } - return new Wrapped(); + expected(): string { + return this.#checker().expected(); + } +} + +export function wrap(checker: () => Checker): Checker { + return new Wrapped(checker); } export interface Constructor extends Function { From ac906870b7d2bfc969a015c7e55c16035a8cbd75 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Fri, 23 Aug 2024 18:24:37 -0400 Subject: [PATCH 2/2] Was this needed? --- packages/@glimmer/debug/lib/stack-check.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/@glimmer/debug/lib/stack-check.ts b/packages/@glimmer/debug/lib/stack-check.ts index 5d1c64e3f2..f030d9f373 100644 --- a/packages/@glimmer/debug/lib/stack-check.ts +++ b/packages/@glimmer/debug/lib/stack-check.ts @@ -18,18 +18,18 @@ export interface Checker { class Wrapped { declare type: T; - #checker: () => Checker; + #checker: Checker; constructor(checker: () => Checker) { - this.#checker = checker; + this.#checker = checker(); } validate(value: unknown): value is T { - return this.#checker().validate(value); + return this.#checker.validate(value); } expected(): string { - return this.#checker().expected(); + return this.#checker.expected(); } }