Skip to content

Commit

Permalink
Changed resolve function to be resolveReferences to be more expli…
Browse files Browse the repository at this point in the history
…cit.
  • Loading branch information
iwoplaza committed Feb 21, 2024
1 parent 1c4caa3 commit 709fd86
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/structure/keyed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class RefSchema<TKeyDef extends string> implements ISchema<Ref<TKeyDef>> {
this.ref = new Ref(key);
}

resolve(): void {
resolveReferences(): void {
throw new UnresolvedReferenceError(
`Tried to resolve a reference directly. Do it through a RefResolver instead.`,
);
Expand Down Expand Up @@ -76,7 +76,7 @@ class RefResolve implements IRefResolver {
}

// Since it's not a RefSchema, we assume it can be resolved.
unstableSchema.resolve(this);
unstableSchema.resolveReferences(this);

return unstableSchema;
}
Expand All @@ -98,14 +98,14 @@ export class KeyedSchema<
this.innerType = innerResolver(new RefSchema(key));

// Automatically resolving after keyed creation.
this.resolve(new RefResolve());
this.resolveReferences(new RefResolve());
}

resolve(ctx: IRefResolver): void {
resolveReferences(ctx: IRefResolver): void {
if (!ctx.hasKey(this.key)) {
ctx.register(this.key, this.innerType);

this.innerType.resolve(ctx);
this.innerType.resolveReferences(ctx);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/structure/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export type PropertyDescription = {
export interface ISchema<TUnwrapped> {
readonly __unwrapped: TUnwrapped;

resolve(ctx: IRefResolver): void;
resolveReferences(ctx: IRefResolver): void;
write(output: ISerialOutput, value: Parsed<TUnwrapped>): void;
read(input: ISerialInput): Parsed<TUnwrapped>;
measure(
Expand All @@ -119,7 +119,7 @@ export abstract class Schema<TUnwrapped> implements ISchema<TUnwrapped> {
readonly __unwrapped!: TUnwrapped;

// eslint-disable-next-line @typescript-eslint/no-unused-vars
resolve(ctx: IRefResolver): void {
resolveReferences(ctx: IRefResolver): void {
// override this if you need to resolve internal references.
}
abstract write(output: ISerialOutput, value: Parsed<TUnwrapped>): void;
Expand Down

0 comments on commit 709fd86

Please sign in to comment.