diff --git a/packages/@glimmer/debug/lib/stack-check.ts b/packages/@glimmer/debug/lib/stack-check.ts index f8abf5bbba..f030d9f373 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 {