Skip to content

Commit

Permalink
No dynamic checker
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Aug 23, 2024
1 parent 10eae74 commit 215b431
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions packages/@glimmer/debug/lib/stack-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,25 @@ export interface Checker<T> {
expected(): string;
}

export function wrap<T>(checker: () => Checker<T>): Checker<T> {
class Wrapped {
declare type: T;
class Wrapped<T> {
declare type: T;
#checker: () => Checker<T>;

validate(value: unknown): value is T {
return checker().validate(value);
}
constructor(checker: () => Checker<T>) {
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<T>(checker: () => Checker<T>): Checker<T> {
return new Wrapped(checker);
}

export interface Constructor<T> extends Function {
Expand Down

0 comments on commit 215b431

Please sign in to comment.